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
3b7520ca
Commit
3b7520ca
authored
May 12, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor get products page to assert instead of return error.
parent
678ed804
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
23 deletions
+17
-23
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+17
-23
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
3b7520ca
...
...
@@ -221,30 +221,24 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getProductsPage
:
(
NSUInteger
)
page
inCollection
:
(
NSNumber
*
)
collectionId
sortOrder
:
(
BUYCollectionSort
)
sortOrder
completion
:
(
BUYDataProductListBlock
)
block
{
NSURLSessionDataTask
*
task
=
nil
;
if
(
collectionId
)
{
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathProductPublications
queryItems
:@{
@"collection_id"
:
collectionId
.
stringValue
,
@"limit"
:
@
(
self
.
pageSize
).
stringValue
,
@"page"
:
@
(
page
).
stringValue
,
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
}];
task
=
[
self
getRequestForURL
:
components
.
URL
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
products
=
nil
;
if
(
json
&&
!
error
)
{
products
=
[
self
.
modelManager
buy_objectsWithEntityName
:[
BUYProduct
entityName
]
JSONArray
:
json
[
kBUYClientPathProductPublications
]];
}
block
(
products
,
page
,
[
self
hasReachedEndOfPage
:
products
]
||
error
,
error
);
}];
}
else
{
block
(
nil
,
0
,
NO
,
[
NSError
errorWithDomain
:
kShopifyError
code
:
BUYShopifyError_NoCollectionIdSpecified
userInfo
:
nil
]);
}
NSAssert
(
collectionId
,
@"Failed to get products page. Invalid collectionID."
);
return
task
;
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathProductPublications
queryItems
:@{
@"collection_id"
:
collectionId
.
stringValue
,
@"limit"
:
@
(
self
.
pageSize
).
stringValue
,
@"page"
:
@
(
page
).
stringValue
,
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
}];
return
[
self
getRequestForURL
:
components
.
URL
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
products
=
nil
;
if
(
json
&&
!
error
)
{
products
=
[
self
.
modelManager
buy_objectsWithEntityName
:[
BUYProduct
entityName
]
JSONArray
:
json
[
kBUYClientPathProductPublications
]];
}
block
(
products
,
page
,
[
self
hasReachedEndOfPage
:
products
]
||
error
,
error
);
}];
}
#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