Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
0594b7fb
Commit
0594b7fb
authored
Jun 02, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Rename method suffix "WithToken" -> "ForToken"."
This reverts commit
4efa5fad
.
parent
1d80e96d
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
65 additions
and
65 deletions
+65
-65
BUYClient+RoutingTests.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+RoutingTests.m
+5
-5
BUYClientTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
+1
-1
BUYIntegrationTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
+12
-12
BUYClient+Checkout.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.h
+5
-5
BUYClient+Checkout.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
+17
-17
BUYClient+Internal.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Internal.h
+3
-3
BUYClient+Routing.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
+5
-5
BUYClient+Routing.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
+11
-11
BUYCheckoutOperation.m
... Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
+3
-3
BUYApplePayAuthorizationDelegate.m
...K/Mobile Buy SDK/Utils/BUYApplePayAuthorizationDelegate.m
+3
-3
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+RoutingTests.m
View file @
0594b7fb
...
@@ -80,19 +80,19 @@
...
@@ -80,19 +80,19 @@
@"https://_DOMAIN_/api/checkouts.json"
@"https://_DOMAIN_/api/checkouts.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCheckouts
For
Token
:
token
].
absoluteString
,
[
self
.
client
urlForCheckouts
With
Token
:
token
].
absoluteString
,
@"https://_DOMAIN_/api/checkouts/_TOKEN_.json"
@"https://_DOMAIN_/api/checkouts/_TOKEN_.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCheckoutsProcessing
For
Token
:
token
].
absoluteString
,
[
self
.
client
urlForCheckoutsProcessing
With
Token
:
token
].
absoluteString
,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json"
@"https://_DOMAIN_/api/checkouts/_TOKEN_/processing.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCheckoutsCompletion
For
Token
:
token
].
absoluteString
,
[
self
.
client
urlForCheckoutsCompletion
With
Token
:
token
].
absoluteString
,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json"
@"https://_DOMAIN_/api/checkouts/_TOKEN_/complete.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
[
self
.
client
urlForCheckoutsShippingRates
For
Token
:
token
parameters
:
parameters
].
absoluteString
,
[
self
.
client
urlForCheckoutsShippingRates
With
Token
:
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
urlForCheckoutsUsingGiftCard
For
Token
:
token
].
absoluteString
,
[
self
.
client
urlForCheckoutsUsingGiftCard
With
Token
:
token
].
absoluteString
,
@"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json"
@"https://_DOMAIN_/api/checkouts/_TOKEN_/gift_cards.json"
);
);
XCTAssertEqualObjects
(
XCTAssertEqualObjects
(
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
0594b7fb
...
@@ -126,7 +126,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -126,7 +126,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
-
(
void
)
testCheckoutPaymentWithOnlyGiftCard
-
(
void
)
testCheckoutPaymentWithOnlyGiftCard
{
{
BUYOperation
*
task
=
[
self
.
client
completeCheckout
For
Token
:
@"abcdef"
paymentToken
:
nil
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{}];
BUYOperation
*
task
=
[
self
.
client
completeCheckout
With
Token
:
@"abcdef"
paymentToken
:
nil
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{}];
XCTAssertNotNil
(
task
);
XCTAssertNotNil
(
task
);
}
}
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYIntegrationTest.m
View file @
0594b7fb
...
@@ -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
For
Token
:
_checkout
.
token
completion
:
^
(
NSArray
*
shippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getShippingRatesForCheckout
With
Token
:
_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
)
completeCheckout
For
Token
:
(
id
<
BUYPaymentToken
>
)
paymentToken
-
(
void
)
completeCheckout
With
Token
:
(
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
urlForCheckoutsCompletion
For
Token
:
_checkout
.
token
].
lastPathComponent
])
{
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsCompletion
With
Token
:
_checkout
.
token
].
lastPathComponent
])
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_5"
];
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_5"
];
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsProcessing
For
Token
:
_checkout
.
token
].
lastPathComponent
])
{
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckoutsProcessing
With
Token
:
_checkout
.
token
].
lastPathComponent
])
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_14"
];
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testCheckoutFlowUsingCreditCard_14"
];
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckouts
For
Token
:
_checkout
.
token
].
lastPathComponent
])
{
}
else
if
([
path
isEqualToString
:[
self
.
client
urlForCheckouts
With
Token
:
_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
completeCheckout
For
Token
:
_checkout
.
token
paymentToken
:
paymentToken
completion
:^
(
BUYCheckout
*
returnedCheckout
,
NSError
*
error
)
{
[
self
.
client
completeCheckout
With
Token
:
_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
getShippingRatesForCheckout
For
Token
:
_checkout
.
token
completion
:
^
(
NSArray
*
returnedShippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getShippingRatesForCheckout
With
Token
:
_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
For
Token
:
checkout
.
token
completion
:
^
(
NSArray
*
returnedShippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getShippingRatesForCheckout
With
Token
:
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
completeCheckout
For
Token
:[
self
addCreditCardToCheckout
]];
[
self
completeCheckout
With
Token
:[
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
completeCheckout
For
Token
:
token
];
[
self
completeCheckout
With
Token
:
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
getCheckout
For
Token
:
@"zzzzzzzzzzz"
completion
:
^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
[
self
.
client
getCheckout
With
Token
:
@"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
removeProductReservationsFromCheckout
For
Token
:
_checkout
.
token
completion
:
^
(
BUYCheckout
*
returnedCheckout
,
NSError
*
error
)
{
[
self
.
client
removeProductReservationsFromCheckout
With
Token
:
_checkout
.
token
completion
:
^
(
BUYCheckout
*
returnedCheckout
,
NSError
*
error
)
{
XCTAssertNil
(
error
);
XCTAssertNil
(
error
);
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.h
View file @
0594b7fb
...
@@ -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
*
)
getCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCheckout
With
Token
:(
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
*
)
completeCheckout
For
Token
:(
nullable
NSString
*
)
checkoutToken
paymentToken
:(
_Nullable
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYOperation
*
)
completeCheckout
With
Token
:(
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
*
)
getCompletionStatusOfCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataStatusBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCompletionStatusOfCheckout
With
Token
:(
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
*
)
getShippingRatesForCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataShippingRatesBlock
)
block
;
-
(
BUYRequestOperation
*
)
getShippingRatesForCheckout
With
Token
:(
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
*
)
removeProductReservationsFromCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYRequestOperation
*
)
removeProductReservationsFromCheckout
With
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
;
@end
@end
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
View file @
0594b7fb
...
@@ -71,38 +71,38 @@
...
@@ -71,38 +71,38 @@
{
{
BUYAssertCheckout
(
checkout
);
BUYAssertCheckout
(
checkout
);
NSURL
*
route
=
[
self
urlForCheckouts
For
Token
:
checkout
.
token
];
NSURL
*
route
=
[
self
urlForCheckouts
With
Token
:
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
*
)
getCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
-
(
BUYRequestOperation
*
)
getCheckout
With
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
{
{
return
[
self
getCheckout
For
Token
:
checkoutToken
start
:
YES
completion
:
block
];
return
[
self
getCheckout
With
Token
:
checkoutToken
start
:
YES
completion
:
block
];
}
}
-
(
BUYRequestOperation
*
)
getCheckout
For
Token
:(
NSString
*
)
checkoutToken
start
:(
BOOL
)
start
completion
:(
BUYDataCheckoutBlock
)
block
-
(
BUYRequestOperation
*
)
getCheckout
With
Token
:(
NSString
*
)
checkoutToken
start
:(
BOOL
)
start
completion
:(
BUYDataCheckoutBlock
)
block
{
{
BUYAssertToken
(
checkoutToken
);
BUYAssertToken
(
checkoutToken
);
NSURL
*
url
=
[
self
urlForCheckouts
For
Token
:
checkoutToken
];
NSURL
*
url
=
[
self
urlForCheckouts
With
Token
:
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
*
)
completeCheckout
For
Token
:(
NSString
*
)
checkoutToken
paymentToken
:(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
-
(
BUYOperation
*
)
completeCheckout
With
Token
:(
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
*
)
getCompletionStatusOfCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataStatusBlock
)
block
-
(
BUYRequestOperation
*
)
getCompletionStatusOfCheckout
With
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataStatusBlock
)
block
{
{
BUYAssertToken
(
checkoutToken
);
BUYAssertToken
(
checkoutToken
);
return
[
self
getCompletionStatusOfCheckout
For
Token
:
checkoutToken
start
:
YES
completion
:
block
];
return
[
self
getCompletionStatusOfCheckout
With
Token
:
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
getCompletionStatusOfCheckout
For
Token
:
token
start
:
YES
completion
:
block
];
return
[
self
getCompletionStatusOfCheckout
With
Token
:
token
start
:
YES
completion
:
block
];
}
}
#pragma mark - Checkout Helpers -
#pragma mark - Checkout Helpers -
-
(
BUYRequestOperation
*
)
beginCheckout
For
Token
:(
NSString
*
)
checkoutToken
paymentToken
:(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
-
(
BUYRequestOperation
*
)
beginCheckout
With
Token
:(
NSString
*
)
checkoutToken
paymentToken
:(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
{
{
BUYAssertToken
(
checkoutToken
);
BUYAssertToken
(
checkoutToken
);
NSURL
*
route
=
[
self
urlForCheckoutsCompletion
For
Token
:
checkoutToken
];
NSURL
*
route
=
[
self
urlForCheckoutsCompletion
With
Token
:
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
*
)
getCompletionStatusOfCheckout
For
Token
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUYDataStatusBlock
)
block
-
(
BUYRequestOperation
*
)
getCompletionStatusOfCheckout
With
Token
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUYDataStatusBlock
)
block
{
{
NSURL
*
url
=
[
self
urlForCheckoutsProcessing
For
Token
:
token
];
NSURL
*
url
=
[
self
urlForCheckoutsProcessing
With
Token
:
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
);
}];
}];
...
@@ -170,11 +170,11 @@
...
@@ -170,11 +170,11 @@
#pragma mark - Shipping Rates -
#pragma mark - Shipping Rates -
-
(
BUYRequestOperation
*
)
getShippingRatesForCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataShippingRatesBlock
)
block
-
(
BUYRequestOperation
*
)
getShippingRatesForCheckout
With
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataShippingRatesBlock
)
block
{
{
BUYAssertToken
(
checkoutToken
);
BUYAssertToken
(
checkoutToken
);
NSURL
*
url
=
[
self
urlForCheckoutsShippingRates
For
Token
:
checkoutToken
parameters
:@{
NSURL
*
url
=
[
self
urlForCheckoutsShippingRates
With
Token
:
checkoutToken
parameters
:@{
@"checkout"
:
@""
,
@"checkout"
:
@""
,
}];
}];
...
@@ -224,7 +224,7 @@
...
@@ -224,7 +224,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
urlForCheckoutsUsingGiftCard
For
Token
:
checkout
.
token
];
NSURL
*
route
=
[
self
urlForCheckoutsUsingGiftCard
With
Token
:
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
)
{
...
@@ -272,7 +272,7 @@
...
@@ -272,7 +272,7 @@
#pragma mark - Reservations -
#pragma mark - Reservations -
-
(
BUYRequestOperation
*
)
removeProductReservationsFromCheckout
For
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
-
(
BUYRequestOperation
*
)
removeProductReservationsFromCheckout
With
Token
:(
NSString
*
)
checkoutToken
completion
:(
BUYDataCheckoutBlock
)
block
{
{
BUYAssertToken
(
checkoutToken
);
BUYAssertToken
(
checkoutToken
);
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Internal.h
View file @
0594b7fb
...
@@ -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
*
)
beginCheckout
For
Token
:(
NSString
*
)
checkoutToken
paymentToken
:(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYRequestOperation
*
)
beginCheckout
With
Token
:(
NSString
*
)
checkoutToken
paymentToken
:(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCompletionStatusOfCheckout
For
Token
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUYDataStatusBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCompletionStatusOfCheckout
With
Token
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUYDataStatusBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCheckout
For
Token
:(
NSString
*
)
checkoutToken
start
:(
BOOL
)
start
completion
:(
BUYDataCheckoutBlock
)
block
;
-
(
BUYRequestOperation
*
)
getCheckout
With
Token
:(
NSString
*
)
checkoutToken
start
:(
BOOL
)
start
completion
:(
BUYDataCheckoutBlock
)
block
;
@end
@end
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
View file @
0594b7fb
...
@@ -36,13 +36,13 @@
...
@@ -36,13 +36,13 @@
-
(
NSURL
*
)
urlForCollectionListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCollectionListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCheckouts
;
-
(
NSURL
*
)
urlForCheckouts
;
-
(
NSURL
*
)
urlForCheckouts
For
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckouts
With
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsProcessing
For
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsProcessing
With
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsCompletion
For
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsCompletion
With
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsShippingRates
For
Token
:(
NSString
*
)
token
parameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCheckoutsShippingRates
With
Token
:(
NSString
*
)
token
parameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
For
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
With
Token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
:(
NSNumber
*
)
giftCardID
token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
:(
NSNumber
*
)
giftCardID
token
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCustomers
;
-
(
NSURL
*
)
urlForCustomers
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
View file @
0594b7fb
...
@@ -131,24 +131,24 @@
...
@@ -131,24 +131,24 @@
return
[[[
self
urlForAPI
]
appendPath
:
@"/checkouts"
]
appendExtension
];
return
[[[
self
urlForAPI
]
appendPath
:
@"/checkouts"
]
appendExtension
];
}
}
-
(
NSURL
*
)
urlForCheckouts
For
Token
:
(
NSString
*
)
token
-
(
NSURL
*
)
urlForCheckouts
With
Token
:
(
NSString
*
)
token
{
{
return
[
self
_urlForCheckoutsAction
:
@""
for
Token
:
token
];
return
[
self
_urlForCheckoutsAction
:
@""
with
Token
:
token
];
}
}
-
(
NSURL
*
)
urlForCheckoutsProcessing
For
Token
:
(
NSString
*
)
token
-
(
NSURL
*
)
urlForCheckoutsProcessing
With
Token
:
(
NSString
*
)
token
{
{
return
[
self
_urlForCheckoutsAction
:
@"/processing"
for
Token
:
token
];
return
[
self
_urlForCheckoutsAction
:
@"/processing"
with
Token
:
token
];
}
}
-
(
NSURL
*
)
urlForCheckoutsCompletion
For
Token
:
(
NSString
*
)
token
-
(
NSURL
*
)
urlForCheckoutsCompletion
With
Token
:
(
NSString
*
)
token
{
{
return
[
self
_urlForCheckoutsAction
:
@"/complete"
for
Token
:
token
];
return
[
self
_urlForCheckoutsAction
:
@"/complete"
with
Token
:
token
];
}
}
-
(
NSURL
*
)
urlForCheckoutsShippingRates
For
Token
:
(
NSString
*
)
token
parameters
:
(
NSDictionary
*
)
parameters
-
(
NSURL
*
)
urlForCheckoutsShippingRates
With
Token
:
(
NSString
*
)
token
parameters
:
(
NSDictionary
*
)
parameters
{
{
return
[[
self
_urlForCheckoutsAction
:
@"/shipping_rates"
for
Token
:
token
]
appendParameters
:
parameters
];
return
[[
self
_urlForCheckoutsAction
:
@"/shipping_rates"
with
Token
:
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
*
)
urlForCheckoutsUsingGiftCard
For
Token
:
(
NSString
*
)
token
-
(
NSURL
*
)
urlForCheckoutsUsingGiftCard
With
Token
:
(
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
urlForCheckoutsUsingGiftCard
For
Token
:
token
]
appendIdentifier
:
giftCardID
]
appendExtension
];
return
[[[
self
urlForCheckoutsUsingGiftCard
With
Token
:
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
for
Token
:
(
NSString
*
)
token
-
(
NSURL
*
)
_urlForCheckoutsAction
:
(
NSString
*
)
action
with
Token
:
(
NSString
*
)
token
{
{
return
[[[[
self
urlForCheckouts
]
appendPath
:
token
]
appendPath
:
action
]
appendExtension
];
return
[[[[
self
urlForCheckouts
]
appendPath
:
token
]
appendPath
:
action
]
appendExtension
];
}
}
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
View file @
0594b7fb
...
@@ -137,7 +137,7 @@
...
@@ -137,7 +137,7 @@
-
(
BUYRequestOperation
*
)
createBeginOperation
-
(
BUYRequestOperation
*
)
createBeginOperation
{
{
return
[
self
.
client
beginCheckout
For
Token
:
self
.
checkoutToken
paymentToken
:
self
.
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
return
[
self
.
client
beginCheckout
With
Token
:
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
getCompletionStatusOfCheckout
For
Token
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUYStatus
status
,
NSError
*
error
)
{
BUYRequestOperation
*
operation
=
[
self
.
client
getCompletionStatusOfCheckout
With
Token
:
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
getCheckout
For
Token
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
return
[
self
.
client
getCheckout
With
Token
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
if
(
checkout
)
{
if
(
checkout
)
{
[
self
finishWithCheckout
:
checkout
];
[
self
finishWithCheckout
:
checkout
];
}
else
{
}
else
{
...
...
Mobile Buy SDK/Mobile Buy SDK/Utils/BUYApplePayAuthorizationDelegate.m
View file @
0594b7fb
...
@@ -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
completeCheckout
For
Token
:
checkout
.
token
paymentToken
:
token
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
[
self
.
client
completeCheckout
With
Token
:
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
getShippingRatesForCheckout
For
Token
:
self
.
checkout
.
token
completion
:
^
(
NSArray
*
shippingRates
,
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getShippingRatesForCheckout
With
Token
:
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
getCompletionStatusOfCheckout
For
Token
:
self
.
checkout
.
token
completion
:
^
(
BUYStatus
status
,
NSError
*
error
)
{
[
self
.
client
getCompletionStatusOfCheckout
With
Token
:
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment