Commit 6961594a by Dima Bart

Refactor updateCheckout to assert instead of return error.

parent 246200b8
...@@ -426,19 +426,18 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token ...@@ -426,19 +426,18 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (NSURLSessionDataTask *)updateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
NSAssert(checkout, @"Failed to update checkout. Checkout must not be nil");
NSAssert([checkout hasToken], @"Failed to update checkout. Checkout must have a valid token associated with it/");
NSDictionary *json = [checkout jsonDictionaryForCheckout]; NSDictionary *json = [checkout jsonDictionaryForCheckout];
NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil]; NSData *data = [NSJSONSerialization dataWithJSONObject:json options:0 error:nil];
NSURLSessionDataTask *task = nil; NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:nil
if ([checkout hasToken]) { checkoutToken:checkout.token
NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:nil queryItems:nil];
checkoutToken:checkout.token return [self patchRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
queryItems:nil]; [self handleCheckoutResponse:json error:error block:block];
task = [self patchRequestForURL:components.URL body:data completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) { }];
[self handleCheckoutResponse:json error:error block:block];
}];
}
return task;
} }
- (NSURLSessionDataTask*)completeCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block - (NSURLSessionDataTask*)completeCheckout:(BUYCheckout *)checkout paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block
......
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