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
4f9f8577
Commit
4f9f8577
authored
8 years ago
by
David Muzi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
product tags API implementation
parent
1b5065bd
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
32 deletions
+40
-32
BUYClientTest.m
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
+1
-1
BUYClient+Routing.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
+1
-0
BUYClient+Routing.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
+5
-0
BUYClient+Storefront.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
+2
-24
BUYClient+Storefront.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
+31
-7
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
4f9f8577
...
@@ -184,7 +184,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
...
@@ -184,7 +184,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
-
(
void
)
testProductsInCollection
-
(
void
)
testProductsInCollection
{
{
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getProductsPage
:
1
inCollection
:
@1
sortOrder
:
BUYCollectionSortCollectionDefault
completion
:^
(
NSArray
<
BUYProduct
*>
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{}];
BUYRequestOperation
*
task
=
(
BUYRequestOperation
*
)[
self
.
client
getProductsPage
:
1
withTags
:
nil
inCollection
:
@1
sortOrder
:
BUYCollectionSortCollectionDefault
completion
:^
(
NSArray
<
BUYProduct
*>
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{}];
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
HTTPMethod
,
@"GET"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
host
,
@"test_shop"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
host
,
@"test_shop"
);
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
View file @
4f9f8577
...
@@ -34,6 +34,7 @@
...
@@ -34,6 +34,7 @@
-
(
NSURL
*
)
urlForShop
;
-
(
NSURL
*
)
urlForShop
;
-
(
NSURL
*
)
urlForProductListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForProductListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCollectionListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCollectionListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForProductTagsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCheckouts
;
-
(
NSURL
*
)
urlForCheckouts
;
-
(
NSURL
*
)
urlForCheckoutsWithToken
:(
NSString
*
)
token
;
-
(
NSURL
*
)
urlForCheckoutsWithToken
:(
NSString
*
)
token
;
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
View file @
4f9f8577
...
@@ -124,6 +124,11 @@
...
@@ -124,6 +124,11 @@
return
[[[[
self
urlForApps
]
appendPath
:
@"/collection_listings"
]
appendExtension
]
appendParameters
:
parameters
];
return
[[[[
self
urlForApps
]
appendPath
:
@"/collection_listings"
]
appendExtension
]
appendParameters
:
parameters
];
}
}
-
(
NSURL
*
)
urlForProductTagsWithParameters
:
(
NSDictionary
*
)
parameters
{
return
[[[[
self
urlForApps
]
appendPath
:
@"/product_listings/tags"
]
appendExtension
]
appendParameters
:
parameters
];;
}
#pragma mark - Checkout -
#pragma mark - Checkout -
-
(
NSURL
*
)
urlForCheckouts
-
(
NSURL
*
)
urlForCheckouts
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
View file @
4f9f8577
...
@@ -191,29 +191,6 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
...
@@ -191,29 +191,6 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
-
(
NSOperation
*
)
getProductTagsPage
:(
NSUInteger
)
page
completion
:(
BUYDataTagsListBlock
)
block
;
-
(
NSOperation
*
)
getProductTagsPage
:(
NSUInteger
)
page
completion
:(
BUYDataTagsListBlock
)
block
;
/**
/**
* Get the set of products that contain the tags provided
*
* @param page Page to request. Pages start at 1.
* @param tags an array of tags which each product must contain
* @param block (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error)
*
* @return The associated NSOperation
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
withTags
:(
NSArray
<
NSString
*>
*
)
tags
completion
:(
BUYDataProductListBlock
)
block
;
/**
* Get the set of products that contain the tags provided within the given collection
*
* @param page Page to request. Pages start at 1.
* @param tags an array of tags which each product must contain
* @param collectionId The `collectionId` found in the BUYCollection object to fetch the products from
* @param block (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable products, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error)
*
* @return The associated NSOperation
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
withTags
:(
NSArray
<
NSString
*>
*
)
tags
inCollection
:(
nullable
NSNumber
*
)
collectionId
completion
:(
BUYDataProductListBlock
)
block
;
/**
* Fetches collections based off page
* Fetches collections based off page
*
*
* @param page Index of the page requested
* @param page Index of the page requested
...
@@ -239,13 +216,14 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
...
@@ -239,13 +216,14 @@ typedef void (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUI
* Fetches the products in the given collection with a given sort order
* Fetches the products in the given collection with a given sort order
*
*
* @param page Index of the page requested
* @param page Index of the page requested
* @param tags an array of tags which each product must contain
* @param collectionId The `collectionId` found in the BUYCollection object to fetch the products from
* @param collectionId The `collectionId` found in the BUYCollection object to fetch the products from
* @param sortOrder The sort order that overrides the default collection sort order
* @param sortOrder The sort order that overrides the default collection sort order
* @param block (NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error)
* @param block (NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error)
*
*
* @return the associated BUYRequestOperation
* @return the associated BUYRequestOperation
*/
*/
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
;
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
withTags
:(
nullable
NSArray
<
NSString
*>
*
)
tags
inCollection
:(
nullable
NSNumber
*
)
collectionId
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
;
@end
@end
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
View file @
4f9f8577
...
@@ -124,6 +124,23 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
...
@@ -124,6 +124,23 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
}];
}];
}
}
-
(
NSOperation
*
)
getProductTagsPage
:(
NSUInteger
)
page
completion
:(
BUYDataTagsListBlock
)
block
{
NSURL
*
url
=
[
self
urlForProductTagsWithParameters
:@{
@"limit"
:
@
(
self
.
pageSize
),
@"page"
:
@
(
page
),
}];
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
tags
=
nil
;
if
(
json
&&
!
error
)
{
tags
=
[
json
[
@"tags"
]
valueForKey
:
@"title"
];
}
block
(
tags
,
[
self
hasReachedEndOfPage
:
tags
],
page
,
error
);
}];
}
-
(
NSOperation
*
)
getCollectionsPage
:(
NSUInteger
)
page
completion
:(
BUYDataCollectionsListBlock
)
block
-
(
NSOperation
*
)
getCollectionsPage
:(
NSUInteger
)
page
completion
:(
BUYDataCollectionsListBlock
)
block
{
{
NSURL
*
url
=
[
self
urlForCollectionListingsWithParameters
:@{
NSURL
*
url
=
[
self
urlForCollectionListingsWithParameters
:@{
...
@@ -143,19 +160,26 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
...
@@ -143,19 +160,26 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
completion
:(
BUYDataProductListBlock
)
block
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
completion
:(
BUYDataProductListBlock
)
block
{
{
return
[
self
getProductsPage
:
page
inCollection
:
collectionId
sortOrder
:
BUYCollectionSortCollectionDefault
completion
:
block
];
return
[
self
getProductsPage
:
page
withTags
:
nil
inCollection
:
collectionId
sortOrder
:
BUYCollectionSortCollectionDefault
completion
:
block
];
}
}
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
withTags
:(
NSArray
<
NSString
*>
*
)
tags
inCollection
:(
NSNumber
*
)
collectionId
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
{
{
BUYAssert
(
collectionId
,
@"Failed to get products page. Invalid collectionID."
);
NSMutableDictionary
*
params
=
@{
NSURL
*
url
=
[
self
urlForProductListingsWithParameters
:@{
@"collection_id"
:
collectionId
,
@"limit"
:
@
(
self
.
pageSize
),
@"limit"
:
@
(
self
.
pageSize
),
@"page"
:
@
(
page
),
@"page"
:
@
(
page
),
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
}];
}.
mutableCopy
;
if
(
tags
)
{
params
[
@"tags"
]
=
[
tags
componentsJoinedByString
:
@","
];
}
if
(
collectionId
)
{
params
[
@"collection_id"
]
=
collectionId
;
}
NSURL
*
url
=
[
self
urlForProductListingsWithParameters
:
params
];
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
return
[
self
getRequestForURL
:
url
completionHandler
:
^
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
...
...
This diff is collapsed.
Click to expand it.
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