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
a353280d
Commit
a353280d
authored
Jul 22, 2016
by
David Muzi
Committed by
GitHub
Jul 22, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #273 from Shopify/task/customer-update
Add customer update endpoint
parents
edcaa8e9
770a2411
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
19 deletions
+12
-19
BUYClient+CustomerTests.m
...le Buy SDK/Mobile Buy SDK Tests/BUYClient+CustomerTests.m
+6
-12
BUYClient+Customers.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.h
+3
-4
BUYClient+Customers.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
+3
-3
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+CustomerTests.m
View file @
a353280d
...
...
@@ -197,26 +197,20 @@
[
self
waitForExpectationsWithTimeout
:
10
.
0
handler
:
^
(
NSError
*
error
)
{}];
}
#pragma mark - Update -
-
(
void
)
testCustomerUpdate
{
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testCustomerLogin"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
BUYAccountCredentialItem
*
email
=
[
BUYAccountCredentialItem
itemWithEmail
:
self
.
customerEmail
];
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
credentialsWithItems
:@[
email
]];
[
self
.
client
updateCustomerWithCredentials
:
credentials
callback
:
^
(
BUYCustomer
*
customer
,
NSError
*
error
)
{
[
self
.
client
updateCustomer
:
_customer
callback
:
^
(
BUYCustomer
*
_Nullable
customer
,
NSError
*
_Nullable
error
)
{
XCTAssertNil
(
error
);
XCTAssertNotNil
(
customer
);
XCTAssertEqualObjects
(
customer
.
email
,
self
.
customerEmail
);
[
expectation
fulfill
];
}];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{}];
}
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.h
View file @
a353280d
...
...
@@ -119,14 +119,13 @@ typedef void (^BUYDataOrderBlock)(BUYOrder * _Nullable order, NSError * _Nullabl
/**
* PUT /api/customers/:customer_id
* Update customer credentials represented by BUYAccountCredentials object
*
* @param c
redentials Credentials containing a password
* @param block
(BUYCustomer *customer, NSError *error)
* @param c
ustomer the customer object to update
* @param block (BUYCustomer *customer, NSError *error)
*
* @return The associated BUYRequestOperation
*/
-
(
NSOperation
*
)
updateCustomer
WithCredentials
:(
BUYAccountCredentials
*
)
credentials
callback
:(
BUYDataCustomerBlock
)
block
;
-
(
NSOperation
*
)
updateCustomer
:(
BUYCustomer
*
)
customer
callback
:(
BUYDataCustomerBlock
)
block
;
/**
* PUT /api/customers/:customer_id/reset
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Customers.m
View file @
a353280d
...
...
@@ -82,10 +82,10 @@
}];
}
-
(
NSOperation
*
)
updateCustomer
WithCredentials
:(
BUYAccountCredentials
*
)
credentials
callback
:(
BUYDataCustomerBlock
)
block
-
(
NSOperation
*
)
updateCustomer
:(
BUYCustomer
*
)
customer
callback
:(
BUYDataCustomerBlock
)
block
{
NSURL
*
url
=
[
self
urlFor
LoggedInCustomer
];
return
[
self
putRequestForURL
:
url
object
:
credentials
.
JSONRepresentation
completionHandler
:^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
NSURL
*
url
=
[
self
urlFor
CustomersWithID
:
customer
.
identifier
.
stringValue
];
return
[
self
putRequestForURL
:
url
object
:
@{
@"customer"
:
customer
.
JSONDictionary
}
completionHandler
:^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
BUYCustomer
*
customer
=
nil
;
if
(
json
&&
!
error
)
{
customer
=
[
self
.
modelManager
customerWithJSONDictionary
:
json
];
...
...
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