Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Classes/Core/HSGear.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#import "HSNewTicket.h"
#import "HSAttachment.h"
#import "HSTicketReply.h"
#import <AFNetworking/AFHTTPRequestOperationManager.h>
#import <AFNetworking/AFHTTPSessionManager.h>



Expand Down Expand Up @@ -162,7 +162,7 @@

@property (nonatomic, strong) NSString* supportEmailAddress;
@property (nonatomic, strong) NSString* localArticlePath;
@property (nonatomic, strong) AFHTTPRequestOperationManager* networkManager;
@property (nonatomic, strong) AFHTTPSessionManager* networkManager;


@end
Expand Down
54 changes: 27 additions & 27 deletions Classes/Stacks/Desk/HSDeskGear.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#import "HSDeskGear.h"
#import "HSDeskKBItem.h"
#import "HSDeskCase.h"
#import <AFNetworking/AFHTTPRequestOperationManager.h>
#import <AFNetworking/AFHTTPSessionManager.h>
#import "UIImage+Extended.h"
#import <AFNetworking/AFNetworkActivityIndicatorManager.h>

Expand All @@ -44,14 +44,14 @@ - (instancetype)initWithInstanceBaseUrl:(NSString*)instanceBaseURL toHelpEmail:(


NSURL* baseURL = [[NSURL alloc] initWithString:instanceBaseURL];
AFHTTPRequestOperationManager* operationManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:baseURL];
AFHTTPSessionManager* sessionManager = [[AFHTTPSessionManager alloc] initWithBaseURL:baseURL];

[operationManager setRequestSerializer:[AFJSONRequestSerializer serializer]];
[operationManager.requestSerializer setAuthorizationHeaderFieldWithUsername:loginEmail password:password];
[operationManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[operationManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[sessionManager setRequestSerializer:[AFJSONRequestSerializer serializer]];
[sessionManager.requestSerializer setAuthorizationHeaderFieldWithUsername:loginEmail password:password];
[sessionManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[sessionManager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];

self.networkManager = operationManager;
self.networkManager = sessionManager;

[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES];

Expand Down Expand Up @@ -84,7 +84,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:(
NSDictionary* params = @{ @"type":@"email", @"subject": newTicket.subject, @"_links":customerLinks, @"message":messageFields};


[self.networkManager POST:@"api/v2/cases" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager POST:@"api/v2/cases" parameters:params success:^(NSURLSessionTask *operation, id responseObject) {

NSDictionary* responsedata = (NSDictionary*)responseObject;

Expand All @@ -104,9 +104,9 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:(
NSString* attachmentPostURL = [caseLink stringByAppendingPathComponent:@"attachments"];
NSDictionary* attachmentParams = @{ @"file_name": attachment.fileName, @"content_type":@"image/png", @"content": attachment.attachmentImage.base64EncodedString };

[self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(NSURLSessionTask *operation, id responseObject) {
success(deskCase, user);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Case created. But Error creating attachment %@", error.localizedDescription);
success(deskCase, user);
}];
Expand All @@ -116,7 +116,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:(
}


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error creating case %@", error.localizedDescription);

failure(error);
Expand All @@ -141,7 +141,7 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes

NSString* messageURL = [NSString stringWithFormat:@"%@/message", deskCase.apiHref];

[self.networkManager GET:messageURL parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:messageURL parameters:nil success:^(NSURLSessionTask *operation, id responseObject) {

HSUpdate* originalMessage = [[HSUpdate alloc] init];
originalMessage.content = [responseObject objectForKey:@"body"];
Expand All @@ -158,7 +158,7 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes

NSDictionary* params = @{@"sort_field": @"updated_at", @"sort_direction": @"asc"};

[self.networkManager GET:repliesURL parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:repliesURL parameters:params success:^(NSURLSessionTask *operation, id responseObject) {

//got the replies

Expand Down Expand Up @@ -189,13 +189,13 @@ - (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user succes

success(allReplies);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {

failure(error);
}];


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {

failure(error);
}];
Expand Down Expand Up @@ -224,7 +224,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU

NSDictionary* messageFields = @{@"direction": @"in", @"body":reply.content, @"to": self.toHelpEmail}; //creating a user reply.

[self.networkManager POST:[NSString stringWithFormat:@"%@/replies", deskCase.apiHref] parameters:messageFields success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager POST:[NSString stringWithFormat:@"%@/replies", deskCase.apiHref] parameters:messageFields success:^(NSURLSessionTask *operation, id responseObject) {

NSDictionary* responsedata = (NSDictionary*)responseObject;

Expand All @@ -245,12 +245,12 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU
NSString* attachmentPostURL = [deskCase.apiHref stringByAppendingPathComponent:@"attachments"];
NSDictionary* attachmentParams = @{ @"file_name": @"Screenshot", @"content_type":@"image/png", @"content": attachment.attachmentImage.base64EncodedString };

[self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager POST:attachmentPostURL parameters:attachmentParams success:^(NSURLSessionTask *operation, id responseObject) {

userReply.attachments = reply.attachments;

success(userReply);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Case created. But Error creating attachment %@", error.localizedDescription);
success(userReply);
}];
Expand All @@ -265,7 +265,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU
success(userReply);
}

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {

NSLog(@"Error replying to case %@", error.localizedDescription);
failure(error);
Expand All @@ -292,7 +292,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k
if (!section) {

// GET ALL SUPPORT CENTER TOPICS
[self.networkManager GET:@"/api/v2/topics" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:@"/api/v2/topics" parameters:nil success:^(NSURLSessionTask *operation, id responseObject) {
NSDictionary* response = (NSDictionary*)responseObject;
NSNumber* numOfTopics = [response objectForKey:@"total_entries"];

Expand Down Expand Up @@ -322,7 +322,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k
}else{
success(nil);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {
failure(error);
}];

Expand All @@ -334,7 +334,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k

NSDictionary* articlesLinks = [deskTopic.apiLinks objectForKey:@"articles"];

[self.networkManager GET:[articlesLinks objectForKey:@"href"] parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:[articlesLinks objectForKey:@"href"] parameters:nil success:^(NSURLSessionTask *operation, id responseObject) {

NSDictionary* response = (NSDictionary*)responseObject;
NSNumber* numEntries = [response objectForKey:@"total_entries"];
Expand Down Expand Up @@ -369,7 +369,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k
}else{
success(nil);
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {
failure(error);
}];
}
Expand All @@ -386,7 +386,7 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid

NSDictionary* params = @{@"email": user.email};

[self.networkManager GET:@"api/v2/customers/search" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:@"api/v2/customers/search" parameters:params success:^(NSURLSessionTask *operation, id responseObject) {

NSNumber* totalEntries = [responseObject objectForKey:@"total_entries"];

Expand Down Expand Up @@ -448,7 +448,7 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid
NSArray* emails = @[@{@"type": @"home", @"value":user.email}];
NSDictionary* params = @{@"first_name": user.firstName, @"last_name":user.lastName, @"emails":emails };

[self.networkManager POST:@"api/v2/customers" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager POST:@"api/v2/customers" parameters:params success:^(NSURLSessionTask *operation, id responseObject) {

HSUser* validUser = nil;
validUser = [[HSUser alloc] init];
Expand All @@ -465,14 +465,14 @@ - (void)checkAndFetchValidUser:(HSUser*)user withSuccess:(void (^)(HSUser* valid

success(validUser);

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {

NSLog(@"Error while creating customer record.");
failure(error);
}];
}

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
} failure:^(NSURLSessionTask *operation, NSError *error) {

NSLog(@"Error while searching customer record.");
failure(error);
Expand Down
26 changes: 13 additions & 13 deletions Classes/Stacks/HappyFox/HSHappyFoxGear.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ - (id)initWithInstanceUrl:(NSString*) instanceUrl apiKey:(NSString *)api_key aut
self.instanceUrl = instanceUrl;
self.hfCategoryID = category_ID;
self.hfPriorityID = priority_ID;
self.networkManager = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]];
self.networkManager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:instanceUrl]];
[self.networkManager setRequestSerializer:[AFJSONRequestSerializer serializer]];
[self.networkManager setResponseSerializer:[AFJSONResponseSerializer serializer]];
[self.networkManager.requestSerializer setAuthorizationHeaderFieldWithUsername:self.api_key password:self.auth_code];
Expand All @@ -64,7 +64,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k
url = [url stringByAppendingString:self.hfSectionID];
url = [url stringByAppendingString:@"/"];
}
[self.networkManager GET:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:url parameters:nil success:^(NSURLSessionTask *operation, id responseObject) {
self.articleSections = responseObject;
if(self.hfSectionID){
NSMutableArray *articles = [self getArticlesFromSection:responseObject];
Expand All @@ -73,7 +73,7 @@ - (void)fetchKBForSection:(HSKBItem*)section success:(void (^)(NSMutableArray* k
NSMutableArray *sections = [self getSectionsFromData:responseObject];
success(sections);
}
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}failure:^(NSURLSessionTask *operation, NSError *error) {
failure(error);
}];
} else {
Expand Down Expand Up @@ -111,10 +111,10 @@ -(NSMutableArray *)getSectionsFromData:(NSDictionary *)responseData{
- (void)fetchAllUpdateForTicket:(HSTicket *)ticket forUser:(HSUser *)user success:(void (^)(NSMutableArray* updateArray))success failure:(void (^)(NSError* e))failure {
NSString *getString = @"api/1.1/json/ticket/";
getString = [getString stringByAppendingString:ticket.ticketID];
[self.networkManager GET:getString parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self.networkManager GET:getString parameters:nil success:^(NSURLSessionTask *operation, id responseObject) {
NSMutableArray *tickUpdates = [self getTicketUpdatesFromResponseData:responseObject];
success(tickUpdates);
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}failure:^(NSURLSessionTask *operation, NSError *error) {
failure(error);
}];
}
Expand Down Expand Up @@ -179,7 +179,7 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:(
[formData appendPartWithFileData:attachment.attachmentData name:@"attachments" fileName:((HSAttachment *)attachment).fileName mimeType:((HSAttachment *)attachment).mimeType];
}
}
}success:^(AFHTTPRequestOperation *operation, id responseObject) {
}success:^(NSURLSessionTask *operation, id responseObject) {
HSTicket *issue = [[HSTicket alloc] init];
issue.subject = [responseObject objectForKey:@"subject"];
issue.ticketID = [[responseObject objectForKey:@"id"] stringValue];
Expand All @@ -188,11 +188,11 @@ - (void)createNewTicket:(HSNewTicket *)newTicket byUser:(HSUser *)user success:(
NSString* userId = [[[responseObject objectForKey:@"user"] objectForKey:@"id"] stringValue];
hfUser.apiHref = userId;
success(issue, hfUser);
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}failure:^(NSURLSessionTask *operation, NSError *error) {

HALog(@"Failed to create a ticket %@", error);
if (operation.responseString) {
HALog(@"Error Description %@", operation.responseString);
if (operation.taskDescription) {
HALog(@"Error Description %@", operation.taskDescription);
}
failure(error);
}];
Expand All @@ -213,7 +213,7 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU
for(HSAttachment *attachment in attachments){
[formData appendPartWithFileData:attachment.attachmentData name:@"attachments" fileName:attachment.fileName mimeType:attachment.mimeType];
}
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
} success:^(NSURLSessionTask *operation, id responseObject) {

HSUpdate *recentUpdate = [[HSUpdate alloc] init];
recentUpdate.from = user.name;
Expand All @@ -223,10 +223,10 @@ - (void)addReply:(HSTicketReply *)reply forTicket:(HSTicket *)ticket byUser:(HSU
recentUpdate.updateType = HATypeUserReply;
success(recentUpdate);
//Send all the updates
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}failure:^(NSURLSessionTask *operation, NSError *error) {
HALog(@"Failed to update Ticket %@", error);
if (operation.responseString) {
HALog(@"Error Description %@", operation.responseString);
if (operation.taskDescription) {
HALog(@"Error Description %@", operation.taskDescription);
}
failure(error);
}];
Expand Down
Loading