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
e81100f8
Commit
e81100f8
authored
Jul 19, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up JSON interface on BUYCustomerToken.
parent
c8fd3ec9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
7 deletions
+23
-7
BUYClient+Customers.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
+1
-1
BUYCustomerToken.h
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.h
+2
-1
BUYCustomerToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.m
+20
-5
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
View file @
e81100f8
...
@@ -190,7 +190,7 @@
...
@@ -190,7 +190,7 @@
NSURL
*
url
=
[
self
urlForCustomersToken
];
NSURL
*
url
=
[
self
urlForCustomersToken
];
return
[
self
postRequestForURL
:
url
object
:
credentials
.
JSONRepresentation
completionHandler
:^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
postRequestForURL
:
url
object
:
credentials
.
JSONRepresentation
completionHandler
:^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
if
(
json
&&
!
error
)
{
if
(
json
&&
!
error
)
{
BUYCustomerToken
*
authenticatedResponse
=
[
BUYCustomerToken
response
WithJSON
:
json
];
BUYCustomerToken
*
authenticatedResponse
=
[
BUYCustomerToken
customerToken
WithJSON
:
json
];
self
.
customerToken
=
authenticatedResponse
.
accessToken
;
self
.
customerToken
=
authenticatedResponse
.
accessToken
;
if
(
!
customerJSON
)
{
if
(
!
customerJSON
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.h
View file @
e81100f8
...
@@ -31,7 +31,8 @@
...
@@ -31,7 +31,8 @@
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
accessToken
;
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
accessToken
;
@property
(
nonatomic
,
copy
,
readonly
)
NSDate
*
expiry
;
@property
(
nonatomic
,
copy
,
readonly
)
NSDate
*
expiry
;
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
customerID
;
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
customerID
;
@property
(
nonatomic
,
copy
,
readonly
)
NSDictionary
*
JSONDictionary
;
+
(
BUYCustomerToken
*
)
response
WithJSON
:(
NSDictionary
*
)
json
;
+
(
BUYCustomerToken
*
)
customerToken
WithJSON
:(
NSDictionary
*
)
json
;
@end
@end
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.m
View file @
e81100f8
...
@@ -27,9 +27,14 @@
...
@@ -27,9 +27,14 @@
#import "BUYCustomerToken.h"
#import "BUYCustomerToken.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h"
static
NSString
*
const
customerAccessTokenKey
=
@"customer_access_token"
;
static
NSString
*
const
accessTokenKey
=
@"access_token"
;
static
NSString
*
const
expiresAtKey
=
@"expires_at"
;
static
NSString
*
const
customerIDKey
=
@"customer_id"
;
@implementation
BUYCustomerToken
@implementation
BUYCustomerToken
+
(
BUYCustomerToken
*
)
response
WithJSON
:(
NSDictionary
*
)
json
+
(
BUYCustomerToken
*
)
customerToken
WithJSON
:(
NSDictionary
*
)
json
{
{
return
[[[
self
class
]
alloc
]
initWithJSON
:
json
];
return
[[[
self
class
]
alloc
]
initWithJSON
:
json
];
}
}
...
@@ -39,13 +44,23 @@
...
@@ -39,13 +44,23 @@
self
=
[
super
init
];
self
=
[
super
init
];
if
(
self
)
{
if
(
self
)
{
NSDateFormatter
*
formatter
=
[
NSDateFormatter
dateFormatterForPublications
];
NSDateFormatter
*
formatter
=
[
NSDateFormatter
dateFormatterForPublications
];
NSDictionary
*
access
=
json
[
@"customer_access_token"
];
NSDictionary
*
access
=
json
[
customerAccessTokenKey
];
_accessToken
=
access
[
@"access_token"
];
_accessToken
=
access
[
accessTokenKey
];
_expiry
=
[
formatter
dateFromString
:
access
[
@"expires_at"
]];
_expiry
=
[
formatter
dateFromString
:
access
[
expiresAtKey
]];
_customerID
=
[
NSString
stringWithFormat
:
@"%@"
,
access
[
@"customer_id"
]];
_customerID
=
[
NSString
stringWithFormat
:
@"%@"
,
access
[
customerIDKey
]];
}
}
return
self
;
return
self
;
}
}
-
(
NSDictionary
*
)
JSONDictionary
{
NSDateFormatter
*
formatter
=
[
NSDateFormatter
dateFormatterForPublications
];
return
@{
accessTokenKey
:
_accessToken
,
expiresAtKey
:
[
formatter
stringFromDate
:
_expiry
],
customerIDKey
:
_customerID
};
}
@end
@end
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