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
7e2bbaf8
Commit
7e2bbaf8
authored
May 12, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor remove product reservation assert instead of return error.
parent
543283c8
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
12 deletions
+10
-12
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+10
-12
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
7e2bbaf8
...
@@ -59,6 +59,8 @@
...
@@ -59,6 +59,8 @@
#define kMinSuccessfulStatusCode 200
#define kMinSuccessfulStatusCode 200
#define kMaxSuccessfulStatusCode 299
#define kMaxSuccessfulStatusCode 299
#define BUYAssertCheckout(checkout) NSAssert([(checkout) hasToken], @"Checkout assertion failed. Checkout must have a valid token associated with it.")
NSString
*
const
BUYVersionString
=
@"1.3"
;
NSString
*
const
BUYVersionString
=
@"1.3"
;
NSString
*
const
kShopifyError
=
@"shopify"
;
NSString
*
const
kShopifyError
=
@"shopify"
;
...
@@ -420,7 +422,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -420,7 +422,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
updateCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
-
(
NSURLSessionDataTask
*
)
updateCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
{
{
NSAssert
([
checkout
hasToken
],
@"Failed to update checkout. Checkout must have a valid token associated with it."
);
BUYAssertCheckout
(
checkout
);
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
];
...
@@ -435,7 +437,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -435,7 +437,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
completeCheckout
:
(
BUYCheckout
*
)
checkout
paymentToken
:
(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:
(
BUYDataCheckoutBlock
)
block
-
(
NSURLSessionDataTask
*
)
completeCheckout
:
(
BUYCheckout
*
)
checkout
paymentToken
:
(
id
<
BUYPaymentToken
>
)
paymentToken
completion
:
(
BUYDataCheckoutBlock
)
block
{
{
NSAssert
([
checkout
hasToken
],
@"Failed to complete checkout. Checkout must have a valid token associated with it."
);
BUYAssertCheckout
(
checkout
);
NSData
*
data
=
nil
;
NSData
*
data
=
nil
;
if
(
paymentToken
)
{
if
(
paymentToken
)
{
...
@@ -461,7 +463,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -461,7 +463,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getCompletionStatusOfCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutStatusBlock
)
block
-
(
NSURLSessionDataTask
*
)
getCompletionStatusOfCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutStatusBlock
)
block
{
{
NSAssert
([
checkout
hasToken
],
@"Failed to get completion status of checkout. Checkout must have a valid token associated with it."
);
BUYAssertCheckout
(
checkout
);
return
[
self
getCompletionStatusOfCheckoutToken
:
checkout
.
token
completion
:
block
];
return
[
self
getCompletionStatusOfCheckoutToken
:
checkout
.
token
completion
:
block
];
}
}
...
@@ -498,7 +500,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -498,7 +500,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getShippingRatesForCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataShippingRatesBlock
)
block
-
(
NSURLSessionDataTask
*
)
getShippingRatesForCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataShippingRatesBlock
)
block
{
{
NSAssert
([
checkout
hasToken
],
@"Failed to get completion status of checkout. Checkout must have a valid token associated with it."
);
BUYAssertCheckout
(
checkout
);
NSURLComponents
*
components
=
[
self
URLComponentsForCheckoutsAppendingPath
:
@"shipping_rates"
checkoutToken
:
checkout
.
token
queryItems
:
@{
@"checkout"
:
@""
}];
NSURLComponents
*
components
=
[
self
URLComponentsForCheckoutsAppendingPath
:
@"shipping_rates"
checkoutToken
:
checkout
.
token
queryItems
:
@{
@"checkout"
:
@""
}];
return
[
self
getRequestForURL
:
components
.
URL
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
getRequestForURL
:
components
.
URL
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
shippingRates
=
nil
;
NSArray
*
shippingRates
=
nil
;
...
@@ -515,7 +517,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -515,7 +517,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
storeCreditCard
:
(
BUYCreditCard
*
)
creditCard
checkout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCreditCardBlock
)
completion
-
(
NSURLSessionDataTask
*
)
storeCreditCard
:
(
BUYCreditCard
*
)
creditCard
checkout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCreditCardBlock
)
completion
{
{
NSAssert
(
checkout
.
token
,
@"Failed to store credit card. No checkout token provided."
);
BUYAssertCheckout
(
checkout
);
NSAssert
(
creditCard
,
@"Failed to store credit card. No credit card provided."
);
NSAssert
(
creditCard
,
@"Failed to store credit card. No credit card provided."
);
NSMutableDictionary
*
json
=
[[
NSMutableDictionary
alloc
]
init
];
NSMutableDictionary
*
json
=
[[
NSMutableDictionary
alloc
]
init
];
...
@@ -534,14 +536,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
...
@@ -534,14 +536,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
removeProductReservationsFromCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
-
(
NSURLSessionDataTask
*
)
removeProductReservationsFromCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
{
{
NSURLSessionDataTask
*
task
=
nil
;
BUYAssertCheckout
(
checkout
)
;
if
([
checkout
hasToken
])
{
checkout
.
reservationTime
=
@0
;
checkout
.
reservationTime
=
@0
;
task
=
[
self
updateCheckout
:
checkout
completion
:
block
];
return
[
self
updateCheckout
:
checkout
completion
:
block
];
}
else
{
block
(
checkout
,
[
NSError
errorWithDomain
:
kShopifyError
code
:
BUYShopifyError_InvalidCheckoutObject
userInfo
:
nil
]);
}
return
task
;
}
}
#pragma mark - Helpers
#pragma mark - Helpers
...
...
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