Commit 3b7520ca by Dima Bart

Refactor get products page to assert instead of return error.

parent 678ed804
......@@ -221,8 +221,8 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
- (NSURLSessionDataTask *)getProductsPage:(NSUInteger)page inCollection:(NSNumber *)collectionId sortOrder:(BUYCollectionSort)sortOrder completion:(BUYDataProductListBlock)block
{
NSURLSessionDataTask *task = nil;
if (collectionId) {
NSAssert(collectionId, @"Failed to get products page. Invalid collectionID.");
NSURLComponents *components = [self URLComponentsForChannelsAppendingPath:kBUYClientPathProductPublications
queryItems:@{
@"collection_id" : collectionId.stringValue,
......@@ -231,7 +231,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
@"sort_by" : [BUYCollection sortOrderParameterForCollectionSort:sortOrder]
}];
task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *products = nil;
if (json && !error) {
......@@ -239,12 +239,6 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
}
block(products, page, [self hasReachedEndOfPage:products] || error, error);
}];
}
else {
block(nil, 0, NO, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoCollectionIdSpecified userInfo:nil]);
}
return task;
}
#pragma mark - Helpers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment