Commit cb433eee by Dima Bart

Rename NSURLSessionDataTask return type to BUYRequestOperation.

parent 4524f2b7
...@@ -74,9 +74,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -74,9 +74,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param customerID A customer ID retrieved from either customer creation or login * @param customerID A customer ID retrieved from either customer creation or login
* @param block (BUYCustomer *customer, NSError *error) * @param block (BUYCustomer *customer, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block; - (BUYRequestOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block;
/** /**
* POST /api/customers * POST /api/customers
...@@ -86,11 +86,11 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -86,11 +86,11 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param credentials Credentials object containing items for required fields * @param credentials Credentials object containing items for required fields
* @param block (BUYCustomer *customer, NSString *token, NSError *error) * @param block (BUYCustomer *customer, NSString *token, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
* *
* @discussion The customer is automatically logged in using -loginCustomerWithCredentials:callback: * @discussion The customer is automatically logged in using -loginCustomerWithCredentials:callback:
*/ */
- (NSURLSessionDataTask *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block; - (BUYRequestOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block;
/** /**
* POST /api/customers/customer_token * POST /api/customers/customer_token
...@@ -100,9 +100,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -100,9 +100,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param credentials Credentials object containing items for required fields * @param credentials Credentials object containing items for required fields
* @param block (BUYCustomer *customer, NSString *token, NSError *error) * @param block (BUYCustomer *customer, NSString *token, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block; - (BUYRequestOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block;
/** /**
* POST /api/customers/recover * POST /api/customers/recover
...@@ -111,9 +111,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -111,9 +111,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param email Email to send the password reset to * @param email Email to send the password reset to
* @param block (BUYStatus status, NSError *error) * @param block (BUYStatus status, NSError *error)
* *
* @return the associated NSURLSessionDataTask * @return the associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block; - (BUYRequestOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block;
/** /**
* PUT /api/customers/:customer_id/customer_token/renew * PUT /api/customers/:customer_id/customer_token/renew
...@@ -122,9 +122,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -122,9 +122,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param customerID ID of customer renewing token * @param customerID ID of customer renewing token
* @param block (NSString *token, NSError *error) * @param block (NSString *token, NSError *error)
* *
* @return the associated NSURLSessionDataTask * @return the associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block; - (BUYRequestOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block;
/** /**
* PUT /api/customers/:customer_id/activate * PUT /api/customers/:customer_id/activate
...@@ -135,9 +135,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -135,9 +135,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param customerToken Token contained in activation URL * @param customerToken Token contained in activation URL
* @param block (BUYCustomer *customer, NSString *token, NSError *error) * @param block (BUYCustomer *customer, NSString *token, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block; - (BUYRequestOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block;
/** /**
* PUT /api/customers/:customer_id/reset * PUT /api/customers/:customer_id/reset
...@@ -148,9 +148,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -148,9 +148,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param customerToken Token contained in reset URL * @param customerToken Token contained in reset URL
* @param block (BUYCustomer *customer, NSString *token, NSError *error) * @param block (BUYCustomer *customer, NSString *token, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block; - (BUYRequestOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block;
/** /**
* GET /api/customers/:customer_id/orders * GET /api/customers/:customer_id/orders
...@@ -159,9 +159,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr ...@@ -159,9 +159,9 @@ typedef void (^BUYDataOrdersBlock)(NSArray <BUYOrder*> * _Nullable orders, NSErr
* @param token An auth token retrieved from customer creation or customer login API * @param token An auth token retrieved from customer creation or customer login API
* @param block (NSArray <BUYOrder*> *orders, NSError *error) * @param block (NSArray <BUYOrder*> *orders, NSError *error)
* *
* @return The associated NSURLSessionDataTask * @return The associated BUYRequestOperation
*/ */
- (NSURLSessionDataTask *)getOrdersForCustomerWithCallback:(BUYDataOrdersBlock)block; - (BUYRequestOperation *)getOrdersForCustomerWithCallback:(BUYDataOrdersBlock)block;
@end @end
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#pragma mark - Customer #pragma mark - Customer
- (NSURLSessionDataTask *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block - (BUYRequestOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block
{ {
NSURL *route = [self urlForCustomersWithID:customerID]; NSURL *route = [self urlForCustomersWithID:customerID];
return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
}]; }];
} }
- (NSURLSessionDataTask *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block - (BUYRequestOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *route = [self urlForCustomers]; NSURL *route = [self urlForCustomers];
return [self postRequestForURL:route object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:route object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
}]; }];
} }
- (NSURLSessionDataTask *)createTokenForCustomerWithCredentials:(BUYAccountCredentials *)credentials customerJSON:(NSDictionary *)customerJSON callback:(BUYDataCustomerTokenBlock)block - (BUYRequestOperation *)createTokenForCustomerWithCredentials:(BUYAccountCredentials *)credentials customerJSON:(NSDictionary *)customerJSON callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *route = [self urlForCustomersToken]; NSURL *route = [self urlForCustomersToken];
return [self postRequestForURL:route object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:route object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
...@@ -87,12 +87,12 @@ ...@@ -87,12 +87,12 @@
}]; }];
} }
- (NSURLSessionDataTask *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block - (BUYRequestOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block
{ {
return [self createTokenForCustomerWithCredentials:credentials customerJSON:nil callback:block]; return [self createTokenForCustomerWithCredentials:credentials customerJSON:nil callback:block];
} }
- (NSURLSessionDataTask *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block - (BUYRequestOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block
{ {
NSURL *route = [self urlForCustomersPasswordRecovery]; NSURL *route = [self urlForCustomersPasswordRecovery];
return [self postRequestForURL:route object:@{@"email": email} completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self postRequestForURL:route object:@{@"email": email} completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
}]; }];
} }
- (NSURLSessionDataTask *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block - (BUYRequestOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block
{ {
if (self.customerToken) { if (self.customerToken) {
NSURL *route = [self urlForCustomersTokenRenewalWithID:customerID]; NSURL *route = [self urlForCustomersTokenRenewalWithID:customerID];
...@@ -130,7 +130,7 @@ ...@@ -130,7 +130,7 @@
} }
} }
- (NSURLSessionDataTask *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block - (BUYRequestOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *route = [self urlForCustomersActivationWithID:customerID parameters:@{ NSURL *route = [self urlForCustomersActivationWithID:customerID parameters:@{
@"token": customerToken, @"token": customerToken,
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
}]; }];
} }
- (NSURLSessionDataTask *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block - (BUYRequestOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID customerToken:(NSString *)customerToken callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *route = [self urlForCustomersPasswordResetWithID:customerID parameters:@{ NSURL *route = [self urlForCustomersPasswordResetWithID:customerID parameters:@{
@"token": customerToken, @"token": customerToken,
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
}]; }];
} }
- (NSURLSessionDataTask *)getOrdersForCustomerWithCallback:(BUYDataOrdersBlock)block - (BUYRequestOperation *)getOrdersForCustomerWithCallback:(BUYDataOrdersBlock)block
{ {
NSURL *route = [self urlForCustomersOrders]; NSURL *route = [self urlForCustomersOrders];
return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
@import Foundation; @import Foundation;
@class BUYModelManager; @class BUYModelManager;
@class BUYRequestOperation;
/** /**
* A BUYStatus is associated with the completion of an enqueued job on Shopify. * A BUYStatus is associated with the completion of an enqueued job on Shopify.
......
...@@ -118,27 +118,27 @@ static NSString * const BUYClientJSONMimeType = @"application/json"; ...@@ -118,27 +118,27 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
#pragma mark - Convenience Requests #pragma mark - Convenience Requests
- (NSURLSessionDataTask *)getRequestForURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)getRequestForURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
return [self requestForURL:url method:@"GET" object:nil completionHandler:completionHandler]; return [self requestForURL:url method:@"GET" object:nil completionHandler:completionHandler];
} }
- (NSURLSessionDataTask *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
return [self requestForURL:url method:@"POST" object:object completionHandler:completionHandler]; return [self requestForURL:url method:@"POST" object:object completionHandler:completionHandler];
} }
- (NSURLSessionDataTask *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
return [self requestForURL:url method:@"PUT" object:object completionHandler:completionHandler]; return [self requestForURL:url method:@"PUT" object:object completionHandler:completionHandler];
} }
- (NSURLSessionDataTask *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
return [self requestForURL:url method:@"PATCH" object:object completionHandler:completionHandler]; return [self requestForURL:url method:@"PATCH" object:object completionHandler:completionHandler];
} }
- (NSURLSessionDataTask *)deleteRequestForURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)deleteRequestForURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
return [self requestForURL:url method:@"DELETE" object:nil completionHandler:completionHandler]; return [self requestForURL:url method:@"DELETE" object:nil completionHandler:completionHandler];
} }
...@@ -156,7 +156,7 @@ static NSString * const BUYClientJSONMimeType = @"application/json"; ...@@ -156,7 +156,7 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
return [NSString stringWithFormat:@"%@ %@", @"Basic", [data base64EncodedStringWithOptions:0]]; return [NSString stringWithFormat:@"%@ %@", @"Basic", [data base64EncodedStringWithOptions:0]];
} }
- (NSURLSessionDataTask *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler - (BUYRequestOperation *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler
{ {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
if (object) { if (object) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment