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
442257f6
Commit
442257f6
authored
May 12, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move JSON serialization into the higher-level network call for PUT.
parent
3a2e7135
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
12 deletions
+10
-12
BUYClient+Customers.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
+3
-5
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+6
-6
BUYClient_Internal.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient_Internal.h
+1
-1
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
View file @
442257f6
...
...
@@ -132,7 +132,7 @@
if
(
self
.
customerToken
)
{
NSURLComponents
*
components
=
[
self
URLComponentsForTokenRenewalWithID
:
customerID
];
return
[
self
putRequestForURL
:
components
.
URL
body
:
nil
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
putRequestForURL
:
components
.
URL
object
:
nil
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSString
*
accessToken
=
nil
;
if
(
json
&&
!
error
)
{
...
...
@@ -156,9 +156,8 @@
-
(
NSURLSessionDataTask
*
)
activateCustomerWithCredentials
:(
BUYAccountCredentials
*
)
credentials
customerID
:(
NSString
*
)
customerID
customerToken
:(
NSString
*
)
customerToken
callback
:(
BUYDataCustomerTokenBlock
)
block
{
NSURLComponents
*
components
=
[
self
URLComponentsForCustomerActivationWithID
:
customerID
customerToken
:
customerToken
];
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:
credentials
.
JSONRepresentation
options
:
0
error
:
nil
];
return
[
self
putRequestForURL
:
components
.
URL
body
:
data
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
putRequestForURL
:
components
.
URL
object
:
credentials
.
JSONRepresentation
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSString
*
email
=
json
[
@"customer"
][
@"email"
];
if
(
email
&&
!
error
)
{
BUYAccountCredentialItem
*
emailItem
=
[
BUYAccountCredentialItem
itemWithEmail
:
email
];
...
...
@@ -173,9 +172,8 @@
-
(
NSURLSessionDataTask
*
)
resetPasswordWithCredentials
:(
BUYAccountCredentials
*
)
credentials
customerID
:(
NSString
*
)
customerID
customerToken
:(
NSString
*
)
customerToken
callback
:(
BUYDataCustomerTokenBlock
)
block
{
NSURLComponents
*
components
=
[
self
URLComponentsForCustomerPasswordResetWithCustomerID
:
customerID
customerToken
:
customerToken
];
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:
credentials
.
JSONRepresentation
options
:
0
error
:
nil
];
return
[
self
putRequestForURL
:
components
.
URL
body
:
data
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
putRequestForURL
:
components
.
URL
object
:
credentials
.
JSONRepresentation
completionHandler
:^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSString
*
email
=
json
[
@"customer"
][
@"email"
];
if
(
email
&&
!
error
)
{
BUYAccountCredentialItem
*
emailItem
=
[
BUYAccountCredentialItem
itemWithEmail
:
email
];
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
442257f6
...
...
@@ -583,10 +583,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
requestForURL
:
(
NSURL
*
)
url
method
:
(
NSString
*
)
method
object
:
(
id
<
BUYSerializable
>
)
object
completionHandler
:
(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
{
BUYAssert
(
object
,
@"Failed to perform request. id<BUYSerializable> must not be nil."
)
;
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
object
jsonDictionaryForCheckout
]
options
:
0
error
:
nil
];
BUYAssert
(
data
,
@"Failed to perform request. Could not serialize object. Possibly invalid object."
);
NSData
*
data
=
nil
;
if
(
object
)
{
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
object
jsonDictionaryForCheckout
]
options
:
0
error
:
nil
];
}
return
[
self
requestForURL
:
url
method
:
method
body
:
data
completionHandler
:
completionHandler
];
}
...
...
@@ -645,9 +645,9 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
return
[
self
requestForURL
:
url
method
:
kPOST
object
:
object
completionHandler
:
completionHandler
];
}
-
(
NSURLSessionDataTask
*
)
putRequestForURL
:
(
NSURL
*
)
url
body
:
(
NSData
*
)
body
completionHandler
:
(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
-
(
NSURLSessionDataTask
*
)
putRequestForURL
:
(
NSURL
*
)
url
object
:
(
id
<
BUYSerializable
>
)
object
completionHandler
:
(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
{
return
[
self
requestForURL
:
url
method
:
kPUT
body
:
body
completionHandler
:
completionHandler
];
return
[
self
requestForURL
:
url
method
:
kPUT
object
:
object
completionHandler
:
completionHandler
];
}
-
(
NSURLSessionDataTask
*
)
postRequestForURL
:
(
NSURL
*
)
url
body
:
(
NSData
*
)
body
completionHandler
:
(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient_Internal.h
View file @
442257f6
...
...
@@ -32,7 +32,7 @@ extern NSString *const kShopifyError;
@interface
BUYClient
(
Internal
)
-
(
NSURLSessionDataTask
*
)
postRequestForURL
:(
NSURL
*
)
url
object
:(
id
<
BUYSerializable
>
)
object
completionHandler
:(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
;
-
(
NSURLSessionDataTask
*
)
putRequestForURL
:(
NSURL
*
)
url
body
:(
NSData
*
)
body
completionHandler
:(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
;
-
(
NSURLSessionDataTask
*
)
putRequestForURL
:(
NSURL
*
)
url
object
:(
id
<
BUYSerializable
>
)
object
completionHandler
:(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
;
-
(
NSURLSessionDataTask
*
)
getRequestForURL
:(
NSURL
*
)
url
completionHandler
:(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
;
-
(
NSURLSessionDataTask
*
)
requestForURL
:(
NSURL
*
)
url
method
:(
NSString
*
)
method
body
:(
NSData
*
)
body
additionalHeaders
:(
NSDictionary
*
)
headers
completionHandler
:(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
;
...
...
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