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
5938fa3b
Commit
5938fa3b
authored
Jul 18, 2016
by
David Muzi
Browse files
Options
Browse Files
Download
Plain Diff
merge with develop
parents
3adc2c74
83dc0a05
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
83 additions
and
14 deletions
+83
-14
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
+33
-9
No files found.
Mobile Buy SDK Sample Apps/Advanced App - ObjC/Mobile Buy SDK Advanced Sample/Product View/ProductViewController.m
View file @
5938fa3b
...
...
@@ -269,7 +269,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
[
self
.
navigationController
setNavigationBarHidden
:
NO
];
}
if
(
self
.
product
.
publicURL
)
{
if
(
self
.
URLForSharing
)
{
UIBarButtonItem
*
rightButton
=
[[
UIBarButtonItem
alloc
]
initWithBarButtonSystemItem
:
UIBarButtonSystemItemAction
target
:
self
action
:
@selector
(
shareLink
)];
NSArray
*
rightButtons
=
[@[
rightButton
]
arrayByAddingObjectsFromArray
:
self
.
navigationItem
.
rightBarButtonItems
];
self
.
navigationItem
.
rightBarButtonItems
=
rightButtons
;
...
...
@@ -584,7 +584,8 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
-
(
NSURL
*
)
URLForSharing
{
return
self
.
product
.
publicURL
;
NSString
*
urlString
=
[
NSString
stringWithFormat
:
@"%@/products/%@"
,
self
.
shop
.
domain
,
self
.
product
.
handle
];
return
[
NSURL
URLWithString
:
urlString
];
}
-
(
UIImage
*
)
ImageForSharing
...
...
Mobile Buy SDK Sample Apps/Advanced App - ObjC/Mobile Buy SDK Advanced Sample/ProductListViewController.m
View file @
5938fa3b
...
...
@@ -162,7 +162,7 @@
{
[
self
.
collectionOperation
cancel
];
[[
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
];
if
(
error
==
nil
&&
products
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClient+StorefrontTests.m
View file @
5938fa3b
...
...
@@ -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
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest.m
View file @
5938fa3b
...
...
@@ -184,7 +184,7 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
-
(
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
.
URL
.
scheme
,
@"https"
);
XCTAssertEqualObjects
(
task
.
originalRequest
.
URL
.
host
,
@"test_shop"
);
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.h
View file @
5938fa3b
...
...
@@ -34,6 +34,7 @@
-
(
NSURL
*
)
urlForShop
;
-
(
NSURL
*
)
urlForProductListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCollectionListingsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForProductTagsWithParameters
:(
NSDictionary
*
)
parameters
;
-
(
NSURL
*
)
urlForCheckouts
;
-
(
NSURL
*
)
urlForCheckoutsWithToken
:(
NSString
*
)
token
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Routing.m
View file @
5938fa3b
...
...
@@ -124,6 +124,11 @@
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 -
-
(
NSURL
*
)
urlForCheckouts
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.h
View file @
5938fa3b
...
...
@@ -119,6 +119,16 @@ typedef void (^BUYDataCollectionsListBlock)(NSArray<BUYCollection *> * _Nullable
*/
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
)
/**
...
...
@@ -171,6 +181,16 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
-
(
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
*
* @param page Index of the page requested
...
...
@@ -197,12 +217,13 @@ typedef void (^BUYDataProductListBlock)(NSArray<BUYProduct *> * _Nullable produc
*
* @param page Index of the page requested
* @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 block (NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error)
*
* @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
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Storefront.m
View file @
5938fa3b
...
...
@@ -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
{
NSURL
*
url
=
[
self
urlForCollectionListingsWithParameters
:@{
...
...
@@ -143,19 +160,26 @@ static NSString * const BUYCollectionsKey = @"collection_listings";
-
(
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
=
@{
@"limit"
:
@
(
self
.
pageSize
),
@"page"
:
@
(
page
),
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
}.
mutableCopy
;
NSURL
*
url
=
[
self
urlForProductListingsWithParameters
:@{
@"collection_id"
:
collectionId
,
@"limit"
:
@
(
self
.
pageSize
),
@"page"
:
@
(
page
),
@"sort_by"
:
[
BUYCollection
sortOrderParameterForCollectionSort
:
sortOrder
]
}];
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
)
{
...
...
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