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
1c040c62
Commit
1c040c62
authored
Jul 26, 2016
by
Brent Gulanowski
Committed by
GitHub
Jul 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #276 from Shopify/task/collection-handle
Add support to get collection with handle
parents
a353280d
405f96fd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
8 deletions
+61
-8
BUYClient+StorefrontTests.m
... Buy SDK/Mobile Buy SDK Tests/BUYClient+StorefrontTests.m
+20
-0
BUYClient+Storefront.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
+26
-8
BUYClient+Storefront.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
+15
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+StorefrontTests.m
View file @
1c040c62
...
...
@@ -253,6 +253,26 @@
}];
}
-
(
void
)
testCollectionHandle
{
[
OHHTTPStubs
stubUsingResponseWithKey
:
@"testGetCollection_0"
useMocks
:[
self
shouldUseMocks
]];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getCollectionByHandle
:
@"frontpage"
completion
:
^
(
BUYCollection
*
_Nullable
collection
,
NSError
*
_Nullable
error
)
{
XCTAssertNotNil
(
collection
);
XCTAssertEqualObjects
(
@"Frontpage"
,
collection
.
title
);
XCTAssertEqualObjects
(
@109931075
,
collection
.
identifier
);
XCTAssertNil
(
error
);
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
}
-
(
void
)
testProductsInCollection
{
if
(
self
.
collection
==
nil
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
View file @
1c040c62
...
...
@@ -78,6 +78,14 @@ typedef NS_ENUM(NSUInteger, BUYCollectionSort) {
typedef
void
(
^
BUYDataShopBlock
)(
BUYShop
*
_Nullable
shop
,
NSError
*
_Nullable
error
);
/**
* Return block containing a BUYCollection object and/or an NSError
*
* @param collection A BUYCollection object.
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataCollectionBlock
)(
BUYCollection
*
_Nullable
collection
,
NSError
*
_Nullable
error
);
/**
* Return block containing a list of BUYCollection objects and/or an NSError
*
* @param collections An array of BUYCollection objects
...
...
@@ -136,7 +144,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
*
* @param block (^BUYDataShopBlock)(BUYShop *shop, NSError *error);
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getShop
:(
BUYDataShopBlock
)
block
;
...
...
@@ -146,7 +154,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param page Page to request. Pages start at 1.
* @param block (^BUYDataProductListBlock)(NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error);
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
completion
:(
BUYDataProductListBlock
)
block
;
...
...
@@ -156,7 +164,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param handle Product handle
* @param block (^BUYDataProductBlock)(BUYProduct *product, NSError *error);
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getProductByHandle
:(
NSString
*
)
handle
completion
:(
BUYDataProductBlock
)
block
;
...
...
@@ -166,7 +174,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param productId Product ID
* @param block (^BUYDataProductBlock)(BUYProduct *product, NSError *error);
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getProductById
:(
NSNumber
*
)
productId
completion
:(
BUYDataProductBlock
)
block
;
...
...
@@ -176,7 +184,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param productIds An array of `NSString` objects with Product IDs to fetch
* @param block (^BUYDataProductsBlock)(NSArray *products, NSError *error);
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getProductsByIds
:(
NSArray
<
NSNumber
*>
*
)
productIds
completion
:(
BUYDataProductsBlock
)
block
;
...
...
@@ -191,12 +199,22 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
-
(
NSOperation
*
)
getProductTagsPage
:(
NSUInteger
)
page
completion
:(
BUYDataTagsListBlock
)
block
;
/**
* Fetch a single collection by the handle of the collection.
*
* @param handle Collection handle
* @param block (^BUYDataCollectionBlock)(BUYCollection* _Nullable collection, NSError * _Nullable error)
*
* @return The associated operation.
*/
-
(
NSOperation
*
)
getCollectionByHandle
:(
NSString
*
)
handle
completion
:(
BUYDataCollectionBlock
)
block
;
/**
* Fetches collections based off page
*
* @param page Index of the page requested
* @param block (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error)
*
* @return The associated
BUYRequestO
peration
* @return The associated
o
peration
*/
-
(
NSOperation
*
)
getCollectionsPage
:(
NSUInteger
)
page
completion
:(
BUYDataCollectionsListBlock
)
block
;
...
...
@@ -208,7 +226,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param collectionId The `collectionId` found in the BUYCollection object to fetch the products from
* @param block (NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error)
*
* @return the associated
BUYRequestO
peration
* @return the associated
o
peration
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
completion
:(
BUYDataProductListBlock
)
block
;
...
...
@@ -221,7 +239,7 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* @param sortOrder The sort order that overrides the default collection sort order
* @param block (NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error)
*
* @return the associated
BUYRequestO
peration
* @return the associated
o
peration
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
nullable
NSNumber
*
)
collectionId
withTags
:(
nullable
NSArray
<
NSString
*>
*
)
tags
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
View file @
1c040c62
...
...
@@ -141,6 +141,21 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}];
}
-
(
NSOperation
*
)
getCollectionByHandle
:(
NSString
*
)
handle
completion
:(
BUYDataCollectionBlock
)
block
{
NSURL
*
url
=
[
self
urlForCollectionListingsWithParameters
:@{
@"handle"
:
handle
}];
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
BUYCollection
*
collection
=
nil
;
if
(
json
&&
!
error
)
{
collection
=
[
self
.
modelManager
buy_objectWithEntityName
:[
BUYCollection
entityName
]
JSONDictionary
:
json
[
BUYCollectionsKey
][
0
]];
}
block
(
collection
,
error
);
}];
}
-
(
NSOperation
*
)
getCollectionsPage
:(
NSUInteger
)
page
completion
:(
BUYDataCollectionsListBlock
)
block
{
NSURL
*
url
=
[
self
urlForCollectionListingsWithParameters
:@{
...
...
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