Commit 572087a3 by David Muzi

Merge pull request #115 from Shopify/develop

Develop -> Master
parents 54cf0179 7caf1a25
...@@ -215,6 +215,57 @@ ...@@ -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 - (void)testProductsInCollection
{ {
if (self.collection == nil) { if (self.collection == nil) {
......
...@@ -125,6 +125,37 @@ ...@@ -125,6 +125,37 @@
XCTAssertEqualObjects(_checkout.billingAddress.address1, @"150 Elgin Street"); XCTAssertEqualObjects(_checkout.billingAddress.address1, @"150 Elgin Street");
} }
- (void)testCheckoutAttributesAndNotes
{
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
return [self shouldUseMocks];
} withStubResponse:^OHHTTPStubsResponse * _Nonnull(NSURLRequest * _Nonnull request) {
return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_1"];
}];
_checkout = [[BUYCheckout alloc] initWithCart:_cart];
NSString *note = @"Order note";
_checkout.note = note;
NSArray *attributes = @[ [[BUYCheckoutAttribute alloc] initWithDictionary:@{ @"name" : @"attribute1", @"value" : @"value1" }], [[BUYCheckoutAttribute alloc] initWithDictionary:@{ @"name" : @"attribute2", @"value" : @"value2" }] ];
_checkout.attributes = attributes;
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client createCheckout:_checkout completion:^(BUYCheckout *returnedCheckout, NSError *error) {
XCTAssertNil(error);
XCTAssertNotNil(returnedCheckout);
XCTAssertEqualObjects(returnedCheckout.note, note);
XCTAssertEqualObjects(returnedCheckout.attributes, attributes);
_checkout = returnedCheckout;
[expectation fulfill];
}];
[self waitForExpectationsWithTimeout:10 handler:^(NSError *error) {
XCTAssertNil(error);
}];
}
- (void)fetchShippingRates - (void)fetchShippingRates
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -178,6 +178,10 @@ ...@@ -178,6 +178,10 @@
901931691BC5B9BC00D1134E /* BUYProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A7C1A700B0A0087DB2C /* BUYProduct.h */; settings = {ATTRIBUTES = (Public, ); }; }; 901931691BC5B9BC00D1134E /* BUYProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A7C1A700B0A0087DB2C /* BUYProduct.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019316A1BC5B9BC00D1134E /* BUYSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = F76CFF1E19CB7C500079C703 /* BUYSerializable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9019316A1BC5B9BC00D1134E /* BUYSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = F76CFF1E19CB7C500079C703 /* BUYSerializable.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019316B1BC5B9BC00D1134E /* BUYProductVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A811A700B0A0087DB2C /* BUYProductVariant.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9019316B1BC5B9BC00D1134E /* BUYProductVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A811A700B0A0087DB2C /* BUYProductVariant.h */; settings = {ATTRIBUTES = (Public, ); }; };
9032F2DA1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 9032F2D81BE9457A00BB9EEF /* BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
9032F2DB1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 9032F2D81BE9457A00BB9EEF /* BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
9032F2DC1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 9032F2D91BE9457A00BB9EEF /* BUYCheckoutAttribute.m */; };
9032F2DD1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 9032F2D91BE9457A00BB9EEF /* BUYCheckoutAttribute.m */; };
903BCC7C1B7D1C2D00C21FEB /* BUYProductViewErrorView.h in Headers */ = {isa = PBXBuildFile; fileRef = 903BCC7A1B7D1C2D00C21FEB /* BUYProductViewErrorView.h */; }; 903BCC7C1B7D1C2D00C21FEB /* BUYProductViewErrorView.h in Headers */ = {isa = PBXBuildFile; fileRef = 903BCC7A1B7D1C2D00C21FEB /* BUYProductViewErrorView.h */; };
903BCC7D1B7D1C2D00C21FEB /* BUYProductViewErrorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 903BCC7B1B7D1C2D00C21FEB /* BUYProductViewErrorView.m */; }; 903BCC7D1B7D1C2D00C21FEB /* BUYProductViewErrorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 903BCC7B1B7D1C2D00C21FEB /* BUYProductViewErrorView.m */; };
904606AF1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 904606AD1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h */; }; 904606AF1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 904606AD1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h */; };
...@@ -328,11 +332,11 @@ ...@@ -328,11 +332,11 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
90DAEC341BC6E50B007555A5 /* PBXContainerItemProxy */ = { 9032F2D61BE93F3D00BB9EEF /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy; isa = PBXContainerItemProxy;
containerPortal = F773741519C770CB0039681C /* Project object */; containerPortal = F773741519C770CB0039681C /* Project object */;
proxyType = 1; proxyType = 1;
remoteGlobalIDString = BE9A64271B503C2F0033E558; remoteGlobalIDString = 901930E11BC5B9BC00D1134E;
remoteInfo = Buy; remoteInfo = Buy;
}; };
90E78A4C1BD58F0C005D16C3 /* PBXContainerItemProxy */ = { 90E78A4C1BD58F0C005D16C3 /* PBXContainerItemProxy */ = {
...@@ -378,6 +382,8 @@ ...@@ -378,6 +382,8 @@
901335451C187E0400410ED0 /* NSURLComponents+BUYAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLComponents+BUYAdditions.m"; sourceTree = "<group>"; }; 901335451C187E0400410ED0 /* NSURLComponents+BUYAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURLComponents+BUYAdditions.m"; sourceTree = "<group>"; };
901931701BC5B9BC00D1134E /* Buy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Buy.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 901931701BC5B9BC00D1134E /* Buy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Buy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
901931761BC5BC9100D1134E /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; }; 901931761BC5BC9100D1134E /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
9032F2D81BE9457A00BB9EEF /* BUYCheckoutAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYCheckoutAttribute.h; sourceTree = "<group>"; };
9032F2D91BE9457A00BB9EEF /* BUYCheckoutAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYCheckoutAttribute.m; sourceTree = "<group>"; };
903BCC7A1B7D1C2D00C21FEB /* BUYProductViewErrorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BUYProductViewErrorView.h; path = "Product View/BUYProductViewErrorView.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 903BCC7A1B7D1C2D00C21FEB /* BUYProductViewErrorView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BUYProductViewErrorView.h; path = "Product View/BUYProductViewErrorView.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
903BCC7B1B7D1C2D00C21FEB /* BUYProductViewErrorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYProductViewErrorView.m; path = "Product View/BUYProductViewErrorView.m"; sourceTree = "<group>"; }; 903BCC7B1B7D1C2D00C21FEB /* BUYProductViewErrorView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYProductViewErrorView.m; path = "Product View/BUYProductViewErrorView.m"; sourceTree = "<group>"; };
904606AD1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BUYProductImageCollectionViewCell.h; path = "Product View/BUYProductImageCollectionViewCell.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; 904606AD1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BUYProductImageCollectionViewCell.h; path = "Product View/BUYProductImageCollectionViewCell.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
...@@ -761,6 +767,8 @@ ...@@ -761,6 +767,8 @@
BEB74A1B1B5490140005A300 /* BUYCheckout_Private.h */, BEB74A1B1B5490140005A300 /* BUYCheckout_Private.h */,
F773749419C77C260039681C /* BUYCheckout.h */, F773749419C77C260039681C /* BUYCheckout.h */,
F773749519C77C260039681C /* BUYCheckout.m */, F773749519C77C260039681C /* BUYCheckout.m */,
9032F2D81BE9457A00BB9EEF /* BUYCheckoutAttribute.h */,
9032F2D91BE9457A00BB9EEF /* BUYCheckoutAttribute.m */,
BEB74A8E1B55A3D00005A300 /* BUYCollection.h */, BEB74A8E1B55A3D00005A300 /* BUYCollection.h */,
9089CC5D1BB48D06009726D6 /* BUYCollection.m */, 9089CC5D1BB48D06009726D6 /* BUYCollection.m */,
900396F41B69563400226B73 /* BUYCollection+Additions.h */, 900396F41B69563400226B73 /* BUYCollection+Additions.h */,
...@@ -941,6 +949,7 @@ ...@@ -941,6 +949,7 @@
9019315B1BC5B9BC00D1134E /* BUYImageKit.h in Headers */, 9019315B1BC5B9BC00D1134E /* BUYImageKit.h in Headers */,
9019315C1BC5B9BC00D1134E /* BUYCollection+Additions.h in Headers */, 9019315C1BC5B9BC00D1134E /* BUYCollection+Additions.h in Headers */,
9019315D1BC5B9BC00D1134E /* NSDateFormatter+BUYAdditions.h in Headers */, 9019315D1BC5B9BC00D1134E /* NSDateFormatter+BUYAdditions.h in Headers */,
9032F2DB1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */,
9019315E1BC5B9BC00D1134E /* BUYError.h in Headers */, 9019315E1BC5B9BC00D1134E /* BUYError.h in Headers */,
9019315F1BC5B9BC00D1134E /* BUYProductHeaderCell.h in Headers */, 9019315F1BC5B9BC00D1134E /* BUYProductHeaderCell.h in Headers */,
901931601BC5B9BC00D1134E /* BUYProductViewErrorView.h in Headers */, 901931601BC5B9BC00D1134E /* BUYProductViewErrorView.h in Headers */,
...@@ -1017,6 +1026,7 @@ ...@@ -1017,6 +1026,7 @@
900E7C841B5DA553006F3C81 /* BUYImageKit.h in Headers */, 900E7C841B5DA553006F3C81 /* BUYImageKit.h in Headers */,
900396F61B69563400226B73 /* BUYCollection+Additions.h in Headers */, 900396F61B69563400226B73 /* BUYCollection+Additions.h in Headers */,
90A446251B5EC03F009602AA /* NSDateFormatter+BUYAdditions.h in Headers */, 90A446251B5EC03F009602AA /* NSDateFormatter+BUYAdditions.h in Headers */,
9032F2DA1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */,
BE47340F1B66C4EF00AA721A /* BUYError.h in Headers */, BE47340F1B66C4EF00AA721A /* BUYError.h in Headers */,
BEB74A6D1B5564200005A300 /* BUYProductHeaderCell.h in Headers */, BEB74A6D1B5564200005A300 /* BUYProductHeaderCell.h in Headers */,
903BCC7C1B7D1C2D00C21FEB /* BUYProductViewErrorView.h in Headers */, 903BCC7C1B7D1C2D00C21FEB /* BUYProductViewErrorView.h in Headers */,
...@@ -1065,7 +1075,7 @@ ...@@ -1065,7 +1075,7 @@
buildRules = ( buildRules = (
); );
dependencies = ( dependencies = (
90DAEC351BC6E50B007555A5 /* PBXTargetDependency */, 9032F2D71BE93F3D00BB9EEF /* PBXTargetDependency */,
); );
name = "Mobile Buy SDK Tests"; name = "Mobile Buy SDK Tests";
productName = "Mobile Buy SDK Tests"; productName = "Mobile Buy SDK Tests";
...@@ -1244,6 +1254,7 @@ ...@@ -1244,6 +1254,7 @@
9019310E1BC5B9BC00D1134E /* BUYProduct.m in Sources */, 9019310E1BC5B9BC00D1134E /* BUYProduct.m in Sources */,
9019310F1BC5B9BC00D1134E /* BUYImageView.m in Sources */, 9019310F1BC5B9BC00D1134E /* BUYImageView.m in Sources */,
901931101BC5B9BC00D1134E /* BUYProductHeaderCell.m in Sources */, 901931101BC5B9BC00D1134E /* BUYProductHeaderCell.m in Sources */,
9032F2DD1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */,
901931111BC5B9BC00D1134E /* BUYCartLineItem.m in Sources */, 901931111BC5B9BC00D1134E /* BUYCartLineItem.m in Sources */,
901931121BC5B9BC00D1134E /* BUYMaskedCreditCard.m in Sources */, 901931121BC5B9BC00D1134E /* BUYMaskedCreditCard.m in Sources */,
901931131BC5B9BC00D1134E /* BUYCheckout.m in Sources */, 901931131BC5B9BC00D1134E /* BUYCheckout.m in Sources */,
...@@ -1339,6 +1350,7 @@ ...@@ -1339,6 +1350,7 @@
BE9A64621B503CF40033E558 /* BUYProduct.m in Sources */, BE9A64621B503CF40033E558 /* BUYProduct.m in Sources */,
BEB74A781B55646F0005A300 /* BUYImageView.m in Sources */, BEB74A781B55646F0005A300 /* BUYImageView.m in Sources */,
BEB74A6E1B5564230005A300 /* BUYProductHeaderCell.m in Sources */, BEB74A6E1B5564230005A300 /* BUYProductHeaderCell.m in Sources */,
9032F2DC1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */,
9003969C1B601DF400226B73 /* BUYCartLineItem.m in Sources */, 9003969C1B601DF400226B73 /* BUYCartLineItem.m in Sources */,
BE5DC3641B71022D00B2BC1E /* BUYMaskedCreditCard.m in Sources */, BE5DC3641B71022D00B2BC1E /* BUYMaskedCreditCard.m in Sources */,
BE9A644C1B503C9F0033E558 /* BUYCheckout.m in Sources */, BE9A644C1B503C9F0033E558 /* BUYCheckout.m in Sources */,
...@@ -1365,10 +1377,10 @@ ...@@ -1365,10 +1377,10 @@
/* End PBXSourcesBuildPhase section */ /* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */ /* Begin PBXTargetDependency section */
90DAEC351BC6E50B007555A5 /* PBXTargetDependency */ = { 9032F2D71BE93F3D00BB9EEF /* PBXTargetDependency */ = {
isa = PBXTargetDependency; isa = PBXTargetDependency;
target = BE9A64271B503C2F0033E558 /* Buy Static */; target = 901930E11BC5B9BC00D1134E /* Buy */;
targetProxy = 90DAEC341BC6E50B007555A5 /* PBXContainerItemProxy */; targetProxy = 9032F2D61BE93F3D00BB9EEF /* PBXContainerItemProxy */;
}; };
90E78A4D1BD58F0C005D16C3 /* PBXTargetDependency */ = { 90E78A4D1BD58F0C005D16C3 /* PBXTargetDependency */ = {
isa = PBXTargetDependency; isa = PBXTargetDependency;
...@@ -1384,7 +1396,7 @@ ...@@ -1384,7 +1396,7 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1.2.4; CURRENT_PROJECT_VERSION = 1.2.6;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
...@@ -1417,7 +1429,7 @@ ...@@ -1417,7 +1429,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.2.4; CURRENT_PROJECT_VERSION = 1.2.6;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
...@@ -1540,7 +1552,7 @@ ...@@ -1540,7 +1552,7 @@
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1.2.4; CURRENT_PROJECT_VERSION = 1.2.6;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
...@@ -1573,7 +1585,7 @@ ...@@ -1573,7 +1585,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1.2.4; CURRENT_PROJECT_VERSION = 1.2.6;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES; DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_COMPATIBILITY_VERSION = 1;
......
...@@ -35,6 +35,7 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[]; ...@@ -35,6 +35,7 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYAddress.h> #import <Buy/BUYAddress.h>
#import <Buy/BUYCart.h> #import <Buy/BUYCart.h>
#import <Buy/BUYCheckout.h> #import <Buy/BUYCheckout.h>
#import <Buy/BUYCheckoutAttribute.h>
#import <Buy/BUYCreditCard.h> #import <Buy/BUYCreditCard.h>
#import <Buy/BUYDiscount.h> #import <Buy/BUYDiscount.h>
#import <Buy/BUYGiftCard.h> #import <Buy/BUYGiftCard.h>
......
...@@ -152,6 +152,14 @@ typedef void (^BUYDataShippingRatesBlock)(NSArray *shippingRates, BUYStatus stat ...@@ -152,6 +152,14 @@ typedef void (^BUYDataShippingRatesBlock)(NSArray *shippingRates, BUYStatus stat
typedef void (^BUYDataShopBlock)(BUYShop *shop, NSError *error); 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 * Return block containing a BUYProduct and/or an NSError
* *
* @param product A BUYProduct * @param product A BUYProduct
...@@ -165,15 +173,17 @@ typedef void (^BUYDataProductBlock)(BUYProduct *product, NSError *error); ...@@ -165,15 +173,17 @@ typedef void (^BUYDataProductBlock)(BUYProduct *product, NSError *error);
* @param products An array of BUYProduct objects * @param products An array of BUYProduct objects
* @param error Optional NSError * @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 * Return block containing a list of BUYCollection objects
* *
* @param collections An array of BUYCollection objects * @param collections An array of BUYCollection objects
* @param error Optional NSError * @param page Index of the page requested
* @param reachedEnd Boolean indicating whether additional pages exist
* @param error An optional NSError
*/ */
typedef void (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error); typedef void (^BUYDataCollectionsListBlock)(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 * 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 +193,7 @@ typedef void (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error); ...@@ -183,7 +193,7 @@ typedef void (^BUYDataCollectionsBlock)(NSArray *collections, NSError *error);
* @param reachedEnd Boolean indicating whether additional pages exist * @param reachedEnd Boolean indicating whether additional pages exist
* @param error An optional NSError * @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 * Return block containing a list of BUYProductImage objects and/or an NSError
...@@ -314,6 +324,16 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error); ...@@ -314,6 +324,16 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
- (NSURLSessionDataTask *)getCollections:(BUYDataCollectionsBlock)block; - (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 * Fetches the products in the given collection with the collection's
* default sort order set in the shop's admin * default sort order set in the shop's admin
* *
......
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
#define kMinSuccessfulStatusCode 200 #define kMinSuccessfulStatusCode 200
#define kMaxSuccessfulStatusCode 299 #define kMaxSuccessfulStatusCode 299
NSString * const BUYVersionString = @"1.2.4"; NSString * const BUYVersionString = @"1.2.6";
static NSString *const kBUYClientPathProductPublications = @"product_publications"; static NSString *const kBUYClientPathProductPublications = @"product_publications";
static NSString *const kBUYClientPathCollectionPublications = @"collection_publications"; static NSString *const kBUYClientPathCollectionPublications = @"collection_publications";
...@@ -88,16 +88,23 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_publi ...@@ -88,16 +88,23 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_publi
self.channelId = channelId; self.channelId = channelId;
self.applicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"] ?: @""; self.applicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"] ?: @"";
self.queue = dispatch_get_main_queue(); self.queue = dispatch_get_main_queue();
self.session = [self createUrlSession];
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
config.HTTPAdditionalHeaders = @{@"User-Agent": [NSString stringWithFormat:@"Mobile Buy SDK iOS/%@", BUYVersionString]};
self.session = [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
self.pageSize = 25; self.pageSize = 25;
} }
return self; return self;
} }
- (NSURLSession *)createUrlSession
{
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
config.HTTPAdditionalHeaders = @{@"User-Agent": [NSString stringWithFormat:@"Mobile Buy SDK iOS/%@/%@", BUYVersionString, bundleIdentifier]};
return [NSURLSession sessionWithConfiguration:config delegate:self delegateQueue:nil];
}
#pragma mark - Storefront #pragma mark - Storefront
- (void)setPageSize:(NSUInteger)pageSize - (void)setPageSize:(NSUInteger)pageSize
...@@ -173,15 +180,23 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_publi ...@@ -173,15 +180,23 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_publi
- (NSURLSessionDataTask *)getCollections:(BUYDataCollectionsBlock)block - (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) { return [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *collections = nil; NSArray *collections = nil;
if (json && error == nil) { if (json && error == nil) {
collections = [BUYCollection convertJSONArray:json[kBUYClientPathCollectionPublications]]; collections = [BUYCollection convertJSONArray:json[kBUYClientPathCollectionPublications]];
} }
block(collections, error); block(collections, page, [self hasReachedEndOfPage:collections], error);
}]; }];
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>FMWK</string> <string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.2.4</string> <string>1.2.6</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
@class BUYTaxLine; @class BUYTaxLine;
@class BUYLineItem; @class BUYLineItem;
@class BUYGiftCard; @class BUYGiftCard;
@class BUYCheckoutAttribute;
/** /**
* The checkout object. This is the main object that you will interact with when creating orders on Shopify. * The checkout object. This is the main object that you will interact with when creating orders on Shopify.
...@@ -236,7 +237,7 @@ ...@@ -236,7 +237,7 @@
/** /**
* Customer ID associated with the checkout * Customer ID associated with the checkout
*/ */
@property (nonatomic, copy, readonly) NSString *customerId; @property (nonatomic, copy, readonly) NSNumber *customerId;
/** /**
* An optional note attached to the order * An optional note attached to the order
...@@ -244,6 +245,11 @@ ...@@ -244,6 +245,11 @@
@property (nonatomic, copy) NSString *note; @property (nonatomic, copy) NSString *note;
/** /**
* Extra information that is added to the order
*/
@property (nonatomic, copy) NSArray <BUYCheckoutAttribute *> *attributes;
/**
* The BUYOrder for a completed checkout * The BUYOrder for a completed checkout
*/ */
@property (nonatomic, strong, readonly) BUYOrder *order; @property (nonatomic, strong, readonly) BUYOrder *order;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#import "NSDateFormatter+BUYAdditions.h" #import "NSDateFormatter+BUYAdditions.h"
#import "NSURL+BUYAdditions.h" #import "NSURL+BUYAdditions.h"
#import "NSDictionary+Additions.h" #import "NSDictionary+Additions.h"
#import "BUYCheckoutAttribute.h"
@implementation BUYCheckout @implementation BUYCheckout
...@@ -146,6 +147,7 @@ ...@@ -146,6 +147,7 @@
self.creditCard = [BUYMaskedCreditCard convertObject:dictionary[@"credit_card"]]; self.creditCard = [BUYMaskedCreditCard convertObject:dictionary[@"credit_card"]];
self.customerId = [dictionary buy_objectForKey:@"customer_id"]; self.customerId = [dictionary buy_objectForKey:@"customer_id"];
self.note = dictionary[@"note"]; self.note = dictionary[@"note"];
self.attributes = [BUYCheckoutAttribute convertJSONArray:dictionary[@"attributes"]];
self.privacyPolicyURL = [NSURL buy_urlWithString:dictionary[@"privacy_policy_url"]]; self.privacyPolicyURL = [NSURL buy_urlWithString:dictionary[@"privacy_policy_url"]];
self.refundPolicyURL = [NSURL buy_urlWithString:dictionary[@"refund_policy_url"]]; self.refundPolicyURL = [NSURL buy_urlWithString:dictionary[@"refund_policy_url"]];
...@@ -181,13 +183,22 @@ ...@@ -181,13 +183,22 @@
- (NSDictionary *)jsonDictionaryForCheckout - (NSDictionary *)jsonDictionaryForCheckout
{ {
//We only need the dirty properties // We only need the dirty properties
NSSet *dirtyProperties = [self dirtyProperties]; NSSet *dirtyProperties = [self dirtyProperties];
NSMutableDictionary *json = [[NSMutableDictionary alloc] init]; NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
for (NSString *dirtyProperty in dirtyProperties) { for (NSString *dirtyProperty in dirtyProperties) {
id value = [self jsonValueForValue:[self valueForKey:dirtyProperty]]; id value = [self jsonValueForValue:[self valueForKey:dirtyProperty]];
json[[BUYCheckout jsonKeyForProperty:dirtyProperty]] = value ?: [NSNull null]; json[[BUYCheckout jsonKeyForProperty:dirtyProperty]] = value ?: [NSNull null];
} }
// We need to serialize the attributes as they need to be posted as a dictionary
if (json[@"attributes"]) {
NSMutableDictionary *attributeDictionary = [[NSMutableDictionary alloc] init];
for (NSDictionary *attribute in json[@"attributes"]) {
attributeDictionary[[attribute allKeys][0]] = [attribute allValues][0];
}
json[@"attributes"] = attributeDictionary;
}
return @{ @"checkout" : json }; return @{ @"checkout" : json };
} }
......
//
// BUYCheckoutAttribute.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2016 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
/**
* A BUYCheckoutAttribute represents a checkout attributes key and value
*/
@interface BUYCheckoutAttribute : BUYObject <BUYSerializable>
/**
* The attribute name
*/
@property (nonatomic, strong, nonnull) NSString *name;
/**
* The attribute value
*/
@property (nonatomic, strong, nonnull) NSString *value;
@end
//
// BUYCheckoutAttribute.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2016 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "BUYCheckoutAttribute.h"
@implementation BUYCheckoutAttribute
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
self.name = dictionary[@"name"];
self.value = dictionary[@"value"];
}
- (NSDictionary *)jsonDictionaryForCheckout
{
return @{ self.name : self.value };
}
- (BOOL)isEqual:(id)object
{
BOOL same = NO;
if (self == object) {
same = YES;
} else if ([object isKindOfClass:self.class]) {
BUYCheckoutAttribute *attribute = (BUYCheckoutAttribute *)object;
same = ([self.name isEqualToString:attribute.name] && [self.value isEqualToString:attribute.value]);
}
return same;
}
- (NSUInteger)hash
{
return [self.name hash] ^ [self.value hash];
}
@end
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
@property (nonatomic, copy) NSDate *updatedAtDate; @property (nonatomic, copy) NSDate *updatedAtDate;
@property (nonatomic, strong) BUYMaskedCreditCard *creditCard; @property (nonatomic, strong) BUYMaskedCreditCard *creditCard;
@property (nonatomic, strong) BUYOrder *order; @property (nonatomic, strong) BUYOrder *order;
@property (nonatomic, copy) NSString *customerId; @property (nonatomic, copy) NSNumber *customerId;
@property (nonatomic, strong) NSURL *privacyPolicyURL; @property (nonatomic, strong) NSURL *privacyPolicyURL;
@property (nonatomic, strong) NSURL *refundPolicyURL; @property (nonatomic, strong) NSURL *refundPolicyURL;
@property (nonatomic, strong) NSURL *termsOfServiceURL; @property (nonatomic, strong) NSURL *termsOfServiceURL;
......
...@@ -32,7 +32,7 @@ NSString * const BUYShopifyError = @"BUYShopifyError"; ...@@ -32,7 +32,7 @@ NSString * const BUYShopifyError = @"BUYShopifyError";
- (NSString *)description - (NSString *)description
{ {
return [[self userInfo] description]; return [NSString stringWithFormat:@"Error code %td: %@", self.code, [self userInfo]];
} }
@end @end
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#import "BUYProductVariant.h" #import "BUYProductVariant.h"
#import "NSDecimalNumber+BUYAdditions.h" #import "NSDecimalNumber+BUYAdditions.h"
#import "NSString+Trim.h" #import "NSString+Trim.h"
#import "BUYProduct.h"
@interface BUYLineItem () @interface BUYLineItem ()
...@@ -54,6 +55,7 @@ ...@@ -54,6 +55,7 @@
self = [super init]; self = [super init];
if (self) { if (self) {
self.variantId = variant.identifier; self.variantId = variant.identifier;
self.productId = variant.product.productId;
self.quantity = variant ? [NSDecimalNumber one] : [NSDecimalNumber zero]; self.quantity = variant ? [NSDecimalNumber one] : [NSDecimalNumber zero];
self.price = variant ? [variant price] : [NSDecimalNumber zero]; self.price = variant ? [variant price] : [NSDecimalNumber zero];
self.title = variant ? [variant title] : @""; self.title = variant ? [variant title] : @"";
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#import "BUYCart.h" #import "BUYCart.h"
#import "BUYCartLineItem.h" #import "BUYCartLineItem.h"
#import "BUYCheckout.h" #import "BUYCheckout.h"
#import "BUYCheckoutAttribute.h"
#import "BUYClient+Test.h" #import "BUYClient+Test.h"
#import "BUYClient.h" #import "BUYClient.h"
#import "BUYCollection.h" #import "BUYCollection.h"
......
...@@ -331,8 +331,10 @@ const NSTimeInterval PollDelay = 0.5; ...@@ -331,8 +331,10 @@ const NSTimeInterval PollDelay = 0.5;
[NSThread sleepForTimeInterval:PollDelay]; [NSThread sleepForTimeInterval:PollDelay];
} }
} }
dispatch_async(dispatch_get_main_queue(), ^{
completion(checkoutStatus == BUYStatusComplete ? PKPaymentAuthorizationStatusSuccess : PKPaymentAuthorizationStatusFailure); completion(checkoutStatus == BUYStatusComplete ? PKPaymentAuthorizationStatusSuccess : PKPaymentAuthorizationStatusFailure);
}); });
});
} }
@end @end
...@@ -147,7 +147,7 @@ NSString * BUYURLKey = @"url"; ...@@ -147,7 +147,7 @@ NSString * BUYURLKey = @"url";
__block NSError *checkoutError = nil; __block NSError *checkoutError = nil;
// download the shop // download the shop
if (self.shop != nil) { if (self.shop == nil) {
dispatch_group_enter(group); dispatch_group_enter(group);
[self loadShopWithCallback:^(BOOL success, NSError *error) { [self loadShopWithCallback:^(BOOL success, NSError *error) {
......
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'Mobile-Buy-SDK' s.name = 'Mobile-Buy-SDK'
s.version = '1.2.5' s.version = '1.2.6'
s.summary = 'Sell with Shopify in iOS apps' s.summary = 'Sell with Shopify in iOS apps'
s.description = 'Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.' s.description = 'Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using Apple Pay or their credit card.'
s.homepage = 'https://developers.shopify.com/mobile-buy-sdk' s.homepage = 'https://developers.shopify.com/mobile-buy-sdk'
......
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