Commit 846f4050 by Gabriel O'Flaherty-Chan

Merge pull request #189 from Shopify/task/merchant-app-integration

Merchant app integration 
parents d4a6e276 1b1299df
...@@ -87,11 +87,11 @@ ...@@ -87,11 +87,11 @@
XCTAssertNotNil(json); XCTAssertNotNil(json);
XCTAssertEqual(json.count, 1); XCTAssertEqual(json.count, 1);
XCTAssertNotNil(customer); XCTAssertNotNil(customer);
XCTAssertEqual(customer[@"email"], @"john@doe.com"); XCTAssertEqual(customer[BUYAccountEmailKey], @"john@doe.com");
XCTAssertEqual(customer[@"first_name"], @"John"); XCTAssertEqual(customer[BUYAccountFirstNameKey], @"John");
XCTAssertEqual(customer[@"last_name"], @"Doe"); XCTAssertEqual(customer[BUYAccountLastNameKey], @"Doe");
XCTAssertEqual(customer[@"password"], @"pass"); XCTAssertEqual(customer[BUYAccountPasswordKey], @"pass");
XCTAssertEqual(customer[@"password_confirmation"], @"pass"); XCTAssertEqual(customer[BUYAccountPasswordConfirmationKey], @"pass");
} }
#pragma mark - Utilities - #pragma mark - Utilities -
......
...@@ -309,11 +309,11 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg"; ...@@ -309,11 +309,11 @@ NSString * const BUYFakeCustomerToken = @"dsfasdgafdg";
XCTAssertNil(error); XCTAssertNil(error);
NSDictionary *dict = @{@"customer": @{ NSDictionary *dict = @{@"customer": @{
@"first_name": @"michael", BUYAccountFirstNameKey: @"michael",
@"last_name": @"scott", BUYAccountLastNameKey: @"scott",
@"email": @"fake@example.com", BUYAccountEmailKey: @"fake@example.com",
@"password": @"password", BUYAccountPasswordKey: @"password",
@"password_confirmation": @"password" BUYAccountPasswordConfirmationKey: @"password"
}}; }};
XCTAssertEqualObjects(payload, dict); XCTAssertEqualObjects(payload, dict);
} }
......
...@@ -181,7 +181,7 @@ ...@@ -181,7 +181,7 @@
XCTAssertNotNil([collections.firstObject title]); XCTAssertNotNil([collections.firstObject title]);
XCTAssertNotNil([collections.firstObject handle]); XCTAssertNotNil([collections.firstObject handle]);
XCTAssertNotNil([collections.firstObject collectionId]); XCTAssertNotNil([collections.firstObject identifier]);
self.collection = collections.firstObject; self.collection = collections.firstObject;
[expectation fulfill]; [expectation fulfill];
...@@ -205,7 +205,7 @@ ...@@ -205,7 +205,7 @@
XCTAssertNotNil([collections.firstObject title]); XCTAssertNotNil([collections.firstObject title]);
XCTAssertNotNil([collections.firstObject handle]); XCTAssertNotNil([collections.firstObject handle]);
XCTAssertNotNil([collections.firstObject collectionId]); XCTAssertNotNil([collections.firstObject identifier]);
[expectation fulfill]; [expectation fulfill];
}]; }];
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client getProductsPage:1 inCollection:self.collection.collectionId completion:^(NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error) { [self.client getProductsPage:1 inCollection:self.collection.identifier completion:^(NSArray *products, NSUInteger page, BOOL reachedEnd, NSError *error) {
XCTAssertNil(error); XCTAssertNil(error);
XCTAssertNotNil(products); XCTAssertNotNil(products);
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
_modelManager = [BUYModelManager modelManager]; _modelManager = [BUYModelManager modelManager];
_variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1, @"requires_shipping" : @YES }]; _variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1, @"requires_shipping" : @YES }];
_lineItem = [[BUYLineItem alloc] initWithVariant:_variant]; _lineItem = [_modelManager lineItemWithVariant:_variant];
} }
- (void)tearDown - (void)tearDown
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
- (void)testJsonDictionaryShouldShowAllProperties - (void)testJsonDictionaryShouldShowAllProperties
{ {
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @5 }]; BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @5 }];
_lineItem = [[BUYLineItem alloc] initWithVariant:variant]; _lineItem = [_modelManager lineItemWithVariant:variant];
_lineItem.quantity = [NSDecimalNumber decimalNumberWithString:@"3"]; _lineItem.quantity = [NSDecimalNumber decimalNumberWithString:@"3"];
_lineItem.price = [NSDecimalNumber decimalNumberWithString:@"5.55"]; _lineItem.price = [NSDecimalNumber decimalNumberWithString:@"5.55"];
_lineItem.title = @"banana"; _lineItem.title = @"banana";
......
...@@ -157,10 +157,6 @@ ...@@ -157,10 +157,6 @@
84B0A73B1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B0A72E1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; 84B0A73B1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B0A72E1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h */; settings = {ATTRIBUTES = (Public, ); }; };
84B0A73C1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */; }; 84B0A73C1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */; };
84B0A73D1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */; }; 84B0A73D1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */; };
84B0A7401CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B0A73E1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h */; };
84B0A7411CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B0A73E1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h */; };
84B0A7421CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A73F1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m */; };
84B0A7431CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = 84B0A73F1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m */; };
84CD7C2D1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; }; 84CD7C2D1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
84CD7C2E1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; }; 84CD7C2E1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */; settings = {ATTRIBUTES = (Public, ); }; };
84CD7C2F1CC65D7B00B6EE61 /* _BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */; }; 84CD7C2F1CC65D7B00B6EE61 /* _BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */; };
...@@ -556,8 +552,6 @@ ...@@ -556,8 +552,6 @@
84B0A72D1CE10ED900253EB0 /* BUYPaymentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYPaymentProvider.h; sourceTree = "<group>"; }; 84B0A72D1CE10ED900253EB0 /* BUYPaymentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYPaymentProvider.h; sourceTree = "<group>"; };
84B0A72E1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYWebCheckoutPaymentProvider.h; sourceTree = "<group>"; }; 84B0A72E1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYWebCheckoutPaymentProvider.h; sourceTree = "<group>"; };
84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYWebCheckoutPaymentProvider.m; sourceTree = "<group>"; }; 84B0A72F1CE10ED900253EB0 /* BUYWebCheckoutPaymentProvider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYWebCheckoutPaymentProvider.m; sourceTree = "<group>"; };
84B0A73E1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BUYClient+CheckoutHelpers.h"; sourceTree = "<group>"; };
84B0A73F1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYClient+CheckoutHelpers.m"; sourceTree = "<group>"; };
84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _BUYCheckoutAttribute.h; sourceTree = "<group>"; }; 84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _BUYCheckoutAttribute.h; sourceTree = "<group>"; };
84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _BUYCheckoutAttribute.m; sourceTree = "<group>"; }; 84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _BUYCheckoutAttribute.m; sourceTree = "<group>"; };
84D73BFE1CDD1931000F978A /* _BUYAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _BUYAddress.h; sourceTree = "<group>"; }; 84D73BFE1CDD1931000F978A /* _BUYAddress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _BUYAddress.h; sourceTree = "<group>"; };
...@@ -924,8 +918,6 @@ ...@@ -924,8 +918,6 @@
84B0A7281CE10ED900253EB0 /* Payment Providers */ = { 84B0A7281CE10ED900253EB0 /* Payment Providers */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
84B0A73E1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h */,
84B0A73F1CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m */,
84B0A7291CE10ED900253EB0 /* BUYApplePayPaymentProvider.h */, 84B0A7291CE10ED900253EB0 /* BUYApplePayPaymentProvider.h */,
84B0A72A1CE10ED900253EB0 /* BUYApplePayPaymentProvider.m */, 84B0A72A1CE10ED900253EB0 /* BUYApplePayPaymentProvider.m */,
84B0A72B1CE10ED900253EB0 /* BUYPaymentController.h */, 84B0A72B1CE10ED900253EB0 /* BUYPaymentController.h */,
...@@ -1238,7 +1230,6 @@ ...@@ -1238,7 +1230,6 @@
9A0B0C731CEB52B90037D68F /* BUYClient+Checkout.h in Headers */, 9A0B0C731CEB52B90037D68F /* BUYClient+Checkout.h in Headers */,
84DD12A11CC63FE600A2442D /* _BUYImageLink.h in Headers */, 84DD12A11CC63FE600A2442D /* _BUYImageLink.h in Headers */,
84DD12A51CC63FE600A2442D /* _BUYOption.h in Headers */, 84DD12A51CC63FE600A2442D /* _BUYOption.h in Headers */,
84B0A7411CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h in Headers */,
84D73C041CDD1945000F978A /* _BUYAddress.h in Headers */, 84D73C041CDD1945000F978A /* _BUYAddress.h in Headers */,
84DD12C31CC63FEE00A2442D /* _BUYDiscount.h in Headers */, 84DD12C31CC63FEE00A2442D /* _BUYDiscount.h in Headers */,
84DD12A71CC63FE600A2442D /* _BUYOptionValue.h in Headers */, 84DD12A71CC63FE600A2442D /* _BUYOptionValue.h in Headers */,
...@@ -1271,9 +1262,6 @@ ...@@ -1271,9 +1262,6 @@
9A807E841CF74EBE00023160 /* BUYClient+Address.h in Headers */, 9A807E841CF74EBE00023160 /* BUYClient+Address.h in Headers */,
84980F531CB7616900CFAB58 /* BUYDecimalNumberTransformer.h in Headers */, 84980F531CB7616900CFAB58 /* BUYDecimalNumberTransformer.h in Headers */,
901931421BC5B9BC00D1134E /* BUYMaskedCreditCard.h in Headers */, 901931421BC5B9BC00D1134E /* BUYMaskedCreditCard.h in Headers */,
8498DCB61CDD1B5400BD12A8 /* BUYClient+Internal.h in Headers */,
8498DCB61CDD1B5400BD12A8 /* BUYClient+Internal.h in Headers */,
8498DCB61CDD1B5400BD12A8 /* BUYClient+Internal.h in Headers */,
841ADE201CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */, 841ADE201CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */,
841ADE241CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */, 841ADE241CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */,
B2653EC41CEF55CC0012D57D /* BUYModelManager+ApplePay.h in Headers */, B2653EC41CEF55CC0012D57D /* BUYModelManager+ApplePay.h in Headers */,
...@@ -1341,7 +1329,6 @@ ...@@ -1341,7 +1329,6 @@
9A0B0C721CEB52B90037D68F /* BUYClient+Checkout.h in Headers */, 9A0B0C721CEB52B90037D68F /* BUYClient+Checkout.h in Headers */,
84DD12811CC63FE600A2442D /* _BUYCart.h in Headers */, 84DD12811CC63FE600A2442D /* _BUYCart.h in Headers */,
84DD12851CC63FE600A2442D /* _BUYCollection.h in Headers */, 84DD12851CC63FE600A2442D /* _BUYCollection.h in Headers */,
84B0A7401CE10F8100253EB0 /* BUYClient+CheckoutHelpers.h in Headers */,
84D73C021CDD1944000F978A /* _BUYAddress.h in Headers */, 84D73C021CDD1944000F978A /* _BUYAddress.h in Headers */,
84DD12891CC63FE600A2442D /* _BUYImageLink.h in Headers */, 84DD12891CC63FE600A2442D /* _BUYImageLink.h in Headers */,
84DD128D1CC63FE600A2442D /* _BUYOption.h in Headers */, 84DD128D1CC63FE600A2442D /* _BUYOption.h in Headers */,
...@@ -1691,7 +1678,6 @@ ...@@ -1691,7 +1678,6 @@
9A807E861CF74EBE00023160 /* BUYClient+Address.m in Sources */, 9A807E861CF74EBE00023160 /* BUYClient+Address.m in Sources */,
901931161BC5B9BC00D1134E /* BUYShippingRate.m in Sources */, 901931161BC5B9BC00D1134E /* BUYShippingRate.m in Sources */,
841ADE061CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */, 841ADE061CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */,
84B0A7431CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m in Sources */,
84B0A7371CE10ED900253EB0 /* BUYPaymentController.m in Sources */, 84B0A7371CE10ED900253EB0 /* BUYPaymentController.m in Sources */,
9019311C1BC5B9BC00D1134E /* BUYOption.m in Sources */, 9019311C1BC5B9BC00D1134E /* BUYOption.m in Sources */,
84D73C081CDD194D000F978A /* _BUYAddress.m in Sources */, 84D73C081CDD194D000F978A /* _BUYAddress.m in Sources */,
...@@ -1834,7 +1820,6 @@ ...@@ -1834,7 +1820,6 @@
9A807E851CF74EBE00023160 /* BUYClient+Address.m in Sources */, 9A807E851CF74EBE00023160 /* BUYClient+Address.m in Sources */,
BE9A644E1B503CA60033E558 /* BUYShippingRate.m in Sources */, BE9A644E1B503CA60033E558 /* BUYShippingRate.m in Sources */,
841ADE051CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */, 841ADE051CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */,
84B0A7421CE10F8100253EB0 /* BUYClient+CheckoutHelpers.m in Sources */,
84B0A7361CE10ED900253EB0 /* BUYPaymentController.m in Sources */, 84B0A7361CE10ED900253EB0 /* BUYPaymentController.m in Sources */,
BE9A64601B503CEC0033E558 /* BUYOption.m in Sources */, BE9A64601B503CEC0033E558 /* BUYOption.m in Sources */,
84D73C061CDD194D000F978A /* _BUYAddress.m in Sources */, 84D73C061CDD194D000F978A /* _BUYAddress.m in Sources */,
......
...@@ -61,4 +61,9 @@ ...@@ -61,4 +61,9 @@
*/ */
- (void)buy_updateObject:(id<BUYObject>)object withJSON:(NSDictionary *)JSON; - (void)buy_updateObject:(id<BUYObject>)object withJSON:(NSDictionary *)JSON;
/**
* Convenience to access JSONPropertyKey for the "identifier" attribute
*/
@property (strong, nonatomic, readonly) NSString *JSONIdentifierKey;
@end @end
...@@ -177,4 +177,11 @@ ...@@ -177,4 +177,11 @@
[object setValuesForKeysWithDictionary:results]; [object setValuesForKeysWithDictionary:results];
} }
- (NSString *)JSONIdentifierKey
{
NSAttributeDescription *attributeDescription = self.attributesByName[@"identifier"];
return attributeDescription.JSONPropertyKey ?: @"id";
}
@end @end
...@@ -71,6 +71,16 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError * ...@@ -71,6 +71,16 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard * _Nullable giftCard, NSError *
@interface BUYClient (Checkout) @interface BUYClient (Checkout)
/** /**
* Updates or create a checkout based on wether or not it has a token
*
* @param checkout BUYCheckout to create or update
* @param completion (^BUYDataCheckoutBlock)(BUYCheckout *checkout, NSError *error)
*
* @return The associated BUYRequestOperation
*/
- (BUYRequestOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion;
/**
* Builds a checkout on Shopify. The checkout object is used to prepare an order * Builds a checkout on Shopify. The checkout object is used to prepare an order
* *
* @param checkout BUYCheckout to create on Shopify * @param checkout BUYCheckout to create on Shopify
......
...@@ -64,6 +64,16 @@ ...@@ -64,6 +64,16 @@
} }
} }
- (BUYRequestOperation *)updateOrCreateCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion
{
if ([checkout hasToken]) {
return [self updateCheckout:checkout completion:completion];
} else {
return [self createCheckout:checkout completion:completion];
}
}
- (BUYRequestOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block - (BUYRequestOperation *)createCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)block
{ {
BUYAssert(checkout, @"Failed to create checkout. Invalid checkout object."); BUYAssert(checkout, @"Failed to create checkout. Invalid checkout object.");
......
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
}]; }];
} }
else { else {
BUYCustomer *customer = [self.modelManager customerWithJSONDictionary:json[@"customer"]]; BUYCustomer *customer = [self.modelManager customerWithJSONDictionary:customerJSON];
block(customer, self.customerToken, error); block(customer, self.customerToken, error);
} }
} }
......
...@@ -27,6 +27,12 @@ ...@@ -27,6 +27,12 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
OBJC_EXTERN NSString * const BUYAccountFirstNameKey;
OBJC_EXTERN NSString * const BUYAccountLastNameKey;
OBJC_EXTERN NSString * const BUYAccountEmailKey;
OBJC_EXTERN NSString * const BUYAccountPasswordKey;
OBJC_EXTERN NSString * const BUYAccountPasswordConfirmationKey;
@class BUYAccountCredentialItem; @class BUYAccountCredentialItem;
/** /**
...@@ -55,9 +61,9 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -55,9 +61,9 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@interface BUYAccountCredentialItem : NSObject @interface BUYAccountCredentialItem : NSObject
@property (nonatomic, assign, readonly, getter=isValid) BOOL valid; @property (nonatomic, assign, getter=isValid) BOOL valid;
@property (nonatomic, strong, readonly) NSString *key; @property (nonatomic, strong, readonly) NSString *key;
@property (nonatomic, strong, readonly) NSString *value; @property (nonatomic, strong) NSString *value;
+ (instancetype)itemWithEmail:(NSString *)value; + (instancetype)itemWithEmail:(NSString *)value;
+ (instancetype)itemWithFirstName:(NSString *)value; + (instancetype)itemWithFirstName:(NSString *)value;
......
...@@ -27,11 +27,11 @@ ...@@ -27,11 +27,11 @@
#import "BUYAccountCredentials.h" #import "BUYAccountCredentials.h"
#import "BUYAssert.h" #import "BUYAssert.h"
static NSString * const BUYAccountFirstNameKey = @"first_name"; NSString * const BUYAccountFirstNameKey = @"first_name";
static NSString * const BUYAccountLastNameKey = @"last_name"; NSString * const BUYAccountLastNameKey = @"last_name";
static NSString * const BUYAccountEmailKey = @"email"; NSString * const BUYAccountEmailKey = @"email";
static NSString * const BUYAccountPasswordKey = @"password"; NSString * const BUYAccountPasswordKey = @"password";
static NSString * const BUYAccountPasswordConfirmationKey = @"password_confirmation"; NSString * const BUYAccountPasswordConfirmationKey = @"password_confirmation";
#pragma mark - BUYAccountCredentials - #pragma mark - BUYAccountCredentials -
@interface BUYAccountCredentials() @interface BUYAccountCredentials()
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10171" systemVersion="15E65" minimumToolsVersion="Xcode 7.0"> <model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10174" systemVersion="15F34" minimumToolsVersion="Xcode 7.0">
<entity name="Address" representedClassName="BUYAddress" syncable="YES"> <entity name="Address" representedClassName="BUYAddress" syncable="YES">
<attribute name="address1" optional="YES" attributeType="String" syncable="YES"> <attribute name="address1" optional="YES" attributeType="String" syncable="YES">
<userInfo> <userInfo>
...@@ -314,11 +314,6 @@ ...@@ -314,11 +314,6 @@
</userInfo> </userInfo>
</entity> </entity>
<entity name="Collection" representedClassName="BUYCollection" syncable="YES"> <entity name="Collection" representedClassName="BUYCollection" syncable="YES">
<attribute name="collectionId" optional="YES" attributeType="Integer 64" defaultValueString="0" syncable="YES">
<userInfo>
<entry key="documentation" value="The unique collection ID in the channel."/>
</userInfo>
</attribute>
<attribute name="createdAt" optional="YES" attributeType="Date" syncable="YES"/> <attribute name="createdAt" optional="YES" attributeType="Date" syncable="YES"/>
<attribute name="handle" optional="YES" attributeType="String" syncable="YES"> <attribute name="handle" optional="YES" attributeType="String" syncable="YES">
<userInfo> <userInfo>
...@@ -332,7 +327,12 @@ ...@@ -332,7 +327,12 @@
<entry key="JSONPropertyKey" value="body_html"/> <entry key="JSONPropertyKey" value="body_html"/>
</userInfo> </userInfo>
</attribute> </attribute>
<attribute name="identifier" optional="YES" attributeType="Integer 64" defaultValueString="0" indexed="YES" syncable="YES"/> <attribute name="identifier" optional="YES" attributeType="Integer 64" defaultValueString="0" indexed="YES" syncable="YES">
<userInfo>
<entry key="documentation" value="Maps to collection_id in the JSON"/>
<entry key="JSONPropertyKey" value="collection_id"/>
</userInfo>
</attribute>
<attribute name="published" optional="YES" attributeType="Boolean" syncable="YES"> <attribute name="published" optional="YES" attributeType="Boolean" syncable="YES">
<userInfo> <userInfo>
<entry key="documentation" value="The state of whether the collection is currently published or not."/> <entry key="documentation" value="The state of whether the collection is currently published or not."/>
...@@ -694,10 +694,10 @@ ...@@ -694,10 +694,10 @@
<entry key="JSONPropertyKey" value="body_html"/> <entry key="JSONPropertyKey" value="body_html"/>
</userInfo> </userInfo>
</attribute> </attribute>
<attribute name="identifier" optional="YES" attributeType="Integer 64" defaultValueString="0" indexed="YES" syncable="YES"/> <attribute name="identifier" optional="YES" attributeType="Integer 64" defaultValueString="0" indexed="YES" syncable="YES">
<attribute name="productId" optional="YES" attributeType="Integer 64" defaultValueString="0" indexed="YES" syncable="YES">
<userInfo> <userInfo>
<entry key="documentation" value="The channel product ID."/> <entry key="documentation" value="Maps to product_id in the JSON"/>
<entry key="JSONPropertyKey" value="product_id"/>
</userInfo> </userInfo>
</attribute> </attribute>
<attribute name="productType" optional="YES" attributeType="String" syncable="YES"> <attribute name="productType" optional="YES" attributeType="String" syncable="YES">
...@@ -994,7 +994,7 @@ ...@@ -994,7 +994,7 @@
<element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/> <element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/>
<element name="Checkout" positionX="333" positionY="442" width="128" height="630"/> <element name="Checkout" positionX="333" positionY="442" width="128" height="630"/>
<element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/> <element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/>
<element name="Collection" positionX="-963" positionY="772" width="128" height="210"/> <element name="Collection" positionX="-963" positionY="772" width="128" height="195"/>
<element name="Customer" positionX="106" positionY="1263" width="128" height="330"/> <element name="Customer" positionX="106" positionY="1263" width="128" height="330"/>
<element name="Discount" positionX="126" positionY="877" width="128" height="105"/> <element name="Discount" positionX="126" positionY="877" width="128" height="105"/>
<element name="GiftCard" positionX="531" positionY="862" width="128" height="135"/> <element name="GiftCard" positionX="531" positionY="862" width="128" height="135"/>
...@@ -1004,7 +1004,7 @@ ...@@ -1004,7 +1004,7 @@
<element name="Option" positionX="-576" positionY="907" width="128" height="105"/> <element name="Option" positionX="-576" positionY="907" width="128" height="105"/>
<element name="OptionValue" positionX="-387" positionY="907" width="128" height="105"/> <element name="OptionValue" positionX="-387" positionY="907" width="128" height="105"/>
<element name="Order" positionX="682" positionY="922" width="128" height="180"/> <element name="Order" positionX="682" positionY="922" width="128" height="180"/>
<element name="Product" positionX="-765" positionY="712" width="128" height="315"/> <element name="Product" positionX="-765" positionY="712" width="128" height="300"/>
<element name="ProductVariant" positionX="-182" positionY="787" width="128" height="240"/> <element name="ProductVariant" positionX="-182" positionY="787" width="128" height="240"/>
<element name="ShippingRate" positionX="531" positionY="1035" width="128" height="135"/> <element name="ShippingRate" positionX="531" positionY="1035" width="128" height="135"/>
<element name="Shop" positionX="-279" positionY="450" width="128" height="255"/> <element name="Shop" positionX="-279" positionY="450" width="128" height="255"/>
......
...@@ -31,10 +31,8 @@ ...@@ -31,10 +31,8 @@
@interface BUYLineItem : _BUYLineItem {} @interface BUYLineItem : _BUYLineItem {}
- (instancetype)initWithVariant:(BUYProductVariant *)variant NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead"); - (void)updateWithVariant:(BUYProductVariant *)variant;
- (instancetype)initWithCartLineItem:(BUYCartLineItem *)cartLineItem NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead"); - (void)updateWithLineItem:(BUYCartLineItem *)lineItem;
@property (readonly) NSString *lineItemIdentifier NS_DEPRECATED_IOS(8_0, 9_0);
@end @end
......
...@@ -34,24 +34,6 @@ ...@@ -34,24 +34,6 @@
@implementation BUYLineItem @implementation BUYLineItem
/**
* Have model manager responsible for instantiation, and allow deprecated
* initializers for backwards compatability
*/
- (instancetype)initWithCartLineItem:(BUYCartLineItem *)cartLineItem
{
BUYLineItem *lineItem = [[BUYLineItem alloc] initWithModelManager:cartLineItem.modelManager JSONDictionary:nil];
[lineItem updateWithLineItem:cartLineItem];
return lineItem;
}
- (instancetype)initWithVariant:(BUYProductVariant *)variant
{
BUYLineItem *lineItem = [[BUYLineItem alloc] initWithModelManager:variant.modelManager JSONDictionary:nil];
[lineItem updateWithVariant:variant];
return lineItem;
}
- (void)updateWithVariant:(BUYProductVariant *)variant - (void)updateWithVariant:(BUYProductVariant *)variant
{ {
self.variantId = variant.identifier; self.variantId = variant.identifier;
...@@ -69,11 +51,6 @@ ...@@ -69,11 +51,6 @@
self.quantity = lineItem.quantity; self.quantity = lineItem.quantity;
} }
- (NSString *)lineItemIdentifier
{
return self.identifier;
}
@end @end
@implementation BUYModelManager (BUYLineItemCreation) @implementation BUYModelManager (BUYLineItemCreation)
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#import "BUYModelManager.h" #import "BUYModelManager.h"
extern const struct BUYCollectionAttributes { extern const struct BUYCollectionAttributes {
__unsafe_unretained NSString *collectionId;
__unsafe_unretained NSString *createdAt; __unsafe_unretained NSString *createdAt;
__unsafe_unretained NSString *handle; __unsafe_unretained NSString *handle;
__unsafe_unretained NSString *htmlDescription; __unsafe_unretained NSString *htmlDescription;
...@@ -68,15 +67,6 @@ extern const struct BUYCollectionUserInfo { ...@@ -68,15 +67,6 @@ extern const struct BUYCollectionUserInfo {
@interface _BUYCollection : BUYCachedObject @interface _BUYCollection : BUYCachedObject
+ (NSString *)entityName; + (NSString *)entityName;
/**
* The unique collection ID in the channel.
*/
@property (nonatomic, strong) NSNumber* collectionId;
@property (atomic) int64_t collectionIdValue;
- (int64_t)collectionIdValue;
- (void)setCollectionIdValue:(int64_t)value_;
@property (nonatomic, strong) NSDate* createdAt; @property (nonatomic, strong) NSDate* createdAt;
/** /**
...@@ -91,6 +81,9 @@ extern const struct BUYCollectionUserInfo { ...@@ -91,6 +81,9 @@ extern const struct BUYCollectionUserInfo {
*/ */
@property (nonatomic, strong) NSString* htmlDescription; @property (nonatomic, strong) NSString* htmlDescription;
/**
* Maps to collection_id in the JSON
*/
@property (nonatomic, strong) NSNumber* identifier; @property (nonatomic, strong) NSNumber* identifier;
@property (atomic) int64_t identifierValue; @property (atomic) int64_t identifierValue;
...@@ -141,9 +134,6 @@ extern const struct BUYCollectionUserInfo { ...@@ -141,9 +134,6 @@ extern const struct BUYCollectionUserInfo {
@interface _BUYCollection (CoreDataGeneratedPrimitiveAccessors) @interface _BUYCollection (CoreDataGeneratedPrimitiveAccessors)
- (NSNumber*)primitiveCollectionId;
- (void)setPrimitiveCollectionId:(NSNumber*)value;
- (NSDate*)primitiveCreatedAt; - (NSDate*)primitiveCreatedAt;
- (void)setPrimitiveCreatedAt:(NSDate*)value; - (void)setPrimitiveCreatedAt:(NSDate*)value;
......
...@@ -29,7 +29,6 @@ ...@@ -29,7 +29,6 @@
#import "_BUYCollection.h" #import "_BUYCollection.h"
const struct BUYCollectionAttributes BUYCollectionAttributes = { const struct BUYCollectionAttributes BUYCollectionAttributes = {
.collectionId = @"collectionId",
.createdAt = @"createdAt", .createdAt = @"createdAt",
.handle = @"handle", .handle = @"handle",
.htmlDescription = @"htmlDescription", .htmlDescription = @"htmlDescription",
...@@ -58,11 +57,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = { ...@@ -58,11 +57,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = {
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key]; NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
if ([key isEqualToString:@"collectionIdValue"]) {
NSSet *affectingKey = [NSSet setWithObject:@"collectionId"];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
return keyPaths;
}
if ([key isEqualToString:@"identifierValue"]) { if ([key isEqualToString:@"identifierValue"]) {
NSSet *affectingKey = [NSSet setWithObject:@"identifier"]; NSSet *affectingKey = [NSSet setWithObject:@"identifier"];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
...@@ -78,19 +72,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = { ...@@ -78,19 +72,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = {
} }
#if defined CORE_DATA_PERSISTENCE #if defined CORE_DATA_PERSISTENCE
- (NSNumber*)collectionId {
[self willAccessValueForKey:@"collectionId"];
id value = [self primitiveValueForKey:@"collectionId"];
[self didAccessValueForKey:@"collectionId"];
return value;
}
- (void)setCollectionId:(NSNumber*)value_ {
[self willChangeValueForKey:@"collectionId"];
[self setPrimitiveValue:value_ forKey:@"collectionId"];
[self didChangeValueForKey:@"collectionId"];
}
- (NSDate*)createdAt { - (NSDate*)createdAt {
[self willAccessValueForKey:@"createdAt"]; [self willAccessValueForKey:@"createdAt"];
id value = [self primitiveValueForKey:@"createdAt"]; id value = [self primitiveValueForKey:@"createdAt"];
...@@ -197,15 +178,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = { ...@@ -197,15 +178,6 @@ const struct BUYCollectionUserInfo BUYCollectionUserInfo = {
#endif #endif
- (int64_t)collectionIdValue {
NSNumber *result = [self collectionId];
return [result longLongValue];
}
- (void)setCollectionIdValue:(int64_t)value_ {
[self setCollectionId:@(value_)];
}
- (int64_t)identifierValue { - (int64_t)identifierValue {
NSNumber *result = [self identifier]; NSNumber *result = [self identifier];
return [result longLongValue]; return [result longLongValue];
......
...@@ -36,7 +36,6 @@ extern const struct BUYProductAttributes { ...@@ -36,7 +36,6 @@ extern const struct BUYProductAttributes {
__unsafe_unretained NSString *handle; __unsafe_unretained NSString *handle;
__unsafe_unretained NSString *htmlDescription; __unsafe_unretained NSString *htmlDescription;
__unsafe_unretained NSString *identifier; __unsafe_unretained NSString *identifier;
__unsafe_unretained NSString *productId;
__unsafe_unretained NSString *productType; __unsafe_unretained NSString *productType;
__unsafe_unretained NSString *publicURL; __unsafe_unretained NSString *publicURL;
__unsafe_unretained NSString *published; __unsafe_unretained NSString *published;
...@@ -107,6 +106,9 @@ extern const struct BUYProductUserInfo { ...@@ -107,6 +106,9 @@ extern const struct BUYProductUserInfo {
*/ */
@property (nonatomic, strong) NSString* htmlDescription; @property (nonatomic, strong) NSString* htmlDescription;
/**
* Maps to product_id in the JSON
*/
@property (nonatomic, strong) NSNumber* identifier; @property (nonatomic, strong) NSNumber* identifier;
@property (atomic) int64_t identifierValue; @property (atomic) int64_t identifierValue;
...@@ -114,15 +116,6 @@ extern const struct BUYProductUserInfo { ...@@ -114,15 +116,6 @@ extern const struct BUYProductUserInfo {
- (void)setIdentifierValue:(int64_t)value_; - (void)setIdentifierValue:(int64_t)value_;
/** /**
* The channel product ID.
*/
@property (nonatomic, strong) NSNumber* productId;
@property (atomic) int64_t productIdValue;
- (int64_t)productIdValue;
- (void)setProductIdValue:(int64_t)value_;
/**
* A categorization that a product can be tagged with, commonly used for filtering and searching. * A categorization that a product can be tagged with, commonly used for filtering and searching.
*/ */
@property (nonatomic, strong) NSString* productType; @property (nonatomic, strong) NSString* productType;
...@@ -254,9 +247,6 @@ extern const struct BUYProductUserInfo { ...@@ -254,9 +247,6 @@ extern const struct BUYProductUserInfo {
- (NSNumber*)primitiveIdentifier; - (NSNumber*)primitiveIdentifier;
- (void)setPrimitiveIdentifier:(NSNumber*)value; - (void)setPrimitiveIdentifier:(NSNumber*)value;
- (NSNumber*)primitiveProductId;
- (void)setPrimitiveProductId:(NSNumber*)value;
- (NSString*)primitiveProductType; - (NSString*)primitiveProductType;
- (void)setPrimitiveProductType:(NSString*)value; - (void)setPrimitiveProductType:(NSString*)value;
......
...@@ -34,7 +34,6 @@ const struct BUYProductAttributes BUYProductAttributes = { ...@@ -34,7 +34,6 @@ const struct BUYProductAttributes BUYProductAttributes = {
.handle = @"handle", .handle = @"handle",
.htmlDescription = @"htmlDescription", .htmlDescription = @"htmlDescription",
.identifier = @"identifier", .identifier = @"identifier",
.productId = @"productId",
.productType = @"productType", .productType = @"productType",
.publicURL = @"publicURL", .publicURL = @"publicURL",
.published = @"published", .published = @"published",
...@@ -75,11 +74,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = { ...@@ -75,11 +74,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = {
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
return keyPaths; return keyPaths;
} }
if ([key isEqualToString:@"productIdValue"]) {
NSSet *affectingKey = [NSSet setWithObject:@"productId"];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
return keyPaths;
}
if ([key isEqualToString:@"publishedValue"]) { if ([key isEqualToString:@"publishedValue"]) {
NSSet *affectingKey = [NSSet setWithObject:@"published"]; NSSet *affectingKey = [NSSet setWithObject:@"published"];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey]; keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
...@@ -155,19 +149,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = { ...@@ -155,19 +149,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = {
[self didChangeValueForKey:@"identifier"]; [self didChangeValueForKey:@"identifier"];
} }
- (NSNumber*)productId {
[self willAccessValueForKey:@"productId"];
id value = [self primitiveValueForKey:@"productId"];
[self didAccessValueForKey:@"productId"];
return value;
}
- (void)setProductId:(NSNumber*)value_ {
[self willChangeValueForKey:@"productId"];
[self setPrimitiveValue:value_ forKey:@"productId"];
[self didChangeValueForKey:@"productId"];
}
- (NSString*)productType { - (NSString*)productType {
[self willAccessValueForKey:@"productType"]; [self willAccessValueForKey:@"productType"];
id value = [self primitiveValueForKey:@"productType"]; id value = [self primitiveValueForKey:@"productType"];
...@@ -292,15 +273,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = { ...@@ -292,15 +273,6 @@ const struct BUYProductUserInfo BUYProductUserInfo = {
[self setIdentifier:@(value_)]; [self setIdentifier:@(value_)];
} }
- (int64_t)productIdValue {
NSNumber *result = [self productId];
return [result longLongValue];
}
- (void)setProductIdValue:(int64_t)value_ {
[self setProductId:@(value_)];
}
- (BOOL)publishedValue { - (BOOL)publishedValue {
NSNumber *result = [self published]; NSNumber *result = [self published];
return [result boolValue]; return [result boolValue];
......
...@@ -115,7 +115,9 @@ ...@@ -115,7 +115,9 @@
- (void)updateWithCart:(BUYCart *)cart - (void)updateWithCart:(BUYCart *)cart
{ {
NSArray *lineItems = [[cart.lineItems array] buy_map:^id(BUYCartLineItem *cartLineItem) { NSArray *lineItems = [[cart.lineItems array] buy_map:^id(BUYCartLineItem *cartLineItem) {
return [[BUYLineItem alloc] initWithCartLineItem:cartLineItem]; BUYLineItem *lineItem = [self.modelManager buy_objectWithEntityName:[BUYLineItem entityName] JSONDictionary:nil];
[lineItem updateWithLineItem:cartLineItem];
return lineItem;
}]; }];
self.lineItems = [NSOrderedSet orderedSetWithArray:lineItems]; self.lineItems = [NSOrderedSet orderedSetWithArray:lineItems];
} }
......
...@@ -31,7 +31,8 @@ ...@@ -31,7 +31,8 @@
#import "BUYApplePayAuthorizationDelegate.h" #import "BUYApplePayAuthorizationDelegate.h"
#import "BUYApplePayAdditions.h" #import "BUYApplePayAdditions.h"
#import "BUYShop.h" #import "BUYShop.h"
#import "BUYClient+CheckoutHelpers.h" #import "BUYClient+Checkout.h"
#import "BUYClient+Storefront.h"
NSString *const BUYApplePayPaymentProviderId = @"BUYApplePayPaymentProviderId"; NSString *const BUYApplePayPaymentProviderId = @"BUYApplePayPaymentProviderId";
...@@ -113,7 +114,7 @@ NSString *const BUYApplePayPaymentProviderId = @"BUYApplePayPaymentProviderId"; ...@@ -113,7 +114,7 @@ NSString *const BUYApplePayPaymentProviderId = @"BUYApplePayPaymentProviderId";
}]; }];
dispatch_group_enter(group); dispatch_group_enter(group);
[self.client handleCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) { [self.client updateOrCreateCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {
if (error) { if (error) {
if ([self.delegate respondsToSelector:@selector(paymentProvider:didFailWithError:)]) { if ([self.delegate respondsToSelector:@selector(paymentProvider:didFailWithError:)]) {
[self.delegate paymentProvider:self didFailWithError:error]; [self.delegate paymentProvider:self didFailWithError:error];
......
//
// BUYClient+CheckoutHelpers.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 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 <Buy/Buy.h>
NS_ASSUME_NONNULL_BEGIN
@interface BUYClient (CheckoutHelpers)
- (NSURLSessionDataTask *)handleCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion;
@end
NS_ASSUME_NONNULL_END
//
// BUYClient+CheckoutHelpers.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 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 "BUYClient+CheckoutHelpers.h"
@implementation BUYClient (CheckoutHelpers)
- (BUYRequestOperation *)handleCheckout:(BUYCheckout *)checkout completion:(BUYDataCheckoutBlock)completion
{
if ([checkout hasToken]) {
return [self updateCheckout:checkout completion:completion];
} else {
return [self createCheckout:checkout completion:completion];
}
}
@end
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#import "BUYWebCheckoutPaymentProvider.h" #import "BUYWebCheckoutPaymentProvider.h"
#import "BUYCheckout.h" #import "BUYCheckout.h"
#import "BUYClient+CheckoutHelpers.h" #import "BUYClient+Checkout.h"
#import "BUYAssert.h" #import "BUYAssert.h"
@import SafariServices; @import SafariServices;
...@@ -114,7 +114,7 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token" ...@@ -114,7 +114,7 @@ static NSString *const WebCheckoutCustomerAccessToken = @"customer_access_token"
self.checkout = checkout; self.checkout = checkout;
[self.client handleCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) { [self.client updateOrCreateCheckout:checkout completion:^(BUYCheckout *checkout, NSError *error) {
[self postCheckoutCompletion:checkout error:error]; [self postCheckoutCompletion:checkout error:error];
}]; }];
} }
......
...@@ -63,6 +63,7 @@ ...@@ -63,6 +63,7 @@
#import "BUYClient+Customers.h" #import "BUYClient+Customers.h"
#import "BUYClient+Checkout.h" #import "BUYClient+Checkout.h"
#import "BUYClient+Storefront.h" #import "BUYClient+Storefront.h"
#import "BUYRequestOperation.h" #import "BUYRequestOperation.h"
#import "BUYError.h" #import "BUYError.h"
#import "BUYError+BUYAdditions.h" #import "BUYError+BUYAdditions.h"
......
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