Commit cb433eee by Dima Bart

Rename NSURLSessionDataTask return type to BUYRequestOperation.

parent 4524f2b7
...@@ -72,7 +72,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -72,7 +72,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
{ {
BUYCart *cart = [self cart]; BUYCart *cart = [self cart];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithCart:cart]; BUYCheckout *checkout = [[BUYCheckout alloc] initWithCart:cart];
NSURLSessionDataTask *task = [self.client createCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {}]; BUYRequestOperation *task = [self.client createCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {}];
XCTAssertNotNil(task); XCTAssertNotNil(task);
NSURLRequest *request = task.originalRequest; NSURLRequest *request = task.originalRequest;
...@@ -104,7 +104,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -104,7 +104,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
XCTAssertThrows([checkout setPartialAddressesValue:NO]); XCTAssertThrows([checkout setPartialAddressesValue:NO]);
NSURLSessionDataTask *task = [self.client createCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {}]; BUYRequestOperation *task = [self.client createCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {}];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:task.originalRequest.HTTPBody options:0 error:nil]; NSDictionary *json = [NSJSONSerialization JSONObjectWithData:task.originalRequest.HTTPBody options:0 error:nil];
XCTAssertFalse([json[@"checkout"][@"partial_addresses"] boolValue]); XCTAssertFalse([json[@"checkout"][@"partial_addresses"] boolValue]);
...@@ -128,7 +128,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -128,7 +128,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
{ {
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:self.client.modelManager JSONDictionary:@{@"token": @"abcdef", @"payment_due": @0}]; BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:self.client.modelManager JSONDictionary:@{@"token": @"abcdef", @"payment_due": @0}];
NSURLSessionDataTask *task = [self.client completeCheckout:checkout paymentToken:nil completion:^(BUYCheckout *checkout, NSError *error) {}]; BUYRequestOperation *task = [self.client completeCheckout:checkout paymentToken:nil completion:^(BUYCheckout *checkout, NSError *error) {}];
XCTAssertNotNil(task); XCTAssertNotNil(task);
} }
...@@ -209,7 +209,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -209,7 +209,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderCollectionDefault - (void)testProductsInCollectionWithSortOrderCollectionDefault
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCollectionDefault completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -221,7 +221,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -221,7 +221,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderBestSelling - (void)testProductsInCollectionWithSortOrderBestSelling
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortBestSelling completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortBestSelling completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -233,7 +233,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -233,7 +233,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderCreatedAscending - (void)testProductsInCollectionWithSortOrderCreatedAscending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCreatedAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCreatedAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -245,7 +245,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -245,7 +245,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderCreatedDescending - (void)testProductsInCollectionWithSortOrderCreatedDescending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCreatedDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortCreatedDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -257,7 +257,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -257,7 +257,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderPriceAscending - (void)testProductsInCollectionWithSortOrderPriceAscending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortPriceAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortPriceAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -269,7 +269,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -269,7 +269,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderPriceDescending - (void)testProductsInCollectionWithSortOrderPriceDescending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortPriceDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortPriceDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -281,7 +281,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -281,7 +281,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderTitleAscending - (void)testProductsInCollectionWithSortOrderTitleAscending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortTitleAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortTitleAscending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -293,7 +293,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -293,7 +293,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testProductsInCollectionWithSortOrderTitleDescending - (void)testProductsInCollectionWithSortOrderTitleDescending
{ {
NSURLSessionDataTask *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortTitleDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}]; BUYRequestOperation *task = [self.client getProductsPage:1 inCollection:@1 sortOrder:BUYCollectionSortTitleDescending completion:^(NSArray<BUYProduct *> *products, NSUInteger page, BOOL reachedEnd, NSError *error) {}];
XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET"); XCTAssertEqualObjects(task.originalRequest.HTTPMethod, @"GET");
XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https"); XCTAssertEqualObjects(task.originalRequest.URL.scheme, @"https");
XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop"); XCTAssertEqualObjects(task.originalRequest.URL.host, @"test_shop");
...@@ -321,7 +321,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -321,7 +321,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
]; ];
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items]; BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSURLSessionDataTask *task = [self.client createCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) { BUYRequestOperation *task = [self.client createCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
...@@ -350,7 +350,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -350,7 +350,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
[BUYAccountCredentialItem itemWithPassword:@"password"], [BUYAccountCredentialItem itemWithPassword:@"password"],
]; ];
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items]; BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSURLSessionDataTask *task = [self.client loginCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) { BUYRequestOperation *task = [self.client loginCustomerWithCredentials:credentials callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
...@@ -371,7 +371,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -371,7 +371,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testGetCustomerURL - (void)testGetCustomerURL
{ {
NSURLSessionDataTask *task = [self.client getCustomerWithID:@"" callback:^(BUYCustomer *customer, NSError *error) { BUYRequestOperation *task = [self.client getCustomerWithID:@"" callback:^(BUYCustomer *customer, NSError *error) {
}]; }];
...@@ -384,7 +384,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -384,7 +384,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testGetOrdersForCustomerURL - (void)testGetOrdersForCustomerURL
{ {
NSURLSessionDataTask *task = [self.client getOrdersForCustomerWithCallback:^(NSArray<BUYOrder *> *orders, NSError *error) { BUYRequestOperation *task = [self.client getOrdersForCustomerWithCallback:^(NSArray<BUYOrder *> *orders, NSError *error) {
}]; }];
...@@ -398,7 +398,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -398,7 +398,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testCustomerRecovery - (void)testCustomerRecovery
{ {
NSString *email = @"fake@example.com"; NSString *email = @"fake@example.com";
NSURLSessionDataTask *task = [self.client recoverPasswordForCustomer:email callback:^(BUYStatus status, NSError *error) { BUYRequestOperation *task = [self.client recoverPasswordForCustomer:email callback:^(BUYStatus status, NSError *error) {
}]; }];
...@@ -418,7 +418,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -418,7 +418,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
{ {
self.client.customerToken = nil; self.client.customerToken = nil;
NSURLSessionDataTask *task = [self.client renewCustomerTokenWithID:@"" callback:^(NSString *token, NSError *error) {}]; BUYRequestOperation *task = [self.client renewCustomerTokenWithID:@"" callback:^(NSString *token, NSError *error) {}];
XCTAssertNil(task); // task should be nil if no customer token was set on the client XCTAssertNil(task); // task should be nil if no customer token was set on the client
self.client.customerToken = BUYFakeCustomerToken; self.client.customerToken = BUYFakeCustomerToken;
...@@ -440,7 +440,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -440,7 +440,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items]; BUYAccountCredentials *credentials = [BUYAccountCredentials credentialsWithItems:items];
NSString *customerID = @"12345"; NSString *customerID = @"12345";
NSString *customerToken = @"12345"; NSString *customerToken = @"12345";
NSURLSessionDataTask *task = [self.client activateCustomerWithCredentials:credentials customerID:customerID customerToken:customerToken callback:^(BUYCustomer *customer, NSString *token, NSError *error) { BUYRequestOperation *task = [self.client activateCustomerWithCredentials:credentials customerID:customerID customerToken:customerToken callback:^(BUYCustomer *customer, NSString *token, NSError *error) {
}]; }];
......
...@@ -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