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
83dc0a05
Commit
83dc0a05
authored
Jul 18, 2016
by
David Muzi
Committed by
GitHub
Jul 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #252 from Shopify/task/product-tags
Product tags support
parents
9c2b37d0
20bcf555
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
12 deletions
+81
-12
ProductViewController.m
... SDK Advanced Sample/Product View/ProductViewController.m
+3
-2
ProductListViewController.m
...obile Buy SDK Advanced Sample/ProductListViewController.m
+1
-1
BUYClient+StorefrontTests.m
... Buy SDK/Mobile Buy SDK Tests/BUYClient+StorefrontTests.m
+17
-0
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
+22
-1
BUYClient+Storefront.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
+31
-7
No files found.
Mobile Buy SDK Sample Apps/Sample App Advanced/Mobile Buy SDK Advanced Sample/Product View/ProductViewController.m
View file @
83dc0a05
...
@@ -269,7 +269,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
...
@@ -269,7 +269,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
[
self
.
navigationController
setNavigationBarHidden
:
NO
];
[
self
.
navigationController
setNavigationBarHidden
:
NO
];
}
}
if
(
self
.
product
.
publicURL
)
{
if
(
self
.
URLForSharing
)
{
UIBarButtonItem
*
rightButton
=
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemAction
target
:
self
action
:
@selector
(
shareLink
)];
UIBarButtonItem
*
rightButton
=
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemAction
target
:
self
action
:
@selector
(
shareLink
)];
NSArray
*
rightButtons
=
[@[
rightButton
]
arrayByAddingObjectsFromArray
:
self
.
navigationItem
.
rightBarButtonItems
];
NSArray
*
rightButtons
=
[@[
rightButton
]
arrayByAddingObjectsFromArray
:
self
.
navigationItem
.
rightBarButtonItems
];
self
.
navigationItem
.
rightBarButtonItems
=
rightButtons
;
self
.
navigationItem
.
rightBarButtonItems
=
rightButtons
;
...
@@ -584,7 +584,8 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
...
@@ -584,7 +584,8 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
-
(
NSURL
*
)
URLForSharing
-
(
NSURL
*
)
URLForSharing
{
{
return
self
.
product
.
publicURL
;
NSString
*
urlString
=
[
NSString
stringWithFormat
:
@"%@/products/%@"
,
self
.
shop
.
domain
,
self
.
product
.
handle
];
return
[
NSURL
URLWithString
:
urlString
];
}
}
-
(
UIImage
*
)
ImageForSharing
-
(
UIImage
*
)
ImageForSharing
...
...
Mobile Buy SDK Sample Apps/Sample App Advanced/Mobile Buy SDK Advanced Sample/ProductListViewController.m
View file @
83dc0a05
...
@@ -162,7 +162,7 @@
...
@@ -162,7 +162,7 @@
{
{
[
self
.
collectionOperation
cancel
];
[
self
.
collectionOperation
cancel
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
YES
];
self
.
collectionOperation
=
[
self
.
client
getProductsPage
:
1
inCollection
:
self
.
collection
.
identifier
sortOrder
:
collectionSort
completion
:^
(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
self
.
collectionOperation
=
[
self
.
client
getProductsPage
:
1
withTags
:
nil
inCollection
:
self
.
collection
.
identifier
sortOrder
:
collectionSort
completion
:^
(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
[[
UIApplication
sharedApplication
]
setNetworkActivityIndicatorVisible
:
NO
];
if
(
error
==
nil
&&
products
)
{
if
(
error
==
nil
&&
products
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+StorefrontTests.m
View file @
83dc0a05
...
@@ -308,4 +308,21 @@
...
@@ -308,4 +308,21 @@
}];
}];
}
}
-
(
void
)
testGettingTags
{
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getProductTagsPage
:
1
completion
:
^
(
NSArray
*
tags
,
NSUInteger
page
,
BOOL
end
,
NSError
*
error
){
XCTAssertNil
(
error
);
XCTAssertNotNil
(
tags
);
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
}
@end
@end
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
83dc0a05
...
@@ -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
inCollection
:
@1
withTags
:
nil
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"
);
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
View file @
83dc0a05
...
@@ -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
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
View file @
83dc0a05
...
@@ -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
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
View file @
83dc0a05
...
@@ -119,6 +119,16 @@ typedef void (^BUYDataCollectionsListBlock)(NSArray<BUYCollection *> * _Nullable
...
@@ -119,6 +119,16 @@ typedef void (^BUYDataCollectionsListBlock)(NSArray<BUYCollection *> * _Nullable
*/
*/
typedef
void
(
^
BUYDataProductListBlock
)(
NSArray
<
BUYProduct
*>
*
_Nullable
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
_Nullable
error
);
typedef
void
(
^
BUYDataProductListBlock
)(
NSArray
<
BUYProduct
*>
*
_Nullable
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
_Nullable
error
);
/**
* Return block containing a list of tags
*
* @param tags An array of tag titles
* @param page Index of the page requested
* @param reachedEnd Boolean indicating whether additional pages exist
* @param error An optional NSError
*/
typedef
void
(
^
BUYDataTagsListBlock
)(
NSArray
<
NSString
*>
*
_Nullable
tags
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
_Nullable
error
);
@interface
BUYClient
(
Storefront
)
@interface
BUYClient
(
Storefront
)
/**
/**
...
@@ -171,6 +181,16 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
...
@@ -171,6 +181,16 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
-
(
NSOperation
*
)
getProductsByIds
:(
NSArray
<
NSNumber
*>
*
)
productIds
completion
:(
BUYDataProductsBlock
)
block
;
-
(
NSOperation
*
)
getProductsByIds
:(
NSArray
<
NSNumber
*>
*
)
productIds
completion
:(
BUYDataProductsBlock
)
block
;
/**
/**
* Gets the list of tags for all products
*
* @param page Page to request. Pages start at 1.
* @param block (^BUYDataTagsListBlock)(NSArray <NSString *> * _Nullable tags, NSUInteger page, BOOL reachedEnd, NSError * _Nullable error)
*
* @return The associated NSOperation
*/
-
(
NSOperation
*
)
getProductTagsPage
:(
NSUInteger
)
page
completion
:(
BUYDataTagsListBlock
)
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
...
@@ -197,12 +217,13 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
...
@@ -197,12 +217,13 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
*
*
* @param page Index of the page requested
* @param page Index of the page requested
* @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 tags An array of tags which each product must contain
* @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
inCollection
:(
nullable
NSNumber
*
)
collectionId
withTags
:(
nullable
NSArray
<
NSString
*>
*
)
tags
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
;
@end
@end
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
View file @
83dc0a05
...
@@ -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
inCollection
:
collectionId
withTags
:
nil
sortOrder
:
BUYCollectionSortCollectionDefault
completion
:
block
];
}
}
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
NSNumber
*
)
collectionId
sortOrder
:(
BUYCollectionSort
)
sortOrder
completion
:(
BUYDataProductListBlock
)
block
-
(
NSOperation
*
)
getProductsPage
:(
NSUInteger
)
page
inCollection
:(
nullable
NSNumber
*
)
collectionId
withTags
:(
nullable
NSArray
<
NSString
*>
*
)
tags
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
)
{
...
...
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