Commit a2e76401 by Dima Bart

Merge pull request #207 from Shopify/task/private-operations

Prevent exposing BUYRequestOperation
parents 68c3b520 39dcac73
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
#pragma mark - Orders - #pragma mark - Orders -
...@@ -182,7 +182,7 @@ ...@@ -182,7 +182,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10.0 handler:nil]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
} }
- (void)testCustomerOrderWithID - (void)testCustomerOrderWithID
...@@ -198,7 +198,7 @@ ...@@ -198,7 +198,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10.0 handler:nil]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
} }
#pragma mark - Update - #pragma mark - Update -
...@@ -221,7 +221,7 @@ ...@@ -221,7 +221,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
#pragma mark - Address - #pragma mark - Address -
...@@ -245,7 +245,7 @@ ...@@ -245,7 +245,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
- (void)testAddressCRUD - (void)testAddressCRUD
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
- (void)getAddress - (void)getAddress
...@@ -312,7 +312,7 @@ ...@@ -312,7 +312,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
- (void)updateAddress - (void)updateAddress
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
- (void)deleteAddress - (void)deleteAddress
...@@ -365,7 +365,7 @@ ...@@ -365,7 +365,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
#pragma mark - Address - #pragma mark - Address -
......
...@@ -113,7 +113,7 @@ ...@@ -113,7 +113,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10 handler:nil]; [self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {}];
} }
- (void)testGetProductById - (void)testGetProductById
......
...@@ -165,7 +165,7 @@ ...@@ -165,7 +165,7 @@
[expectation fulfill]; [expectation fulfill];
}]; }];
[self waitForExpectationsWithTimeout:10.0 handler:nil]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
} }
- (void)updateCheckout - (void)updateCheckout
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
[operation start]; [operation start];
[self waitForExpectationsWithTimeout:3.0 handler:nil]; [self waitForExpectationsWithTimeout:3.0 handler:^(NSError *error) {}];
} }
#pragma mark - Data Tests - #pragma mark - Data Tests -
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
}]; }];
[self.queue addOperation:operation]; [self.queue addOperation:operation];
[self waitForExpectationsWithTimeout:3.0 handler:nil]; [self waitForExpectationsWithTimeout:3.0 handler:^(NSError *error) {}];
} }
- (void)testFailedRequest - (void)testFailedRequest
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
}]; }];
[self.queue addOperation:operation]; [self.queue addOperation:operation];
[self waitForExpectationsWithTimeout:3.0 handler:nil]; [self waitForExpectationsWithTimeout:3.0 handler:^(NSError *error) {}];
} }
#pragma mark - Dependency Tests - #pragma mark - Dependency Tests -
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
[self.queue addOperation:operation2]; [self.queue addOperation:operation2];
[self.queue addOperation:operation1]; [self.queue addOperation:operation1];
[self waitForExpectationsWithTimeout:10.0 handler:nil]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
XCTAssertEqualObjects(container, @"12"); XCTAssertEqualObjects(container, @"12");
} }
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
[self.queue addOperation:operation2]; [self.queue addOperation:operation2];
[self.queue addOperation:operation1]; [self.queue addOperation:operation1];
[self waitForExpectationsWithTimeout:10.0 handler:nil]; [self waitForExpectationsWithTimeout:10.0 handler:^(NSError *error) {}];
XCTAssertEqualObjects(container, @"1134"); XCTAssertEqualObjects(container, @"1134");
} }
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
}; };
[self.queue addOperation:operation]; [self.queue addOperation:operation];
[self waitForExpectationsWithTimeout:5.0 handler:nil]; [self waitForExpectationsWithTimeout:5.0 handler:^(NSError *error) {}];
} }
- (void)testCancellationBeforeExecution - (void)testCancellationBeforeExecution
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
[self.queue addOperation:operation]; [self.queue addOperation:operation];
[operation cancel]; [operation cancel];
[self waitForExpectationsWithTimeout:3.0 handler:nil]; [self waitForExpectationsWithTimeout:3.0 handler:^(NSError *error) {}];
} }
- (void)testCancellationDuringExecution - (void)testCancellationDuringExecution
...@@ -277,7 +277,7 @@ ...@@ -277,7 +277,7 @@
[operation cancel]; [operation cancel];
}]; }];
[self waitForExpectationsWithTimeout:4.0 handler:nil]; [self waitForExpectationsWithTimeout:4.0 handler:^(NSError *error) {}];
} }
- (void)testCancellationWithoutQueue - (void)testCancellationWithoutQueue
...@@ -292,7 +292,7 @@ ...@@ -292,7 +292,7 @@
[operation cancel]; [operation cancel];
[self createExpectationDelay]; [self createExpectationDelay];
[self waitForExpectationsWithTimeout:4.0 handler:nil]; [self waitForExpectationsWithTimeout:4.0 handler:^(NSError *error) {}];
} }
- (void)testCancellationDuringPolling - (void)testCancellationDuringPolling
...@@ -351,7 +351,7 @@ ...@@ -351,7 +351,7 @@
}]; }];
if (block) { if (block) {
[self waitForExpectationsWithTimeout:delay + 0.1 handler:nil]; [self waitForExpectationsWithTimeout:delay + 0.1 handler:^(NSError *error) {}];
} }
} }
......
//
// NSURLComponents+BUYAdditions.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@import Foundation;
@interface NSURLComponents (BUYAdditions)
- (void)setQueryItemsWithDictionary:(NSDictionary*)namesAndValues;
@end
//
// NSURLComponents+BUYAdditions.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "NSURLComponents+BUYAdditions.h"
@implementation NSURLComponents (BUYAdditions)
- (void)setQueryItemsWithDictionary:(NSDictionary*)dictionary
{
if (dictionary) {
NSMutableArray *queryItems = [NSMutableArray array];
for (NSString *key in [dictionary allKeys]) {
NSString *value = [dictionary[key] length] ? dictionary[key] : nil;
[queryItems addObject:[[NSURLQueryItem alloc] initWithName:key value:value]];
}
self.queryItems = [queryItems copy];
}
}
@end
...@@ -67,7 +67,6 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[]; ...@@ -67,7 +67,6 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYClient+Customers.h> #import <Buy/BUYClient+Customers.h>
#import <Buy/BUYClient+Checkout.h> #import <Buy/BUYClient+Checkout.h>
#import <Buy/BUYClient+Storefront.h> #import <Buy/BUYClient+Storefront.h>
#import <Buy/BUYRequestOperation.h>
#import <Buy/BUYError.h> #import <Buy/BUYError.h>
#import <Buy/BUYError+BUYAdditions.h> #import <Buy/BUYError+BUYAdditions.h>
#import <Buy/BUYManagedObject.h> #import <Buy/BUYManagedObject.h>
...@@ -91,4 +90,3 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[]; ...@@ -91,4 +90,3 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/NSRegularExpression+BUYAdditions.h> #import <Buy/NSRegularExpression+BUYAdditions.h>
#import <Buy/NSString+BUYAdditions.h> #import <Buy/NSString+BUYAdditions.h>
#import <Buy/NSURL+BUYAdditions.h> #import <Buy/NSURL+BUYAdditions.h>
#import <Buy/NSURLComponents+BUYAdditions.h>
...@@ -56,7 +56,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N ...@@ -56,7 +56,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getAddressesForCustomerID:(NSString *)customerID callback:(BUYDataAddressesBlock)block; - (NSOperation *)getAddressesForCustomerID:(NSString *)customerID callback:(BUYDataAddressesBlock)block;
/** /**
* GET /api/customers/:customer_id/addresses/:id * GET /api/customers/:customer_id/addresses/:id
...@@ -68,7 +68,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N ...@@ -68,7 +68,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block; - (NSOperation *)getAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block;
/** /**
* POST /api/customers/:customer_id/addresses * POST /api/customers/:customer_id/addresses
...@@ -80,7 +80,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N ...@@ -80,7 +80,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)createAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block; - (NSOperation *)createAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block;
/** /**
* PUT /api/customers/:customer_id/addresses/:id * PUT /api/customers/:customer_id/addresses/:id
...@@ -92,7 +92,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N ...@@ -92,7 +92,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)updateAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block; - (NSOperation *)updateAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block;
/** /**
* DELETE /api/customers/:customer_id/addresses/:id * DELETE /api/customers/:customer_id/addresses/:id
...@@ -104,7 +104,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N ...@@ -104,7 +104,7 @@ typedef void (^BUYDataAddressBlock)(BUYAddress * _Nullable address, NSError * _N
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)deleteAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataStatusBlock)block; - (NSOperation *)deleteAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataStatusBlock)block;
@end @end
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
@implementation BUYClient (Address) @implementation BUYClient (Address)
- (BUYRequestOperation *)getAddressesForCustomerID:(NSString *)customerID callback:(BUYDataAddressesBlock)block - (NSOperation *)getAddressesForCustomerID:(NSString *)customerID callback:(BUYDataAddressesBlock)block
{ {
NSURL *route = [self urlForCustomersAddressesWithID:customerID]; NSURL *route = [self urlForCustomersAddressesWithID:customerID];
return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
}]; }];
} }
- (BUYRequestOperation *)getAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block - (NSOperation *)getAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block
{ {
NSURL *route = [self urlForCustomersAddressWithID:customerID addressID:addressID]; NSURL *route = [self urlForCustomersAddressWithID:customerID addressID:addressID];
return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:route completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
}]; }];
} }
- (BUYRequestOperation *)createAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block - (NSOperation *)createAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block
{ {
NSURL *route = [self urlForCustomersAddressesWithID:customerID]; NSURL *route = [self urlForCustomersAddressesWithID:customerID];
return [self postRequestForURL:route object:@{ @"address" : address.JSONDictionary } completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:route object:@{ @"address" : address.JSONDictionary } completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
}]; }];
} }
- (BUYRequestOperation *)updateAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block - (NSOperation *)updateAddress:(BUYAddress *)address customerID:(NSString *)customerID callback:(BUYDataAddressBlock)block
{ {
BUYAssert(address.identifier, @"Failed to update address. Address must have a valid identifier."); BUYAssert(address.identifier, @"Failed to update address. Address must have a valid identifier.");
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
}]; }];
} }
- (BUYRequestOperation *)deleteAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataStatusBlock)block - (NSOperation *)deleteAddressWithID:(NSNumber *)addressID customerID:(NSString *)customerID callback:(BUYDataStatusBlock)block
{ {
BUYAssert(addressID, @"Failed to update address. Address must have a valid identifier."); BUYAssert(addressID, @"Failed to update address. Address must have a valid identifier.");
......
...@@ -80,7 +80,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -80,7 +80,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion; - (NSOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion;
/** /**
* Builds a checkout on Shopify. The checkout object is used to prepare an order * Builds a checkout on Shopify. The checkout object is used to prepare an order
...@@ -90,7 +90,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -90,7 +90,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (NSOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block;
/** /**
* Builds a checkout on Shopify using a Cart Token from an existing cart on your Shopify store's storefront. * Builds a checkout on Shopify using a Cart Token from an existing cart on your Shopify store's storefront.
...@@ -101,7 +101,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -101,7 +101,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)createCheckoutWithCartToken:(NSString *)cartToken completion:(BUYDataCheckoutBlock)block; - (NSOperation *)createCheckoutWithCartToken:(NSString *)cartToken completion:(BUYDataCheckoutBlock)block;
/** /**
* Updates a given BUYCheckout on Shopify. * Updates a given BUYCheckout on Shopify.
...@@ -116,7 +116,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -116,7 +116,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (NSOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block;
/** /**
* Retrieves an updated BUYCheckout. * Retrieves an updated BUYCheckout.
...@@ -126,7 +126,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -126,7 +126,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block; - (NSOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block;
/** /**
* Finalizes the BUYCheckout associated with the token and charges the payment provider (ex: Credit Card, Apple Pay, etc). * Finalizes the BUYCheckout associated with the token and charges the payment provider (ex: Credit Card, Apple Pay, etc).
...@@ -153,7 +153,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -153,7 +153,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block; - (NSOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block;
/** /**
* Retrieve the status of a checkout given a URL obtained in the UIApplicationDelegate method `application:sourceApplication:annotation` * Retrieve the status of a checkout given a URL obtained in the UIApplicationDelegate method `application:sourceApplication:annotation`
...@@ -163,7 +163,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -163,7 +163,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block; - (NSOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block;
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
...@@ -176,7 +176,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -176,7 +176,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block; - (NSOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block;
#pragma mark - Cards - #pragma mark - Cards -
...@@ -196,7 +196,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -196,7 +196,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block; - (NSOperation *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block;
/** /**
* Applies a gift card code to the checkout. * Applies a gift card code to the checkout.
...@@ -207,7 +207,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -207,7 +207,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)applyGiftCardCode:(NSString *)giftCardCode toCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (NSOperation *)applyGiftCardCode:(NSString *)giftCardCode toCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block;
/** /**
* Removes a gift card from the checkout. * Removes a gift card from the checkout.
...@@ -218,7 +218,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -218,7 +218,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)removeGiftCard:(BUYGiftCard *)giftCard fromCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (NSOperation *)removeGiftCard:(BUYGiftCard *)giftCard fromCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block;
#pragma mark - Reservations - #pragma mark - Reservations -
...@@ -232,7 +232,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -232,7 +232,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block; - (NSOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block;
@end @end
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#pragma mark - Checkout - #pragma mark - Checkout -
- (BUYRequestOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion - (NSOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion
{ {
if ([checkout hasToken]) { if ([checkout hasToken]) {
return [self updateCheckout:checkout completion:completion]; return [self updateCheckout:checkout completion:completion];
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
} }
} }
- (BUYRequestOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
BUYAssert(checkout, @"Failed to create checkout. Invalid checkout object."); BUYAssert(checkout, @"Failed to create checkout. Invalid checkout object.");
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
return [self postCheckout:json completion:block]; return [self postCheckout:json completion:block];
} }
- (BUYRequestOperation *)createCheckoutWithCartToken:(NSString *)cartToken completion:(BUYDataCheckoutBlock)block - (NSOperation *)createCheckoutWithCartToken:(NSString *)cartToken completion:(BUYDataCheckoutBlock)block
{ {
BUYAssert(cartToken, @"Failed to create checkout. Invalid cart token"); BUYAssert(cartToken, @"Failed to create checkout. Invalid cart token");
BUYCheckout *checkout = [self.modelManager checkoutwithCartToken:cartToken]; BUYCheckout *checkout = [self.modelManager checkoutwithCartToken:cartToken];
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
return [self postCheckout:json completion:block]; return [self postCheckout:json completion:block];
} }
- (BUYRequestOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertCheckout(checkout);
...@@ -87,12 +87,12 @@ ...@@ -87,12 +87,12 @@
}]; }];
} }
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block - (NSOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block
{ {
return [self getCheckoutWithToken:checkoutToken start:YES completion:block]; return [self getCheckoutWithToken:checkoutToken start:YES completion:block];
} }
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block - (NSOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
...@@ -109,13 +109,13 @@ ...@@ -109,13 +109,13 @@
return operation; return operation;
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block - (NSOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
return [self getCompletionStatusOfCheckoutWithToken:checkoutToken start:YES completion:block]; return [self getCompletionStatusOfCheckoutWithToken:checkoutToken start:YES completion:block];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block - (NSOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block
{ {
NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO]; NSURLComponents *components = [NSURLComponents componentsWithURL:url resolvingAgainstBaseURL:NO];
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
#pragma mark - Checkout Helpers - #pragma mark - Checkout Helpers -
- (BUYRequestOperation *)beginCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block - (NSOperation *)beginCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
...@@ -144,7 +144,7 @@ ...@@ -144,7 +144,7 @@
}]; }];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block - (NSOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block
{ {
NSURL *url = [self urlForCheckoutsProcessingWithToken:token]; NSURL *url = [self urlForCheckoutsProcessingWithToken:token];
return [self getRequestForURL:url start:start completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:url start:start completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
}]; }];
} }
- (BUYRequestOperation *)postCheckout:(NSDictionary *)checkoutJSON completion:(BUYDataCheckoutBlock)block - (NSOperation *)postCheckout:(NSDictionary *)checkoutJSON completion:(BUYDataCheckoutBlock)block
{ {
return [self postRequestForURL:[self urlForCheckouts] object:checkoutJSON completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:[self urlForCheckouts] object:checkoutJSON completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
[self handleCheckoutResponse:json error:error block:block]; [self handleCheckoutResponse:json error:error block:block];
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
- (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block - (NSOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
...@@ -188,7 +188,7 @@ ...@@ -188,7 +188,7 @@
@"checkout" : @"", @"checkout" : @"",
}]; }];
BUYRequestOperation *operation = [self getRequestForURL:url start:NO completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { BUYRequestOperation *operation = (BUYRequestOperation *)[self getRequestForURL:url start:NO completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
NSArray *shippingRates = nil; NSArray *shippingRates = nil;
if (json && !error) { if (json && !error) {
shippingRates = [self.modelManager insertShippingRatesWithJSONArray:json[@"shipping_rates"]]; shippingRates = [self.modelManager insertShippingRatesWithJSONArray:json[@"shipping_rates"]];
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
#pragma mark - Cards - #pragma mark - Cards -
- (BUYRequestOperation *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)completion - (NSOperation *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)completion
{ {
BUYAssertCheckout(checkout); BUYAssertCheckout(checkout);
BUYAssert(creditCard, @"Failed to store credit card. No credit card provided."); BUYAssert(creditCard, @"Failed to store credit card. No credit card provided.");
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
}]; }];
} }
- (BUYRequestOperation *)applyGiftCardCode:(NSString *)giftCardCode toCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSOperation *)applyGiftCardCode:(NSString *)giftCardCode toCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertCheckout(checkout);
BUYAssert(giftCardCode.length > 0, @"Failed to apply gift card code. Invalid gift card code."); BUYAssert(giftCardCode.length > 0, @"Failed to apply gift card code. Invalid gift card code.");
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
}]; }];
} }
- (BUYRequestOperation *)removeGiftCard:(BUYGiftCard *)giftCard fromCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSOperation *)removeGiftCard:(BUYGiftCard *)giftCard fromCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertCheckout(checkout);
BUYAssert(giftCard.identifier, @"Failed to remove gift card. Gift card must have a valid identifier."); BUYAssert(giftCard.identifier, @"Failed to remove gift card. Gift card must have a valid identifier.");
...@@ -282,7 +282,7 @@ ...@@ -282,7 +282,7 @@
#pragma mark - Reservations - #pragma mark - Reservations -
- (BUYRequestOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block - (NSOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
......
...@@ -86,7 +86,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -86,7 +86,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block; - (NSOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block;
#pragma mark - Customer - #pragma mark - Customer -
...@@ -102,7 +102,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -102,7 +102,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @discussion The customer is automatically logged in using -loginCustomerWithCredentials:callback: * @discussion The customer is automatically logged in using -loginCustomerWithCredentials:callback:
*/ */
- (BUYRequestOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block; - (NSOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block;
/** /**
* PUT /api/customers/:customer_id/activate * PUT /api/customers/:customer_id/activate
...@@ -115,7 +115,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -115,7 +115,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block; - (NSOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block;
/** /**
* PUT /api/customers/:customer_id * PUT /api/customers/:customer_id
...@@ -127,7 +127,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -127,7 +127,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID callback:(BUYDataCustomerBlock)block; - (NSOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID callback:(BUYDataCustomerBlock)block;
/** /**
* PUT /api/customers/:customer_id/reset * PUT /api/customers/:customer_id/reset
...@@ -140,7 +140,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -140,7 +140,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block; - (NSOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block;
#pragma mark - Token - #pragma mark - Token -
...@@ -153,7 +153,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -153,7 +153,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return the associated BUYRequestOperation * @return the associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block; - (NSOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block;
#pragma mark - Login - #pragma mark - Login -
...@@ -167,7 +167,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -167,7 +167,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block; - (NSOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block;
/** /**
* DELETE /api/customers/:customer_id/customer_token * DELETE /api/customers/:customer_id/customer_token
...@@ -179,7 +179,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -179,7 +179,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)logoutCustomerID:(NSString *)customerID callback:(BUYDataStatusBlock)block; - (NSOperation *)logoutCustomerID:(NSString *)customerID callback:(BUYDataStatusBlock)block;
/** /**
* POST /api/customers/recover * POST /api/customers/recover
...@@ -190,7 +190,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -190,7 +190,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return the associated BUYRequestOperation * @return the associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block; - (NSOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block;
#pragma mark - Orders - #pragma mark - Orders -
...@@ -203,7 +203,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -203,7 +203,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getOrdersForCustomerWithID:(NSString *)customerID callback:(BUYDataOrdersBlock)block; - (NSOperation *)getOrdersForCustomerWithID:(NSString *)customerID callback:(BUYDataOrdersBlock)block;
/** /**
* GET /api/customers/:customer_id/orders/:id * GET /api/customers/:customer_id/orders/:id
...@@ -215,7 +215,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl ...@@ -215,7 +215,7 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getOrderWithID:(NSNumber *)orderID customerID:(NSString *)customerID callback:(BUYDataOrderBlock)block; - (NSOperation *)getOrderWithID:(NSNumber *)orderID customerID:(NSString *)customerID callback:(BUYDataOrderBlock)block;
@end @end
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#pragma mark - Getting - #pragma mark - Getting -
- (BUYRequestOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block - (NSOperation *)getCustomerWithID:(NSString *)customerID callback:(BUYDataCustomerBlock)block
{ {
NSURL *url = [self urlForCustomersWithID:customerID]; NSURL *url = [self urlForCustomersWithID:customerID];
return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
#pragma mark - Customer - #pragma mark - Customer -
- (BUYRequestOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block - (NSOperation *)createCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *url = [self urlForCustomers]; NSURL *url = [self urlForCustomers];
return [self postRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
}]; }];
} }
- (BUYRequestOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block - (NSOperation *)activateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *url = [self urlForCustomersActivationWithID:customerID parameters:@{ @"token": token }]; NSURL *url = [self urlForCustomersActivationWithID:customerID parameters:@{ @"token": token }];
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
}]; }];
} }
- (BUYRequestOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID callback:(BUYDataCustomerBlock)block - (NSOperation *)updateCustomerWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID callback:(BUYDataCustomerBlock)block
{ {
NSURL *url = [self urlForCustomersWithID:customerID]; NSURL *url = [self urlForCustomersWithID:customerID];
return [self putRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self putRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -93,7 +93,7 @@ ...@@ -93,7 +93,7 @@
}]; }];
} }
- (BUYRequestOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block - (NSOperation *)resetPasswordWithCredentials:(BUYAccountCredentials *)credentials customerID:(NSString *)customerID token:(NSString *)token callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *url = [self urlForCustomersPasswordResetWithID:customerID parameters:@{ @"token": token }]; NSURL *url = [self urlForCustomersPasswordResetWithID:customerID parameters:@{ @"token": token }];
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
#pragma mark - Token - #pragma mark - Token -
- (BUYRequestOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block - (NSOperation *)renewCustomerTokenWithID:(NSString *)customerID callback:(BUYDataTokenBlock)block
{ {
if (self.customerToken) { if (self.customerToken) {
NSURL *url = [self urlForCustomersTokenRenewalWithID:customerID]; NSURL *url = [self urlForCustomersTokenRenewalWithID:customerID];
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
#pragma mark - Login - #pragma mark - Login -
- (BUYRequestOperation *)logoutCustomerID:(NSString *)customerID callback:(BUYDataStatusBlock)block - (NSOperation *)logoutCustomerID:(NSString *)customerID callback:(BUYDataStatusBlock)block
{ {
NSURL *url = [self urlForCustomersTokenWithID:customerID]; NSURL *url = [self urlForCustomersTokenWithID:customerID];
return [self deleteRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self deleteRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -142,12 +142,12 @@ ...@@ -142,12 +142,12 @@
}]; }];
} }
- (BUYRequestOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block - (NSOperation *)loginCustomerWithCredentials:(BUYAccountCredentials *)credentials callback:(BUYDataCustomerTokenBlock)block
{ {
return [self createTokenForCustomerWithCredentials:credentials customerJSON:nil callback:block]; return [self createTokenForCustomerWithCredentials:credentials customerJSON:nil callback:block];
} }
- (BUYRequestOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block - (NSOperation *)recoverPasswordForCustomer:(NSString *)email callback:(BUYDataStatusBlock)block
{ {
NSURL *url = [self urlForCustomersPasswordRecovery]; NSURL *url = [self urlForCustomersPasswordRecovery];
return [self postRequestForURL:url object:@{@"email": email} completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:url object:@{@"email": email} completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -157,7 +157,7 @@ ...@@ -157,7 +157,7 @@
#pragma mark - Orders - #pragma mark - Orders -
- (BUYRequestOperation *)getOrdersForCustomerWithID:(NSString *)customerID callback:(BUYDataOrdersBlock)block - (NSOperation *)getOrdersForCustomerWithID:(NSString *)customerID callback:(BUYDataOrdersBlock)block
{ {
NSURL *url = [self urlForCustomersOrdersWithID:customerID]; NSURL *url = [self urlForCustomersOrdersWithID:customerID];
return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
}]; }];
} }
- (BUYRequestOperation *)getOrderWithID:(NSNumber *)orderID customerID:(NSString *)customerID callback:(BUYDataOrderBlock)block - (NSOperation *)getOrderWithID:(NSNumber *)orderID customerID:(NSString *)customerID callback:(BUYDataOrderBlock)block
{ {
NSURL *url = [self urlForCustomersOrdersWithID:customerID orderID:orderID]; NSURL *url = [self urlForCustomersOrdersWithID:customerID orderID:orderID];
return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:url completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
...@@ -185,7 +185,7 @@ ...@@ -185,7 +185,7 @@
#pragma mark - Helpers - #pragma mark - Helpers -
- (BUYRequestOperation *)createTokenForCustomerWithCredentials:(BUYAccountCredentials *)credentials customerJSON:(NSDictionary *)customerJSON callback:(BUYDataCustomerTokenBlock)block - (NSOperation *)createTokenForCustomerWithCredentials:(BUYAccountCredentials *)credentials customerJSON:(NSDictionary *)customerJSON callback:(BUYDataCustomerTokenBlock)block
{ {
NSURL *url = [self urlForCustomersToken]; NSURL *url = [self urlForCustomersToken];
return [self postRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:url object:credentials.JSONRepresentation completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
......
...@@ -36,23 +36,23 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp ...@@ -36,23 +36,23 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp
@interface BUYClient (Internal) @interface BUYClient (Internal)
- (BUYRequestOperation *)getRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)getRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)deleteRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)deleteRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)getRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)getRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)deleteRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)deleteRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYRequestOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler; - (NSOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler;
- (BUYStatus)statusForStatusCode:(NSUInteger)statusCode error:(NSError *)error; - (BUYStatus)statusForStatusCode:(NSUInteger)statusCode error:(NSError *)error;
- (void)startOperation:(BUYOperation *)operation; - (void)startOperation:(NSOperation *)operation;
@end @end
...@@ -62,8 +62,8 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp ...@@ -62,8 +62,8 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp
@interface BUYClient (PrivateCheckout) @interface BUYClient (PrivateCheckout)
- (BUYRequestOperation *)beginCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block; - (NSOperation *)beginCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block; - (NSOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block;
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block; - (NSOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block;
@end @end
...@@ -128,7 +128,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -128,7 +128,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getShop:(BUYDataShopBlock)block; - (NSOperation *)getShop:(BUYDataShopBlock)block;
/** /**
* Fetches a single page of products for the shop. * Fetches a single page of products for the shop.
...@@ -138,7 +138,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -138,7 +138,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page completion:(BUYDataProductListBlock)block; - (NSOperation *)getProductsPage:(NSUInteger)page completion:(BUYDataProductListBlock)block;
/** /**
* Fetches a single product by the handle of the product. * Fetches a single product by the handle of the product.
...@@ -148,7 +148,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -148,7 +148,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductByHandle:(NSString *)handle completion:(BUYDataProductBlock)block; - (NSOperation *)getProductByHandle:(NSString *)handle completion:(BUYDataProductBlock)block;
/** /**
* Fetches a single product by the ID of the product. * Fetches a single product by the ID of the product.
...@@ -158,7 +158,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -158,7 +158,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block; - (NSOperation *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block;
/** /**
* Fetches a list of product by the ID of each product. * Fetches a list of product by the ID of each product.
...@@ -168,7 +168,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -168,7 +168,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductsByIds:(NSArray<NSString *> *)productIds completion:(BUYDataProductsBlock)block; - (NSOperation *)getProductsByIds:(NSArray<NSString *> *)productIds completion:(BUYDataProductsBlock)block;
/** /**
* Fetches collections based off page * Fetches collections based off page
...@@ -178,7 +178,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -178,7 +178,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCollectionsPage:(NSUInteger)page completion:(BUYDataCollectionsListBlock)block; - (NSOperation *)getCollectionsPage:(NSUInteger)page completion:(BUYDataCollectionsListBlock)block;
/** /**
* Fetches the products in the given collection with the collection's * Fetches the products in the given collection with the collection's
...@@ -190,7 +190,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -190,7 +190,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return the associated BUYRequestOperation * @return the associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId completion:(BUYDataProductListBlock)block; - (NSOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId completion:(BUYDataProductListBlock)block;
/** /**
* Fetches the products in the given collection with a given sort order * Fetches the products in the given collection with a given sort order
...@@ -202,7 +202,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc ...@@ -202,7 +202,7 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
* *
* @return the associated BUYRequestOperation * @return the associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId sortOrder:(BUYCollectionSort)sortOrder completion:(BUYDataProductListBlock)block; - (NSOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId sortOrder:(BUYCollectionSort)sortOrder completion:(BUYDataProductListBlock)block;
@end @end
......
...@@ -47,7 +47,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -47,7 +47,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
#pragma mark - API - #pragma mark - API -
- (BUYRequestOperation *)getShop:(BUYDataShopBlock)block - (NSOperation *)getShop:(BUYDataShopBlock)block
{ {
return [self getRequestForURL:[self urlForShop] completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self getRequestForURL:[self urlForShop] completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
BUYShop *shop = nil; BUYShop *shop = nil;
...@@ -58,7 +58,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -58,7 +58,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page completion:(BUYDataProductListBlock)block - (NSOperation *)getProductsPage:(NSUInteger)page completion:(BUYDataProductListBlock)block
{ {
NSURL *url = [self urlForProductListingsWithParameters:@{ NSURL *url = [self urlForProductListingsWithParameters:@{
@"limit" : @(self.pageSize), @"limit" : @(self.pageSize),
...@@ -75,7 +75,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -75,7 +75,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getProductByHandle:(NSString *)handle completion:(BUYDataProductBlock)block - (NSOperation *)getProductByHandle:(NSString *)handle completion:(BUYDataProductBlock)block
{ {
BUYAssert(handle, @"Failed to get product by handle. Product handle must not be nil."); BUYAssert(handle, @"Failed to get product by handle. Product handle must not be nil.");
...@@ -94,7 +94,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -94,7 +94,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block - (NSOperation *)getProductById:(NSString *)productId completion:(BUYDataProductBlock)block
{ {
BUYAssert(productId, @"Failed to get product by ID. Product ID must not be nil."); BUYAssert(productId, @"Failed to get product by ID. Product ID must not be nil.");
...@@ -103,7 +103,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -103,7 +103,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getProductsByIds:(NSArray *)productIds completion:(BUYDataProductsBlock)block - (NSOperation *)getProductsByIds:(NSArray *)productIds completion:(BUYDataProductsBlock)block
{ {
BUYAssert(productIds, @"Failed to get product by IDs. Product IDs array must not be nil."); BUYAssert(productIds, @"Failed to get product by IDs. Product IDs array must not be nil.");
...@@ -124,7 +124,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -124,7 +124,7 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getCollectionsPage:(NSUInteger)page completion:(BUYDataCollectionsListBlock)block - (NSOperation *)getCollectionsPage:(NSUInteger)page completion:(BUYDataCollectionsListBlock)block
{ {
NSURL *url = [self urlForCollectionListingsWithParameters:@{ NSURL *url = [self urlForCollectionListingsWithParameters:@{
@"limit" : @(self.pageSize), @"limit" : @(self.pageSize),
...@@ -141,12 +141,12 @@ static NSString * const BUYCollectionsKey = @"collection_listings"; ...@@ -141,12 +141,12 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}]; }];
} }
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId completion:(BUYDataProductListBlock)block - (NSOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId completion:(BUYDataProductListBlock)block
{ {
return [self getProductsPage:page inCollection:collectionId sortOrder:BUYCollectionSortCollectionDefault completion:block]; return [self getProductsPage:page inCollection:collectionId sortOrder:BUYCollectionSortCollectionDefault completion:block];
} }
- (BUYRequestOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId sortOrder:(BUYCollectionSort)sortOrder completion:(BUYDataProductListBlock)block - (NSOperation *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId sortOrder:(BUYCollectionSort)sortOrder completion:(BUYDataProductListBlock)block
{ {
BUYAssert(collectionId, @"Failed to get products page. Invalid collectionID."); BUYAssert(collectionId, @"Failed to get products page. Invalid collectionID.");
......
...@@ -125,61 +125,61 @@ static NSString * const BUYClientJSONMimeType = @"application/json"; ...@@ -125,61 +125,61 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
#pragma mark - Auto Starting Convenience Requests #pragma mark - Auto Starting Convenience Requests
- (BUYRequestOperation *)getRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)getRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self getRequestForURL:url start:YES completionHandler:completionHandler]; return [self getRequestForURL:url start:YES completionHandler:completionHandler];
} }
- (BUYRequestOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self postRequestForURL:url object:object start:YES completionHandler:completionHandler]; return [self postRequestForURL:url object:object start:YES completionHandler:completionHandler];
} }
- (BUYRequestOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self putRequestForURL:url object:object start:YES completionHandler:completionHandler]; return [self putRequestForURL:url object:object start:YES completionHandler:completionHandler];
} }
- (BUYRequestOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self patchRequestForURL:url object:object start:YES completionHandler:completionHandler]; return [self patchRequestForURL:url object:object start:YES completionHandler:completionHandler];
} }
- (BUYRequestOperation *)deleteRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)deleteRequestForURL:(NSURL *)url completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self deleteRequestForURL:url start:YES completionHandler:completionHandler]; return [self deleteRequestForURL:url start:YES completionHandler:completionHandler];
} }
#pragma mark - Convenience Requests #pragma mark - Convenience Requests
- (BUYRequestOperation *)getRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)getRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:@"GET" object:nil start:start completionHandler:completionHandler]; return [self requestForURL:url method:@"GET" object:nil start:start completionHandler:completionHandler];
} }
- (BUYRequestOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)postRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:@"POST" object:object start:start completionHandler:completionHandler]; return [self requestForURL:url method:@"POST" object:object start:start completionHandler:completionHandler];
} }
- (BUYRequestOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)putRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:@"PUT" object:object start:start completionHandler:completionHandler]; return [self requestForURL:url method:@"PUT" object:object start:start completionHandler:completionHandler];
} }
- (BUYRequestOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)patchRequestForURL:(NSURL *)url object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:@"PATCH" object:object start:start completionHandler:completionHandler]; return [self requestForURL:url method:@"PATCH" object:object start:start completionHandler:completionHandler];
} }
- (BUYRequestOperation *)deleteRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)deleteRequestForURL:(NSURL *)url start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:@"DELETE" object:nil start:start completionHandler:completionHandler]; return [self requestForURL:url method:@"DELETE" object:nil start:start completionHandler:completionHandler];
} }
#pragma mark - Generic Requests #pragma mark - Generic Requests
- (void)startOperation:(BUYOperation *)operation - (void)startOperation:(NSOperation *)operation
{ {
[self.requestQueue addOperation:operation]; [self.requestQueue addOperation:operation];
} }
...@@ -190,12 +190,12 @@ static NSString * const BUYClientJSONMimeType = @"application/json"; ...@@ -190,12 +190,12 @@ static NSString * const BUYClientJSONMimeType = @"application/json";
return [NSString stringWithFormat:@"%@ %@", @"Basic", [data base64EncodedStringWithOptions:0]]; return [NSString stringWithFormat:@"%@ %@", @"Basic", [data base64EncodedStringWithOptions:0]];
} }
- (BUYRequestOperation *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
return [self requestForURL:url method:method object:object start:YES completionHandler:completionHandler]; return [self requestForURL:url method:method object:object start:YES completionHandler:completionHandler];
} }
- (BUYRequestOperation *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler - (NSOperation *)requestForURL:(NSURL *)url method:(NSString *)method object:(id <BUYSerializable>)object start:(BOOL)start completionHandler:(BUYClientRequestJSONCompletion)completionHandler
{ {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
if (object) { if (object) {
......
...@@ -95,9 +95,9 @@ ...@@ -95,9 +95,9 @@
[super startExecution]; [super startExecution];
BUYRequestOperation *beginOperation = [self createBeginOperation]; NSOperation *beginOperation = [self createBeginOperation];
BUYRequestOperation *pollOperation = [self createPollOperation]; NSOperation *pollOperation = [self createPollOperation];
BUYRequestOperation *getOperation = [self createGetOperation]; NSOperation *getOperation = [self createGetOperation];
[pollOperation addDependency:beginOperation]; [pollOperation addDependency:beginOperation];
[getOperation addDependency:pollOperation]; [getOperation addDependency:pollOperation];
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
#pragma mark - Operations - #pragma mark - Operations -
- (BUYRequestOperation *)createBeginOperation - (NSOperation *)createBeginOperation
{ {
return [self.client beginCheckoutWithToken:self.checkoutToken paymentToken:self.token completion:^(BUYCheckout *checkout, NSError *error) { return [self.client beginCheckoutWithToken:self.checkoutToken paymentToken:self.token completion:^(BUYCheckout *checkout, NSError *error) {
if (!checkout) { if (!checkout) {
...@@ -144,9 +144,9 @@ ...@@ -144,9 +144,9 @@
}]; }];
} }
- (BUYRequestOperation *)createPollOperation - (NSOperation *)createPollOperation
{ {
BUYRequestOperation *operation =[self.client getCompletionStatusOfCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYStatus status, NSError *error) { BUYRequestOperation *operation = (BUYRequestOperation *)[self.client getCompletionStatusOfCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYStatus status, NSError *error) {
if (status != BUYStatusComplete) { if (status != BUYStatusComplete) {
[self finishWithError:error]; [self finishWithError:error];
} }
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
return operation; return operation;
} }
- (BUYRequestOperation *)createGetOperation - (NSOperation *)createGetOperation
{ {
return [self.client getCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYCheckout *checkout, NSError *error) { return [self.client getCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYCheckout *checkout, NSError *error) {
if (checkout) { if (checkout) {
......
...@@ -64,7 +64,6 @@ ...@@ -64,7 +64,6 @@
#import "BUYClient+Checkout.h" #import "BUYClient+Checkout.h"
#import "BUYClient+Storefront.h" #import "BUYClient+Storefront.h"
#import "BUYRequestOperation.h"
#import "BUYError.h" #import "BUYError.h"
#import "BUYError+BUYAdditions.h" #import "BUYError+BUYAdditions.h"
#import "BUYManagedObject.h" #import "BUYManagedObject.h"
...@@ -88,4 +87,3 @@ ...@@ -88,4 +87,3 @@
#import "NSRegularExpression+BUYAdditions.h" #import "NSRegularExpression+BUYAdditions.h"
#import "NSString+BUYAdditions.h" #import "NSString+BUYAdditions.h"
#import "NSURL+BUYAdditions.h" #import "NSURL+BUYAdditions.h"
#import "NSURLComponents+BUYAdditions.h"
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