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
b8be173a
Commit
b8be173a
authored
Jul 19, 2016
by
Brent Gulanowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add proper initializer to BUYCustomerToken.
parent
426f4dbe
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
29 deletions
+40
-29
BUYClient+Customers.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
+4
-4
BUYClient+Routing.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
+5
-4
BUYClient+Routing.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
+12
-12
BUYCustomerToken.h
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.h
+3
-1
BUYCustomerToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.m
+16
-8
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
View file @
b8be173a
...
...
@@ -115,7 +115,7 @@
-
(
NSOperation
*
)
renewCustomerTokenCallback
:(
BUYDataTokenBlock
)
block
{
if
(
self
.
customerToken
)
{
NSURL
*
url
=
[
self
urlForCustomersTokenRenewal
WithID
:
self
.
customerToken
.
customerID
];
NSURL
*
url
=
[
self
urlForCustomersTokenRenewal
];
return
[
self
putRequestForURL
:
url
object
:
nil
completionHandler
:^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
NSString
*
accessToken
=
nil
;
...
...
@@ -137,7 +137,7 @@
-
(
NSOperation
*
)
logoutCustomerCallback
:(
BUYDataStatusBlock
)
block
{
NSURL
*
url
=
[
self
urlForLoggedInCustomer
];
NSURL
*
url
=
[
self
urlForLoggedInCustomer
Token
];
return
[
self
deleteRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
block
(
response
.
statusCode
,
error
);
}];
...
...
@@ -160,7 +160,7 @@
-
(
NSOperation
*
)
getOrdersForCustomerCallback
:(
BUYDataOrdersBlock
)
block
{
NSURL
*
url
=
[
self
urlFor
LoggedInCustomer
];
NSURL
*
url
=
[
self
urlFor
CustomersOrders
];
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
if
(
json
&&
!
error
)
{
NSArray
*
orders
=
[
self
.
modelManager
ordersWithJSONDictionary
:
json
];
...
...
@@ -173,7 +173,7 @@
-
(
NSOperation
*
)
getOrderWithID
:(
NSNumber
*
)
orderID
callback
:(
BUYDataOrderBlock
)
block
{
NSURL
*
url
=
[
self
urlForCustomersOrdersWith
ID
:
self
.
customerToken
.
customerID
o
rderID
:
orderID
];
NSURL
*
url
=
[
self
urlForCustomersOrdersWith
O
rderID
:
orderID
];
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
if
(
json
&&
!
error
)
{
BUYOrder
*
order
=
[
self
.
modelManager
orderWithJSONDictionary
:
json
];
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
View file @
b8be173a
...
...
@@ -50,13 +50,14 @@
-
(
NSURL
*
)
urlForCustomersToken
;
-
(
NSURL
*
)
urlForCustomersPasswordRecovery
;
-
(
NSURL
*
)
urlForLoggedInCustomer
;
-
(
NSURL
*
)
urlForLoggedInCustomerToken
;
-
(
NSURL
*
)
urlForCustomersTokenRenewal
;
-
(
NSURL
*
)
urlForCustomersOrders
;
-
(
NSURL
*
)
urlForCustomersOrdersWithOrderID
:(
NSNumber
*
)
orderID
;
-
(
NSURL
*
)
urlForCustomersOrdersWithID
:(
NSString
*
)
identifier
;
-
(
NSURL
*
)
urlForCustomersOrdersWithID
:(
NSString
*
)
identifier
orderID
:(
NSNumber
*
)
orderID
;
-
(
NSURL
*
)
urlForCustomersWithID
:(
NSString
*
)
identifier
;
-
(
NSURL
*
)
urlForCustomersActivationWithID
:(
NSString
*
)
identifier
parameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCustomersTokenWithID
:(
NSString
*
)
customerID
;
-
(
NSURL
*
)
urlForCustomersTokenRenewalWithID
:(
NSString
*
)
customerID
;
-
(
NSURL
*
)
urlForCustomersPasswordResetWithID
:(
NSString
*
)
identifier
parameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCustomersAddressesWithID
:(
NSString
*
)
customerID
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
View file @
b8be173a
...
...
@@ -191,7 +191,12 @@
-
(
NSURL
*
)
urlForLoggedInCustomer
{
return
[
self
urlForCustomersWithID
:
self
.
customerToken
.
customerID
];
return
[
self
urlForCustomersWithID
:[
self
.
customerToken
.
customerID
stringValue
]];
}
-
(
NSURL
*
)
urlForLoggedInCustomerToken
{
return
[[[
self
urlForLoggedInCustomer
]
appendPath
:
@"/customer_token"
]
appendExtension
];
}
#pragma mark - Customer With ID -
...
...
@@ -201,14 +206,14 @@
return
[[[
self
urlForCustomers
]
appendPath
:
identifier
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersOrders
WithID
:
(
NSString
*
)
identifier
-
(
NSURL
*
)
urlForCustomersOrders
{
return
[[[
self
urlFor
CustomersWithID
:
identifi
er
]
appendPath
:
@"/orders"
]
appendExtension
];
return
[[[
self
urlFor
LoggedInCustom
er
]
appendPath
:
@"/orders"
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersOrdersWith
ID
:
(
NSString
*
)
identifier
o
rderID
:
(
NSNumber
*
)
orderID
-
(
NSURL
*
)
urlForCustomersOrdersWith
O
rderID
:
(
NSNumber
*
)
orderID
{
return
[[[
self
urlForCustomersOrders
WithID
:
identifier
]
appendIdentifier
:
orderID
]
appendExtension
];
return
[[[
self
urlForCustomersOrders
]
appendIdentifier
:
orderID
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersActivationWithID
:
(
NSString
*
)
identifier
parameters
:
(
NSDictionary
*
)
parameters
...
...
@@ -216,14 +221,9 @@
return
[[[[
self
urlForCustomersWithID
:
identifier
]
appendPath
:
@"/activate"
]
appendParameters
:
parameters
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersTokenWithID
:
(
NSString
*
)
customerID
{
return
[[[
self
urlForCustomersWithID
:
customerID
]
appendPath
:
@"/customer_token"
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersTokenRenewalWithID
:
(
NSString
*
)
customerID
-
(
NSURL
*
)
urlForCustomersTokenRenewal
{
return
[[[
self
urlFor
CustomersWithID
:
customerID
]
appendPath
:
@"/customer_token/renew"
]
appendExtension
];
return
[[[
self
urlFor
LoggedInCustomer
]
appendPath
:
@"/customer_token/renew"
]
appendExtension
];
}
-
(
NSURL
*
)
urlForCustomersPasswordResetWithID
:
(
NSString
*
)
identifier
parameters
:
(
NSDictionary
*
)
parameters
...
...
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.h
View file @
b8be173a
...
...
@@ -30,9 +30,11 @@
@property
(
nonatomic
,
copy
,
readonly
)
NSString
*
accessToken
;
@property
(
nonatomic
,
copy
,
readonly
)
NSDate
*
expiry
;
@property
(
nonatomic
,
copy
,
readonly
)
NS
String
*
customerID
;
@property
(
nonatomic
,
copy
,
readonly
)
NS
Number
*
customerID
;
@property
(
nonatomic
,
copy
,
readonly
)
NSDictionary
*
JSONDictionary
;
-
(
instancetype
)
init
NS_UNAVAILABLE
;
-
(
instancetype
)
initWithCustomerID
:(
NSNumber
*
)
customerID
accessToken
:(
NSString
*
)
accessToken
expiry
:(
NSDate
*
)
expiry
;
+
(
BUYCustomerToken
*
)
customerTokenWithJSON
:(
NSDictionary
*
)
json
;
@end
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomerToken.m
View file @
b8be173a
...
...
@@ -34,23 +34,31 @@ static NSString * const customerIDKey = @"customer_id";
@implementation
BUYCustomerToken
-
(
instancetype
)
initWithCustomerID
:(
NSNumber
*
)
customerID
accessToken
:(
NSString
*
)
accessToken
expiry
:(
NSDate
*
)
expiry
{
self
=
[
super
init
];
if
(
self
)
{
_customerID
=
customerID
;
_accessToken
=
accessToken
;
_expiry
=
expiry
;
}
return
self
;
}
+
(
BUYCustomerToken
*
)
customerTokenWithJSON
:(
NSDictionary
*
)
json
{
return
[[
[
self
class
]
alloc
]
initWithJSON
:
json
];
return
[[
self
alloc
]
initWithJSON
:
json
];
}
-
(
instancetype
)
initWithJSON
:(
NSDictionary
*
)
json
{
self
=
[
super
init
];
if
(
self
)
{
NSDateFormatter
*
formatter
=
[
NSDateFormatter
dateFormatterForPublications
];
NSDictionary
*
access
=
json
[
customerAccessTokenKey
];
_accessToken
=
access
[
accessTokenKey
];
_expiry
=
[
formatter
dateFromString
:
access
[
expiresAtKey
]];
_customerID
=
[
NSString
stringWithFormat
:
@"%@"
,
access
[
customerIDKey
]];
}
return
self
;
NSNumber
*
customerID
=
access
[
customerIDKey
];
NSString
*
accessToken
=
access
[
accessTokenKey
];
NSDate
*
expiry
=
[
formatter
dateFromString
:
access
[
expiresAtKey
]];
return
[
self
initWithCustomerID
:
customerID
accessToken
:
accessToken
expiry
:
expiry
];
}
-
(
NSDictionary
*
)
JSONDictionary
...
...
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