Commit ee1b2354 by Dima Bart

Convert getCheckout to use token.

parent 3fe05c4f
...@@ -933,11 +933,7 @@ ...@@ -933,11 +933,7 @@
[OHHTTPStubs stubUsingResponseWithKey:@"testGetCheckoutWithInvalidToken_0" useMocks:[self shouldUseMocks]]; [OHHTTPStubs stubUsingResponseWithKey:@"testGetCheckoutWithInvalidToken_0" useMocks:[self shouldUseMocks]];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getCheckoutWithToken:@"zzzzzzzzzzz" completion:^(BUYCheckout *checkout, NSError *error) {
BUYCheckout *badCheckout = [[BUYCheckout alloc] initWithCartToken:@""];
badCheckout.token = @"zzzzzzzzzzz";
[self.client getCheckout:badCheckout completion:^(BUYCheckout *checkout, NSError *error) {
XCTAssertEqual(404, error.code); XCTAssertEqual(404, error.code);
[expectation fulfill]; [expectation fulfill];
......
...@@ -109,17 +109,17 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -109,17 +109,17 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
- (BUYRequestOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block;
/** /**
* Retrieves an updated version of a BUYCheckout from Shopify. * Retrieves an updated BUYCheckout.
* *
* Note: There's no guarantee that the BUYCheckout returned will be the same as the one that is passed in. * Note: There's no guarantee that the BUYCheckout returned will be the same as the one that is passed in.
* We recommended using the BUYCheckout returned in the block. * We recommended using the BUYCheckout returned in the block.
* *
* @param checkout The BUYCheckout to retrieve (updated) from Shopify * @param checkoutToken The checkout token for which to retrieve the updated checkout
* @param block (^BUYDataCheckoutBlock)(BUYCheckout *checkout, NSError *error); * @param block (^BUYDataCheckoutBlock)(BUYCheckout *checkout, NSError *error);
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block;
/** /**
* Finalizes the BUYCheckout and charges the payment provider (ex: Credit Card, Apple Pay, etc). * Finalizes the BUYCheckout and charges the payment provider (ex: Credit Card, Apple Pay, etc).
......
...@@ -77,16 +77,16 @@ ...@@ -77,16 +77,16 @@
}]; }];
} }
- (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block
{ {
return [self getCheckout:checkout start:YES completion:block]; return [self getCheckoutWithToken:checkoutToken start:YES completion:block];
} }
- (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout start:(BOOL)start completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertCheckout(checkout); BUYAssertToken(checkoutToken);
NSURL *url = [self urlForCheckoutsWithToken:checkout.token]; NSURL *url = [self urlForCheckoutsWithToken:checkoutToken];
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) {
[self handleCheckoutResponse:json error:error block:block]; [self handleCheckoutResponse:json error:error block:block];
}]; }];
......
...@@ -64,6 +64,6 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp ...@@ -64,6 +64,6 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp
- (BUYRequestOperation *)beginCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)beginCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block; - (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block;
- (BUYRequestOperation *)getCheckout:(BUYCheckout *)checkout start:(BOOL)start completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block;
@end @end
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
- (BUYRequestOperation *)createGetOperation - (BUYRequestOperation *)createGetOperation
{ {
return [self.client getCheckout:self.checkout start:NO completion:^(BUYCheckout *checkout, NSError *error) { return [self.client getCheckoutWithToken:self.checkout.token start:NO completion:^(BUYCheckout *checkout, NSError *error) {
if (checkout) { if (checkout) {
[self finishWithCheckout:checkout]; [self finishWithCheckout:checkout];
} else { } else {
......
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