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
b9bf4ab4
Commit
b9bf4ab4
authored
Mar 14, 2016
by
Gabriel O'Flaherty-Chan
Committed by
Gabriel O'Flaherty-Chan
Mar 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add API to BUYClient allowing for a specific collection page to be fetched, update test JSON
parent
b7248c54
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
6 deletions
+83
-6
BUYClientTest_Storefront.m
...e Buy SDK/Mobile Buy SDK Tests/BUYClientTest_Storefront.m
+51
-0
mocked_responses.json
Mobile Buy SDK/Mobile Buy SDK Tests/mocked_responses.json
+0
-0
BUYClient.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
+21
-3
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+11
-3
No files found.
Mobile Buy SDK/Mobile Buy SDK Tests/BUYClientTest_Storefront.m
View file @
b9bf4ab4
...
...
@@ -215,6 +215,57 @@
}];
}
-
(
void
)
testCollectionsFromFirstPage
{
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
self
shouldUseMocks
];
}
withStubResponse
:
^
OHHTTPStubsResponse
*
_Nonnull
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testGetCollection_0"
];
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getCollectionsPage
:
1
completion
:
^
(
NSArray
<
BUYCollection
*>
*
collections
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
XCTAssertEqual
(
1
,
page
);
XCTAssertNotNil
((
collections
));
XCTAssertNil
(
error
);
XCTAssertNotNil
([
collections
.
firstObject
title
]);
XCTAssertNotNil
([
collections
.
firstObject
handle
]);
XCTAssertNotNil
([
collections
.
firstObject
collectionId
]);
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
}
-
(
void
)
testCollectionsFromEmptyPage
{
[
OHHTTPStubs
stubRequestsPassingTest
:
^
BOOL
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
self
shouldUseMocks
];
}
withStubResponse
:
^
OHHTTPStubsResponse
*
_Nonnull
(
NSURLRequest
*
_Nonnull
request
)
{
return
[
OHHTTPStubsResponse
responseWithKey
:
@"testGetOutOfIndexCollectionPage_0"
];
}];
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
NSStringFromSelector
(
_cmd
)];
[
self
.
client
getCollectionsPage
:
999
completion
:
^
(
NSArray
<
BUYCollection
*>
*
collections
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
XCTAssertEqual
(
999
,
page
);
XCTAssertNotNil
((
collections
));
XCTAssert
(
collections
.
count
==
0
);
XCTAssertNil
(
error
);
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
10
handler
:
^
(
NSError
*
error
)
{
XCTAssertNil
(
error
);
}];
}
-
(
void
)
testProductsInCollection
{
if
(
self
.
collection
==
nil
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK Tests/mocked_responses.json
View file @
b9bf4ab4
This source diff could not be displayed because it is too large. You can
view the blob
instead.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
View file @
b9bf4ab4
...
...
@@ -152,6 +152,14 @@ typedef void (^BUYDataShippingRatesBlock)(NSArray *shippingRates, BUYStatus stat
typedef
void
(
^
BUYDataShopBlock
)(
BUYShop
*
shop
,
NSError
*
error
);
/**
* Return block containing a list of BUYCollection objects and/or an NSError
*
* @param collections An array of BUYCollection objects
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataCollectionsBlock
)(
NSArray
<
BUYCollection
*>
*
collections
,
NSError
*
error
);
/**
* Return block containing a BUYProduct and/or an NSError
*
* @param product A BUYProduct
...
...
@@ -165,7 +173,7 @@ typedef void (^BUYDataProductBlock)(BUYProduct *product, NSError *error);
* @param products An array of BUYProduct objects
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataProductsBlock
)(
NSArray
*
products
,
NSError
*
error
);
typedef
void
(
^
BUYDataProductsBlock
)(
NSArray
<
BUYProduct
*>
*
products
,
NSError
*
error
);
/**
* Return block containing list of collections
...
...
@@ -173,7 +181,7 @@ typedef void (^BUYDataProductsBlock)(NSArray *products, NSError *error);
* @param collections An array of BUYCollection objects
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataCollections
Block
)(
NSArray
*
collections
,
NSError
*
error
);
typedef
void
(
^
BUYDataCollections
ListBlock
)(
NSArray
<
BUYCollection
*>
*
collections
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
);
/**
* Return block containing a list of BUYProduct objects, the page requested, a boolean to determine whether the end of the list has been reach and/or an optional NSError
...
...
@@ -183,7 +191,7 @@ typedef void (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error);
* @param reachedEnd Boolean indicating whether additional pages exist
* @param error An optional NSError
*/
typedef
void
(
^
BUYDataProductListBlock
)(
NSArray
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
);
typedef
void
(
^
BUYDataProductListBlock
)(
NSArray
<
BUYProduct
*>
*
products
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
);
/**
* Return block containing a list of BUYProductImage objects and/or an NSError
...
...
@@ -314,6 +322,16 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
-
(
NSURLSessionDataTask
*
)
getCollections
:(
BUYDataCollectionsBlock
)
block
;
/**
* Fetches collections based off page
*
* @param page Index of the page requested
* @param block (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error)
*
* @return The associated NSURLSessionDataTask
*/
-
(
NSURLSessionDataTask
*
)
getCollectionsPage
:(
NSUInteger
)
page
completion
:(
BUYDataCollectionsListBlock
)
block
;
/**
* Fetches the products in the given collection with the collection's
* default sort order set in the shop's admin
*
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
b9bf4ab4
...
...
@@ -180,15 +180,23 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_publi
-
(
NSURLSessionDataTask
*
)
getCollections
:
(
BUYDataCollectionsBlock
)
block
{
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathCollectionPublications
queryItems
:
nil
];
return
[
self
getCollectionsPage
:
1
completion
:
^
(
NSArray
<
BUYCollection
*>
*
collections
,
NSUInteger
page
,
BOOL
reachedEnd
,
NSError
*
error
)
{
block
(
collections
,
error
);
}];
}
-
(
NSURLSessionDataTask
*
)
getCollectionsPage
:
(
NSUInteger
)
page
completion
:
(
BUYDataCollectionsListBlock
)
block
{
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathCollectionPublications
queryItems
:@{
@"limit"
:
[
NSString
stringWithFormat
:
@"%lu"
,
(
unsigned
long
)
self
.
pageSize
],
@"page"
:
[
NSString
stringWithFormat
:
@"%lu"
,
(
unsigned
long
)
page
]}];
return
[
self
getRequestForURL
:
components
.
URL
completionHandler
:
^
(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
)
{
NSArray
*
collections
=
nil
;
if
(
json
&&
error
==
nil
)
{
collections
=
[
BUYCollection
convertJSONArray
:
json
[
kBUYClientPathCollectionPublications
]];
}
block
(
collections
,
error
);
block
(
collections
,
page
,
[
self
hasReachedEndOfPage
:
collections
],
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