Commit 4efa5fad by Dima Bart

Rename method suffix "WithToken" -> "ForToken".

parent 974a0367
...@@ -80,19 +80,19 @@ ...@@ -80,19 +80,19 @@
@"https://_DOMAIN_/api/checkouts.json" @"https://_DOMAIN_/api/checkouts.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
[self.client urlForCheckoutsWithToken:token].absoluteString, [self.client urlForCheckoutsForToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_.json" @"https://_DOMAIN_/api/checkouts/_TOKEN_.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
[self.client urlForCheckoutsProcessingWithToken:token].absoluteString, [self.client urlForCheckoutsProcessingForToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json" @"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
[self.client urlForCheckoutsCompletionWithToken:token].absoluteString, [self.client urlForCheckoutsCompletionForToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json" @"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
[self.client urlForCheckoutsShippingRatesWithToken:token parameters:parameters].absoluteString, [self.client urlForCheckoutsShippingRatesForToken:token parameters:parameters].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/shipping_rates.json?param=value" @"https://_DOMAIN_/api/checkouts/_TOKEN_/shipping_rates.json?param=value"
); );
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
@"https://_DOMAIN_/api/checkouts/gift_cards.json" @"https://_DOMAIN_/api/checkouts/gift_cards.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
[self.client urlForCheckoutsUsingGiftCardWithToken:token].absoluteString, [self.client urlForCheckoutsUsingGiftCardForToken:token].absoluteString,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json" @"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json"
); );
XCTAssertEqualObjects( XCTAssertEqualObjects(
......
...@@ -126,7 +126,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -126,7 +126,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
- (void)testCheckoutPaymentWithOnlyGiftCard - (void)testCheckoutPaymentWithOnlyGiftCard
{ {
BUYOperation *task = [self.client completeCheckoutWithToken:@"abcdef" paymentToken:nil completion:^(BUYCheckout *checkout, NSError *error) {}]; BUYOperation *task = [self.client completeCheckoutForToken:@"abcdef" paymentToken:nil completion:^(BUYCheckout *checkout, NSError *error) {}];
XCTAssertNotNil(task); XCTAssertNotNil(task);
} }
......
...@@ -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 getShippingRatesForCheckoutWithToken:_checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutForToken:_checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) {
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertEqual(status, BUYStatusComplete); XCTAssertEqual(status, BUYStatusComplete);
...@@ -222,26 +222,26 @@ ...@@ -222,26 +222,26 @@
return creditCard; return creditCard;
} }
- (void)completeCheckoutWithToken:(id<BUYPaymentToken>)paymentToken - (void)completeCheckoutForToken:(id<BUYPaymentToken>)paymentToken
{ {
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) { [OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
return [self shouldUseMocks]; return [self shouldUseMocks];
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) { } withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) {
NSString *path = request.URL.absoluteString.lastPathComponent; NSString *path = request.URL.absoluteString.lastPathComponent;
if ([path isEqualToString:[self.client urlForCheckoutsCompletionWithToken:_checkout.token].lastPathComponent]) { if ([path isEqualToString:[self.client urlForCheckoutsCompletionForToken:_checkout.token].lastPathComponent]) {
return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_5"]; return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_5"];
} else if ([path isEqualToString:[self.client urlForCheckoutsProcessingWithToken:_checkout.token].lastPathComponent]) { } else if ([path isEqualToString:[self.client urlForCheckoutsProcessingForToken:_checkout.token].lastPathComponent]) {
return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_14"]; return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_14"];
} else if ([path isEqualToString:[self.client urlForCheckoutsWithToken:_checkout.token].lastPathComponent]) { } else if ([path isEqualToString:[self.client urlForCheckoutsForToken:_checkout.token].lastPathComponent]) {
return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_15"]; return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_15"];
} }
return [OHHTTPStubsResponse responseWithData:[NSData new] statusCode:500 headers:nil];; return [OHHTTPStubsResponse responseWithData:[NSData new] statusCode:500 headers:nil];;
}]; }];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client completeCheckoutWithToken:_checkout.token paymentToken:paymentToken completion:^(BUYCheckout *returnedCheckout, NSError *error) { [self.client completeCheckoutForToken:_checkout.token paymentToken:paymentToken completion:^(BUYCheckout *returnedCheckout, NSError *error) {
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertNotNil(returnedCheckout); XCTAssertNotNil(returnedCheckout);
XCTAssertNotNil(returnedCheckout.order); XCTAssertNotNil(returnedCheckout.order);
...@@ -752,7 +752,7 @@ ...@@ -752,7 +752,7 @@
XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getShippingRatesForCheckoutWithToken:_checkout.token completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutForToken:_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 getShippingRatesForCheckoutWithToken:checkout.token completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutForToken:checkout.token completion:^(NSArray *returnedShippingRates, BUYStatus status, NSError *error) {
XCTAssertEqual(BUYStatusNotFound, status); XCTAssertEqual(BUYStatusNotFound, status);
[expectation fulfill]; [expectation fulfill];
}]; }];
...@@ -786,7 +786,7 @@ ...@@ -786,7 +786,7 @@
[self fetchShippingRates]; [self fetchShippingRates];
[self updateCheckout]; [self updateCheckout];
[self completeCheckoutWithToken:[self addCreditCardToCheckout]]; [self completeCheckoutForToken:[self addCreditCardToCheckout]];
} }
- (void)testCheckoutWithAPartialAddress - (void)testCheckoutWithAPartialAddress
...@@ -827,7 +827,7 @@ ...@@ -827,7 +827,7 @@
//We use a credit card here because we're not generating apple pay tokens in the tests //We use a credit card here because we're not generating apple pay tokens in the tests
id<BUYPaymentToken> token = [self addCreditCardToCheckout]; id<BUYPaymentToken> token = [self addCreditCardToCheckout];
[self completeCheckoutWithToken:token]; [self completeCheckoutForToken:token];
} }
- (void)testCheckoutCreationWithApplicableDiscount - (void)testCheckoutCreationWithApplicableDiscount
...@@ -933,7 +933,7 @@ ...@@ -933,7 +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) { [self.client getCheckoutForToken:@"zzzzzzzzzzz" completion:^(BUYCheckout *checkout, NSError *error) {
XCTAssertEqual(404, error.code); XCTAssertEqual(404, error.code);
[expectation fulfill]; [expectation fulfill];
...@@ -1021,7 +1021,7 @@ ...@@ -1021,7 +1021,7 @@
// Expire the checkout // Expire the checkout
XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation2 = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client removeProductReservationsFromCheckoutWithToken:_checkout.token completion:^(BUYCheckout *returnedCheckout, NSError *error) { [self.client removeProductReservationsFromCheckoutForToken:_checkout.token completion:^(BUYCheckout *returnedCheckout, NSError *error) {
XCTAssertNil(error); XCTAssertNil(error);
......
...@@ -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 *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)getCheckoutForToken:(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).
...@@ -132,7 +132,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -132,7 +132,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYOperation * @return The associated BUYOperation
*/ */
- (BUYOperation *)completeCheckoutWithToken:(nullable NSString *)checkoutToken paymentToken:(_Nullable id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block; - (BUYOperation *)completeCheckoutForToken:(nullable NSString *)checkoutToken paymentToken:(_Nullable id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
/** /**
* Retrieve the status of a checkout with token. This checks the status of the current payment processing job for the provided checkout. * Retrieve the status of a checkout with token. This checks the status of the current payment processing job for the provided checkout.
...@@ -143,7 +143,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -143,7 +143,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block; - (BUYRequestOperation *)getCompletionStatusOfCheckoutForToken:(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`
...@@ -166,7 +166,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -166,7 +166,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block; - (BUYRequestOperation *)getShippingRatesForCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block;
#pragma mark - Cards - #pragma mark - Cards -
...@@ -222,7 +222,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -222,7 +222,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
* *
* @return The associated BUYRequestOperation * @return The associated BUYRequestOperation
*/ */
- (BUYRequestOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)removeProductReservationsFromCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block;
@end @end
......
...@@ -71,38 +71,38 @@ ...@@ -71,38 +71,38 @@
{ {
BUYAssertCheckout(checkout); BUYAssertCheckout(checkout);
NSURL *route = [self urlForCheckoutsWithToken:checkout.token]; NSURL *route = [self urlForCheckoutsForToken:checkout.token];
return [self patchRequestForURL:route object:checkout completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self patchRequestForURL:route object:checkout completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
[self handleCheckoutResponse:json error:error block:block]; [self handleCheckoutResponse:json error:error block:block];
}]; }];
} }
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)getCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block
{ {
return [self getCheckoutWithToken:checkoutToken start:YES completion:block]; return [self getCheckoutForToken:checkoutToken start:YES completion:block];
} }
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)getCheckoutForToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
NSURL *url = [self urlForCheckoutsWithToken:checkoutToken]; NSURL *url = [self urlForCheckoutsForToken: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];
}]; }];
} }
- (BUYOperation *)completeCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block - (BUYOperation *)completeCheckoutForToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block
{ {
BUYCheckoutOperation *operation = [[BUYCheckoutOperation alloc] initWithClient:self checkoutToken:checkoutToken token:paymentToken completion:block]; BUYCheckoutOperation *operation = [[BUYCheckoutOperation alloc] initWithClient:self checkoutToken:checkoutToken token:paymentToken completion:block];
[self startOperation:operation]; [self startOperation:operation];
return operation; return operation;
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataStatusBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
return [self getCompletionStatusOfCheckoutWithToken:checkoutToken start:YES completion:block]; return [self getCompletionStatusOfCheckoutForToken:checkoutToken start:YES completion:block];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutURL:(NSURL *)url completion:(BUYDataStatusBlock)block
...@@ -119,24 +119,24 @@ ...@@ -119,24 +119,24 @@
BUYAssert(token, @"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it."); BUYAssert(token, @"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it.");
return [self getCompletionStatusOfCheckoutWithToken:token start:YES completion:block]; return [self getCompletionStatusOfCheckoutForToken:token start:YES completion:block];
} }
#pragma mark - Checkout Helpers - #pragma mark - Checkout Helpers -
- (BUYRequestOperation *)beginCheckoutWithToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)beginCheckoutForToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
NSURL *route = [self urlForCheckoutsCompletionWithToken:checkoutToken]; NSURL *route = [self urlForCheckoutsCompletionForToken:checkoutToken];
return [self postRequestForURL:route object:[paymentToken JSONDictionary] start:NO completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:route object:[paymentToken JSONDictionary] start:NO completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
[self handleCheckoutResponse:json error:error block:block]; [self handleCheckoutResponse:json error:error block:block];
}]; }];
} }
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block - (BUYRequestOperation *)getCompletionStatusOfCheckoutForToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block
{ {
NSURL *url = [self urlForCheckoutsProcessingWithToken:token]; NSURL *url = [self urlForCheckoutsProcessingForToken: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) {
block([self statusForStatusCode:response.statusCode error:error], error); block([self statusForStatusCode:response.statusCode error:error], error);
}]; }];
...@@ -187,11 +187,11 @@ ...@@ -187,11 +187,11 @@
#pragma mark - Shipping Rates - #pragma mark - Shipping Rates -
- (BUYRequestOperation *)getShippingRatesForCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block - (BUYRequestOperation *)getShippingRatesForCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataShippingRatesBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
NSURL *url = [self urlForCheckoutsShippingRatesWithToken:checkoutToken parameters:@{ NSURL *url = [self urlForCheckoutsShippingRatesForToken:checkoutToken parameters:@{
@"checkout" : @"", @"checkout" : @"",
}]; }];
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
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.");
BUYGiftCard *giftCard = [self.modelManager giftCardWithCode:giftCardCode]; BUYGiftCard *giftCard = [self.modelManager giftCardWithCode:giftCardCode];
NSURL *route = [self urlForCheckoutsUsingGiftCardWithToken:checkout.token]; NSURL *route = [self urlForCheckoutsUsingGiftCardForToken:checkout.token];
return [self postRequestForURL:route object:giftCard completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) { return [self postRequestForURL:route object:giftCard completionHandler:^(NSDictionary *json, NSHTTPURLResponse *response, NSError *error) {
if (json && !error) { if (json && !error) {
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
#pragma mark - Reservations - #pragma mark - Reservations -
- (BUYRequestOperation *)removeProductReservationsFromCheckoutWithToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)removeProductReservationsFromCheckoutForToken:(NSString *)checkoutToken completion:(BUYDataCheckoutBlock)block
{ {
BUYAssertToken(checkoutToken); BUYAssertToken(checkoutToken);
......
...@@ -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; - (BUYRequestOperation *)beginCheckoutForToken:(NSString *)checkoutToken paymentToken:(id<BUYPaymentToken>)paymentToken completion:(BUYDataCheckoutBlock)block;
- (BUYRequestOperation *)getCompletionStatusOfCheckoutWithToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block; - (BUYRequestOperation *)getCompletionStatusOfCheckoutForToken:(NSString *)token start:(BOOL)start completion:(BUYDataStatusBlock)block;
- (BUYRequestOperation *)getCheckoutWithToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block; - (BUYRequestOperation *)getCheckoutForToken:(NSString *)checkoutToken start:(BOOL)start completion:(BUYDataCheckoutBlock)block;
@end @end
...@@ -36,13 +36,13 @@ ...@@ -36,13 +36,13 @@
- (NSURL *)urlForCollectionListingsWithParameters:(NSDictionary *)parameters; - (NSURL *)urlForCollectionListingsWithParameters:(NSDictionary *)parameters;
- (NSURL *)urlForCheckouts; - (NSURL *)urlForCheckouts;
- (NSURL *)urlForCheckoutsWithToken:(NSString *)token; - (NSURL *)urlForCheckoutsForToken:(NSString *)token;
- (NSURL *)urlForCheckoutsProcessingWithToken:(NSString *)token; - (NSURL *)urlForCheckoutsProcessingForToken:(NSString *)token;
- (NSURL *)urlForCheckoutsCompletionWithToken:(NSString *)token; - (NSURL *)urlForCheckoutsCompletionForToken:(NSString *)token;
- (NSURL *)urlForCheckoutsShippingRatesWithToken:(NSString *)token parameters:(NSDictionary *)parameters; - (NSURL *)urlForCheckoutsShippingRatesForToken:(NSString *)token parameters:(NSDictionary *)parameters;
- (NSURL *)urlForCheckoutsUsingGiftCard; - (NSURL *)urlForCheckoutsUsingGiftCard;
- (NSURL *)urlForCheckoutsUsingGiftCardWithToken:(NSString *)token; - (NSURL *)urlForCheckoutsUsingGiftCardForToken:(NSString *)token;
- (NSURL *)urlForCheckoutsUsingGiftCard:(NSNumber *)giftCardID token:(NSString *)token; - (NSURL *)urlForCheckoutsUsingGiftCard:(NSNumber *)giftCardID token:(NSString *)token;
- (NSURL *)urlForCustomers; - (NSURL *)urlForCustomers;
......
...@@ -131,24 +131,24 @@ ...@@ -131,24 +131,24 @@
return [[[self urlForAPI] appendPath:@"/checkouts"] appendExtension]; return [[[self urlForAPI] appendPath:@"/checkouts"] appendExtension];
} }
- (NSURL *)urlForCheckoutsWithToken:(NSString *)token - (NSURL *)urlForCheckoutsForToken:(NSString *)token
{ {
return [self _urlForCheckoutsAction:@"" withToken:token]; return [self _urlForCheckoutsAction:@"" forToken:token];
} }
- (NSURL *)urlForCheckoutsProcessingWithToken:(NSString *)token - (NSURL *)urlForCheckoutsProcessingForToken:(NSString *)token
{ {
return [self _urlForCheckoutsAction:@"/processing" withToken:token]; return [self _urlForCheckoutsAction:@"/processing" forToken:token];
} }
- (NSURL *)urlForCheckoutsCompletionWithToken:(NSString *)token - (NSURL *)urlForCheckoutsCompletionForToken:(NSString *)token
{ {
return [self _urlForCheckoutsAction:@"/complete" withToken:token]; return [self _urlForCheckoutsAction:@"/complete" forToken:token];
} }
- (NSURL *)urlForCheckoutsShippingRatesWithToken:(NSString *)token parameters:(NSDictionary *)parameters - (NSURL *)urlForCheckoutsShippingRatesForToken:(NSString *)token parameters:(NSDictionary *)parameters
{ {
return [[self _urlForCheckoutsAction:@"/shipping_rates" withToken:token] appendParameters:parameters]; return [[self _urlForCheckoutsAction:@"/shipping_rates" forToken:token] appendParameters:parameters];
} }
- (NSURL *)urlForCheckoutsUsingGiftCard - (NSURL *)urlForCheckoutsUsingGiftCard
...@@ -156,14 +156,14 @@ ...@@ -156,14 +156,14 @@
return [[[self urlForCheckouts] appendPath:@"/gift_cards"] appendExtension]; return [[[self urlForCheckouts] appendPath:@"/gift_cards"] appendExtension];
} }
- (NSURL *)urlForCheckoutsUsingGiftCardWithToken:(NSString *)token - (NSURL *)urlForCheckoutsUsingGiftCardForToken:(NSString *)token
{ {
return [[[[self urlForCheckouts] appendPath:token] appendPath:@"/gift_cards"] appendExtension]; return [[[[self urlForCheckouts] appendPath:token] appendPath:@"/gift_cards"] appendExtension];
} }
- (NSURL *)urlForCheckoutsUsingGiftCard:(NSNumber *)giftCardID token:(NSString *)token - (NSURL *)urlForCheckoutsUsingGiftCard:(NSNumber *)giftCardID token:(NSString *)token
{ {
return [[[self urlForCheckoutsUsingGiftCardWithToken:token] appendIdentifier:giftCardID] appendExtension]; return [[[self urlForCheckoutsUsingGiftCardForToken:token] appendIdentifier:giftCardID] appendExtension];
} }
#pragma mark - Customers - #pragma mark - Customers -
...@@ -229,7 +229,7 @@ ...@@ -229,7 +229,7 @@
#pragma mark - Utilities - #pragma mark - Utilities -
- (NSURL *)_urlForCheckoutsAction:(NSString *)action withToken:(NSString *)token - (NSURL *)_urlForCheckoutsAction:(NSString *)action forToken:(NSString *)token
{ {
return [[[[self urlForCheckouts] appendPath:token] appendPath:action] appendExtension]; return [[[[self urlForCheckouts] appendPath:token] appendPath:action] appendExtension];
} }
......
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
- (BUYRequestOperation *)createBeginOperation - (BUYRequestOperation *)createBeginOperation
{ {
return [self.client beginCheckoutWithToken:self.checkoutToken paymentToken:self.token completion:^(BUYCheckout *checkout, NSError *error) { return [self.client beginCheckoutForToken:self.checkoutToken paymentToken:self.token completion:^(BUYCheckout *checkout, NSError *error) {
if (!checkout) { if (!checkout) {
[self finishWithError:error]; [self finishWithError:error];
} }
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
- (BUYRequestOperation *)createPollOperation - (BUYRequestOperation *)createPollOperation
{ {
BUYRequestOperation *operation =[self.client getCompletionStatusOfCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYStatus status, NSError *error) { BUYRequestOperation *operation =[self.client getCompletionStatusOfCheckoutForToken:self.checkoutToken start:NO completion:^(BUYStatus status, NSError *error) {
if (status != BUYStatusComplete) { if (status != BUYStatusComplete) {
[self finishWithError:error]; [self finishWithError:error];
} }
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
- (BUYRequestOperation *)createGetOperation - (BUYRequestOperation *)createGetOperation
{ {
return [self.client getCheckoutWithToken:self.checkoutToken start:NO completion:^(BUYCheckout *checkout, NSError *error) { return [self.client getCheckoutForToken:self.checkoutToken start:NO completion:^(BUYCheckout *checkout, NSError *error) {
if (checkout) { if (checkout) {
[self finishWithCheckout:checkout]; [self finishWithCheckout:checkout];
} else { } else {
......
...@@ -99,7 +99,7 @@ const NSTimeInterval PollDelay = 0.5; ...@@ -99,7 +99,7 @@ const NSTimeInterval PollDelay = 0.5;
id<BUYPaymentToken> token = [[BUYApplePayToken alloc] initWithPaymentToken:payment.token]; id<BUYPaymentToken> token = [[BUYApplePayToken alloc] initWithPaymentToken:payment.token];
//Now that the checkout is up to date, call complete. //Now that the checkout is up to date, call complete.
[self.client completeCheckoutWithToken:checkout.token paymentToken:token completion:^(BUYCheckout *checkout, NSError *error) { [self.client completeCheckoutForToken:checkout.token paymentToken:token completion:^(BUYCheckout *checkout, NSError *error) {
if (checkout && error == nil) { if (checkout && error == nil) {
self.checkout = checkout; self.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 getShippingRatesForCheckoutWithToken:self.checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) { [self.client getShippingRatesForCheckoutForToken:self.checkout.token completion:^(NSArray *shippingRates, BUYStatus status, NSError *error) {
shippingStatus = status; shippingStatus = status;
if (error) { if (error) {
...@@ -295,7 +295,7 @@ const NSTimeInterval PollDelay = 0.5; ...@@ -295,7 +295,7 @@ const NSTimeInterval PollDelay = 0.5;
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
while (checkout.token && checkoutStatus != BUYStatusFailed && checkoutStatus != BUYStatusComplete) { while (checkout.token && checkoutStatus != BUYStatusFailed && checkoutStatus != BUYStatusComplete) {
[self.client getCompletionStatusOfCheckoutWithToken:self.checkout.token completion:^(BUYStatus status, NSError *error) { [self.client getCompletionStatusOfCheckoutForToken:self.checkout.token completion:^(BUYStatus status, NSError *error) {
checkoutStatus = status; checkoutStatus = status;
self.lastError = error; self.lastError = error;
dispatch_semaphore_signal(semaphore); dispatch_semaphore_signal(semaphore);
......
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