Commit 28bce436 by Dima Bart

Convert getShippingRates to use token.

parent 9fd7679a
...@@ -154,7 +154,7 @@ ...@@ -154,7 +154,7 @@
[OHHTTPStubs stubUsingResponseWithKey:@"testCheckoutFlowUsingCreditCard_2" useMocks:[self shouldUseMocks]]; [OHHTTPStubs stubUsingResponseWithKey:@"testCheckoutFlowUsingCreditCard_2" useMocks:[self shouldUseMocks]];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getShippingRatesForCheckout:_checkout completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutWithToken:_checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) {
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertEqual(status, BUYStatusComplete); XCTAssertEqual(status, BUYStatusComplete);
...@@ -752,7 +752,7 @@ ...@@ -752,7 +752,7 @@
XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getShippingRatesForCheckout:_checkout completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutWithToken:_checkout.token completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) {
XCTAssertEqual(BUYStatusPreconditionFailed, status); XCTAssertEqual(BUYStatusPreconditionFailed, status);
[expectation2 fulfill]; [expectation2 fulfill];
}]; }];
...@@ -770,7 +770,7 @@ ...@@ -770,7 +770,7 @@
checkout.token = @"bananaaaa"; checkout.token = @"bananaaaa";
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getShippingRatesForCheckout:checkout completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutWithToken:checkout.token completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) {
XCTAssertEqual(BUYStatusNotFound, status); XCTAssertEqual(BUYStatusNotFound, status);
[expectation fulfill]; [expectation fulfill];
}]; }];
......
...@@ -161,15 +161,15 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -161,15 +161,15 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
/** /**
* Retrieves a list of applicable shipping rates for a given BUYCheckout. * Retrieves a list of applicable shipping rates for a given checkout token.
* Add the preferred/selected BUYShippingRate to BUYCheckout, then update BUYCheckout * Add the preferred/selected BUYShippingRate to BUYCheckout, then update BUYCheckout
* *
* @param checkout The BUYCheckout to retrieve shipping rates for * @param checkoutToken The checkout token for which to retrieve shipping rates
* @param block (^BUYDataShippingRatesBlock)(NSArray *shippingRates, BUYStatus status, NSError *error); * @param block (^BUYDataShippingRatesBlock)(NSArray *shippingRates, BUYStatus status, NSError *error);
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getShippingRatesForCheckout:(BUYCheckout *)checkout completion:(BUYDataShippingRatesBlock)block; - (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block;
#pragma mark - Cards - #pragma mark - Cards -
......
...@@ -191,11 +191,11 @@ ...@@ -191,11 +191,11 @@
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
- (BUYRequestOperation *)getShippingRatesForCheckout:(BUYCheckout *)checkout completion:(BUYDataShippingRatesBlock)block - (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertToken(checkoutToken);
NSURL *url = [self urlForCheckoutsShippingRatesWithToken:checkout.token parameters:@{ NSURL *url = [self urlForCheckoutsShippingRatesWithToken:checkoutToken parameters:@{
@"checkout" : @"", @"checkout" : @"",
}]; }];
......
...@@ -242,7 +242,7 @@ const NSTimeInterval PollDelay = 0.5; ...@@ -242,7 +242,7 @@ const NSTimeInterval PollDelay = 0.5;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
__block BUYStatus shippingStatus = BUYStatusUnknown; __block BUYStatus shippingStatus = BUYStatusUnknown;
do { do {
[self.client getShippingRatesForCheckout:self.checkout completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutWithToken:self.checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) {
shippingStatus = status; shippingStatus = status;
if (error) { if (error) {
......
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