Commit f1aebcaf by Brent Gulanowski

Update all models to derive from generated classes.

parent eab091af
......@@ -28,11 +28,8 @@
@import PassKit;
@import UIKit;
@import XCTest;
#import <Buy/Buy.h>
#import "BUYAddress+Additions.h"
#import "BUYCheckout_Private.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "BUYPKContact.h"
#import "BUYNSPersonNameComponents.h"
......@@ -44,13 +41,20 @@
@implementation BUYApplePayAdditionsTest {
BUYCheckout *_checkout;
BUYModelManager *_modelManager;
}
- (void)setUp
{
_modelManager = [BUYModelManager modelManager];
_checkout = [[BUYCheckout alloc] initWithCart:nil];
}
- (void)tearDown
{
_modelManager = nil;
}
#pragma mark - BUYCheckout Apple Pay additions
- (void)testSummaryItemsWithEmptyCheckout
......@@ -67,7 +71,7 @@
- (void)testFullSummaryItems
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"2.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"2.00" }];
_checkout.totalTax = [NSDecimalNumber decimalNumberWithString:@"1.00"];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"4.00"];
......@@ -87,7 +91,7 @@
- (void)testSummaryItemsWithShippingRate
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"2.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"2.00" }];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"3.00"];
NSArray *summaryItems = [_checkout buy_summaryItems];
......@@ -104,7 +108,7 @@
- (void)testSummaryItemsWithFreeShippingAndTaxesShouldNotShowShippingOrTaxes
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"0.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"0.00" }];
_checkout.totalTax = [NSDecimalNumber zero];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"3.00"];
......@@ -120,13 +124,12 @@
- (void)testSummaryItemsWithZeroDiscount
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"0.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"0.00" }];
_checkout.totalTax = [NSDecimalNumber zero];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"3.00"];
BUYDiscount *discount = [[BUYDiscount alloc] init];
discount.code = @"BANANA";
BUYDiscount *discount = [_modelManager discountWithCode:@"BANANA"];
discount.amount = [NSDecimalNumber zero];
discount.applicable = YES;
discount.applicableValue = YES;
_checkout.discount = discount;
NSArray *summaryItems = [_checkout buy_summaryItems];
......@@ -141,13 +144,12 @@
- (void)testSummaryItemsWithNonZeroDiscount
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"0.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"0.00" }];
_checkout.totalTax = [NSDecimalNumber zero];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"2.00"];
BUYDiscount *discount = [[BUYDiscount alloc] init];
discount.code = @"BANANA";
BUYDiscount *discount = [_modelManager discountWithCode:@"BANANA"];
discount.amount = [NSDecimalNumber one];
discount.applicable = YES;
discount.applicableValue = YES;
_checkout.discount = discount;
NSArray *summaryItems = [_checkout buy_summaryItems];
......@@ -165,13 +167,12 @@
- (void)testSummaryItemsWithNonZeroCodelessDiscount
{
_checkout.subtotalPrice = [NSDecimalNumber one];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"0.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"0.00" }];
_checkout.totalTax = [NSDecimalNumber zero];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"2.00"];
BUYDiscount *discount = [[BUYDiscount alloc] init];
discount.code = @"";
BUYDiscount *discount = [_modelManager discountWithCode:@""];
discount.amount = [NSDecimalNumber one];
discount.applicable = YES;
discount.applicableValue = YES;
_checkout.discount = discount;
NSArray *summaryItems = [_checkout buy_summaryItems];
......@@ -189,17 +190,16 @@
- (void)testSummaryItemsWithGiftCard
{
_checkout.subtotalPrice = [NSDecimalNumber decimalNumberWithString:@"12.00"];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"price" : @"0.00" }];
_checkout.shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"price" : @"0.00" }];
_checkout.totalTax = [NSDecimalNumber zero];
_checkout.paymentDue = [NSDecimalNumber decimalNumberWithString:@"2.00"];
BUYDiscount *discount = [[BUYDiscount alloc] init];
discount.code = @"";
BUYDiscount *discount = [_modelManager discountWithCode:@""];
discount.amount = [NSDecimalNumber one];
discount.applicable = YES;
discount.applicableValue = YES;
_checkout.discount = discount;
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithDictionary:@{ @"amount_used" : [NSDecimalNumber decimalNumberWithString:@"10.00"], @"balance" : [NSDecimalNumber decimalNumberWithString:@"10.00"], @"last_characters" : @"1234" }];
_checkout.giftCards = @[giftCard];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"amount_used" : [NSDecimalNumber decimalNumberWithString:@"10.00"], @"balance" : [NSDecimalNumber decimalNumberWithString:@"10.00"], @"last_characters" : @"1234" }];
[[_checkout giftCardsSet] addObject:giftCard];
NSArray *summaryItems = [_checkout buy_summaryItems];
XCTAssertEqual(5, [summaryItems count]);
......@@ -227,15 +227,15 @@
NSDate *lastDate = [self dateWithoutTime:[NSDate dateWithTimeIntervalSinceNow:day]];
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForShippingRates];
BUYShippingRate *rate1 = [[BUYShippingRate alloc] initWithDictionary:@{@"price" : @"5.00", @"id" : @"1234", @"title" : @"Banana", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
BUYShippingRate *rate1 = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{@"price" : @"5.00", @"id" : @"1234", @"title" : @"Banana", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
firstDate = [self dateWithoutTime:[NSDate dateWithTimeIntervalSinceNow:day * 3]];
lastDate = [self dateWithoutTime:[NSDate dateWithTimeIntervalSinceNow:day * 5]];
BUYShippingRate *rate2 = [[BUYShippingRate alloc] initWithDictionary:@{@"price" : @"3.00", @"id" : @"5678", @"title" : @"Dinosaur", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
BUYShippingRate *rate2 = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{@"price" : @"3.00", @"id" : @"5678", @"title" : @"Dinosaur", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
firstDate = [self dateWithoutTime:[NSDate dateWithTimeIntervalSinceNow:day * 10]];
lastDate = [self dateWithoutTime:[NSDate dateWithTimeIntervalSinceNow:day * 12]];
BUYShippingRate *rate3 = [[BUYShippingRate alloc] initWithDictionary:@{@"price" : @"19.00", @"id" : @"1357", @"title" : @"Bulldozer", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
BUYShippingRate *rate3 = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{@"price" : @"19.00", @"id" : @"1357", @"title" : @"Bulldozer", @"delivery_range" : @[[dateFormatter stringFromDate:firstDate], [dateFormatter stringFromDate:lastDate]]}];
NSArray *shippingMethods = [BUYShippingRate buy_convertShippingRatesToShippingMethods:@[rate1, rate2, rate3]];
XCTAssertEqual(3, [shippingMethods count]);
......@@ -353,7 +353,7 @@
ABRecordSetValue(person, kABPersonAddressProperty, addresses, &error);
CFRelease(addresses);
BUYAddress *newAddress = [BUYAddress buy_addressFromRecord:person];
BUYAddress *newAddress = [_modelManager buyAddressWithABRecord:person];
CFRelease(person);
......@@ -410,7 +410,7 @@
[postalAddress setISOCountryCode:@"CA"];
[contact setPostalAddress:postalAddress];
return [BUYAddress buy_addressFromContact:contact];
return [_modelManager buyAddressWithContact:contact];
}
- (void)testCompareAddressWithContactWithNameOrStreetOrPhone
......
......@@ -33,33 +33,32 @@
@implementation BUYCartTest {
BUYCart *_cart;
BUYModelManager *_modelManager;
}
- (void)setUp
{
[super setUp];
_cart = [[BUYCart alloc] init];
_modelManager = [BUYModelManager modelManager];
_cart = [_modelManager insertCartWithJSONDictionary:nil];
}
#pragma mark - Serialization Tests
- (void)testJsonDictionaryShouldBeEmptyWhenNothingIsSet
- (void)tearDown
{
NSDictionary *json = [_cart jsonDictionaryForCheckout];
XCTAssertNotNil(json);
XCTAssertEqual(0, [json count]);
_cart = nil;
_modelManager = nil;
}
#pragma mark - Serialization Tests
- (void)testCartShouldBeInvalidWhenEmpty
{
BUYCart *cart = [[BUYCart alloc] init];
XCTAssertFalse([cart isValid]);
XCTAssertFalse([_cart isValid]);
}
- (void)testAddVariantWillAddALineItem
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
[_cart addVariant:variant];
XCTAssertEqual([[_cart lineItems] count], 1);
XCTAssertEqualObjects([[_cart lineItems][0] variantId], variant.identifier);
......@@ -67,10 +66,10 @@
- (void)testAddingTwoDifferentVariantsWillAddDifferentLineItems
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
[_cart addVariant:variant];
BUYProductVariant *variant2 = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @2 }];
BUYProductVariant *variant2 = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @2 }];
[_cart addVariant:variant2];
XCTAssertEqual([[_cart lineItems] count], 2);
......@@ -78,7 +77,7 @@
- (void)testAddingAVariantOfTheSameTypeWillNotAddAnotherLineItem
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
[_cart addVariant:variant];
[_cart addVariant:variant];
XCTAssertEqual([[_cart lineItems] count], 1);
......@@ -88,7 +87,7 @@
- (void)testRemovingAVariantDecrementsQuantity
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
[_cart addVariant:variant];
[_cart addVariant:variant];
[_cart removeVariant:variant];
......@@ -97,7 +96,7 @@
- (void)testRemovingAllVariantsOfASingleTypeRemovesItsLineItem
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
[_cart addVariant:variant];
[_cart removeVariant:variant];
XCTAssertEqual([[_cart lineItems] count], 0);
......@@ -105,8 +104,8 @@
- (void)testSetVariantWithQuantity
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
BUYProductVariant *variantTwo = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @2 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
BUYProductVariant *variantTwo = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @2 }];
[_cart setVariant:variant withTotalQuantity:2];
XCTAssertEqual([[_cart lineItems] count], 1);
......
......@@ -26,12 +26,15 @@
@import UIKit;
@import XCTest;
#import <Buy/Buy.h>
#import "BUYCheckout_Private.h"
#import "BUYCheckout.h"
@interface BUYCheckoutTest : XCTestCase
@end
@implementation BUYCheckoutTest {
BUYModelManager *_modelManager;
BUYCheckout *_checkout;
BUYCart *_cart;
BUYProductVariant *_variant;
......@@ -41,27 +44,28 @@
- (void)setUp
{
[super setUp];
_cart = [[BUYCart alloc] init];
_checkout = [[BUYCheckout alloc] initWithCart:_cart];
_variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1 }];
_modelManager = [BUYModelManager modelManager];
_cart = [_modelManager insertCartWithJSONDictionary:nil];
_checkout = [_modelManager checkoutWithCart:_cart];
_variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1 }];
_discountDictionary = @{ @"code" : @"abcd1234", @"amount" : @"5.00", @"applicable" : @true };
}
- (void)testOrderStatusDeserializationWithInvalidURL
{
BUYCheckout *checkout = [[BUYCheckout alloc] initWithDictionary:@{ @"order" : @{ @"status_url" : @"NOT REAL" } }];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"order" : @{ @"status_url" : @"NOT REAL" } }];
XCTAssertNil(checkout.order.statusURL);
}
- (void)testOrderStatusDeserializationWithValidURL
{
BUYCheckout *checkout = [[BUYCheckout alloc] initWithDictionary:@{ @"order" : @{ @"status_url" : @"http://www.shopify.com/" } }];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"order" : @{ @"status_url" : @"http://www.shopify.com/" } }];
XCTAssertNotNil(checkout.order.statusURL);
}
- (void)testOrderStatusDeserializationWithNoURL
{
BUYCheckout *checkout = [[BUYCheckout alloc] initWithDictionary:@{}];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager JSONDictionary:@{}];
XCTAssertNil(checkout.order.statusURL);
}
......@@ -73,25 +77,47 @@
XCTAssertTrue([checkout isDirty]);
}
- (void)testCheckoutWithVariant
{
BUYCheckout *checkout = [_modelManager checkoutWithVariant:_variant];
XCTAssertNotNil(checkout);
XCTAssertGreaterThanOrEqual([checkout.lineItems count], 1);
BUYLineItem *lineItem = checkout.lineItems[0];
XCTAssertEqual(_variant.identifier, lineItem.variantId);
}
- (void)testSettingAShippingRateMarksShippingRateIdAsDirty
{
BUYShippingRate *shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @"banana" }];
XCTAssertNil(_checkout.shippingRate);
XCTAssertNil(_checkout.shippingRateId);
_checkout.shippingRate = shippingRate;
XCTAssertEqualObjects(@"banana", _checkout.shippingRateId);
XCTAssertTrue([[_checkout dirtyProperties] containsObject:@"shippingRateId"]);
}
- (void)testDirtyPropertiesAreReturnedInJSON
{
BUYShippingRate *shippingRate = [[BUYShippingRate alloc] initWithDictionary:@{ @"id" : @"banana" }];
BUYShippingRate *shippingRate = [[BUYShippingRate alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @"banana" }];
[_checkout markAsClean];
_checkout.shippingRate = shippingRate;
_checkout.currency = @"BANANA";
NSSet *dirtyProperties = [_checkout dirtyProperties];
XCTAssertTrue([dirtyProperties containsObject:@"currency"]);
XCTAssertTrue([dirtyProperties containsObject:@"shippingRateId"]);
XCTAssertTrue([dirtyProperties containsObject:@"shippingRate"]);
NSDictionary *json = [_checkout jsonDictionaryForCheckout];
XCTAssertEqualObjects(json[@"checkout"][@"currency"], @"BANANA");
XCTAssertEqualObjects(json[@"checkout"][@"shipping_rate_id"], @"banana");
}
- (void)testRequiresShippingAndIncludesTaxesSerialization
{
_checkout.requiresShipping = YES;
_checkout.taxesIncluded = YES;
_checkout.requiresShippingValue = YES;
_checkout.includesTaxesValue = YES;
NSDictionary *jsonDictionary = [_checkout jsonDictionaryForCheckout][@"checkout"];
XCTAssertEqualObjects(@YES, jsonDictionary[@"requires_shipping"]);
XCTAssertEqualObjects(@YES, jsonDictionary[@"taxes_included"]);
......@@ -99,16 +125,16 @@
- (void)testDiscountDeserialization
{
BUYDiscount *discount = [[BUYDiscount alloc] initWithDictionary: _discountDictionary];
BUYDiscount *discount = [[BUYDiscount alloc] initWithModelManager:_modelManager JSONDictionary: _discountDictionary];
XCTAssertEqualObjects(@"abcd1234", discount.code);
XCTAssertEqualObjects(@5.00, discount.amount);
XCTAssertEqual(true, discount.applicable);
XCTAssertEqual(true, discount.applicableValue);
}
- (void)testDiscountSerialization
{
NSDictionary *jsonDict = @{ @"code": @"abcd1234" };
BUYDiscount *discount = [[BUYDiscount alloc] initWithDictionary:_discountDictionary];
BUYDiscount *discount = [[BUYDiscount alloc] initWithModelManager:_modelManager JSONDictionary:_discountDictionary];
XCTAssertEqualObjects(jsonDict, [discount jsonDictionaryForCheckout]);
}
......@@ -125,21 +151,21 @@
- (void)testEmptyCheckoutsDoNotRequireShipping
{
_checkout = [[BUYCheckout alloc] initWithDictionary:@{}];
_checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager JSONDictionary:@{}];
XCTAssertFalse([_checkout requiresShipping]);
}
- (void)testCheckoutsWithoutItemsThatRequireShipping
{
_checkout = [[BUYCheckout alloc] initWithDictionary:@{ @"requires_shipping" : @1 }];
_checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"requires_shipping" : @1 }];
XCTAssertTrue([_checkout requiresShipping]);
}
- (void)testTaxLineDeserialization
{
BUYTaxLine *taxLine = [[BUYTaxLine alloc] initWithDictionary:@{@"price": @"0.29",
@"rate": @"0.13",
@"title": @"HST"}];
BUYTaxLine *taxLine = [[BUYTaxLine alloc] initWithModelManager:_modelManager JSONDictionary:@{@"price": @"0.29",
@"rate": @"0.13",
@"title": @"HST"}];
XCTAssertEqualObjects(@0.29, taxLine.price);
XCTAssertEqualObjects(@0.13, taxLine.rate);
XCTAssertEqualObjects(@"HST", taxLine.title);
......
......@@ -29,9 +29,7 @@
#import <Buy/Buy.h>
#import "BUYTestConstants.h"
#import "BUYAddress+Additions.h"
#import "BUYClientTestBase.h"
#import "BUYCollection+Additions.h"
#import "NSURLComponents+BUYAdditions.h"
@interface BUYClient ()
......@@ -69,7 +67,7 @@
- (NSData *)dataForCartFromClient:(BUYClient *)client
{
BUYCart *cart = [[BUYCart alloc] init];
BUYCart *cart = [self cart];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithCart:cart];
NSURLSessionDataTask *task = [self.client createCheckout:checkout completion:nil];
XCTAssertNotNil(task);
......@@ -98,10 +96,10 @@
- (void)testPartialAddressesFlag
{
BUYCart *cart = [[BUYCart alloc] init];
BUYCart *cart = [self cart];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithCart:cart];
XCTAssertThrows([checkout setPartialAddresses:NO]);
XCTAssertThrows([checkout setPartialAddressesValue:NO]);
NSURLSessionDataTask *task = [self.client createCheckout:checkout completion:nil];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:task.originalRequest.HTTPBody options:0 error:nil];
......@@ -109,11 +107,11 @@
checkout = [[BUYCheckout alloc] initWithCart:cart];
BUYAddress *partialAddress = [[BUYAddress alloc] init];
BUYAddress *partialAddress = [self.client.modelManager insertAddressWithJSONDictionary:nil];
partialAddress.address1 = nil;
if ([partialAddress isPartialAddress]) {
checkout.partialAddresses = YES;
checkout.partialAddressesValue = YES;
}
checkout.shippingAddress = partialAddress;
......@@ -125,7 +123,7 @@
- (void)testCheckoutPaymentWithOnlyGiftCard
{
BUYCheckout *checkout = [[BUYCheckout alloc] initWithDictionary:@{@"token": @"abcdef", @"payment_due": @0}];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:self.client.modelManager JSONDictionary:@{@"token": @"abcdef", @"payment_due": @0}];
NSURLSessionDataTask *task = [self.client completeCheckout:checkout completion:nil];
XCTAssertNotNil(task);
......@@ -200,7 +198,7 @@
XCTAssertEqual(error.code, BUYShopifyError_InvalidCheckoutObject);
}];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithDictionary:@{@"token": @"abcdef", @"payment_due": @0}];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:self.client.modelManager JSONDictionary:@{@"token": @"abcdef", @"payment_due": @0}];
[self.client completeCheckout:checkout withApplePayToken:nil completion:^(BUYCheckout *checkout, NSError *error) {
callbackCount++;
......@@ -318,4 +316,9 @@
XCTAssertEqualObjects(requestQueryItems, queryItems);
}
- (BUYCart *)cart
{
return [self.client.modelManager insertCartWithJSONDictionary:nil];
}
@end
......@@ -29,7 +29,6 @@
#import <Buy/Buy.h>
#import "BUYTestConstants.h"
#import "BUYCollection.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "BUYClientTestBase.h"
#import <OHHTTPStubs/OHHTTPStubs.h>
#import "OHHTTPStubsResponse+Helpers.h"
......
......@@ -29,8 +29,7 @@
#import <Buy/Buy.h>
#import "BUYTestConstants.h"
#import "BUYAddress+Additions.h"
#import "BUYCheckout_Private.h"
#import "BUYCheckout.h"
#import "BUYClientTestBase.h"
#import <OHHTTPStubs/OHHTTPStubs.h>
#import "OHHTTPStubsResponse+Helpers.h"
......@@ -40,6 +39,8 @@
@implementation BUYIntegrationTest {
BUYModelManager *_modelManager;
NSMutableArray *_products;
BUYCart *_cart;
......@@ -52,6 +53,7 @@
{
[super setUp];
_modelManager = [BUYModelManager modelManager];
_products = [[NSMutableArray alloc] init];
[self fetchProducts];
......@@ -87,12 +89,12 @@
XCTAssertNil(error);
}];
NSLog(@"Fetched products (count: %ld", _products.count);
NSLog(@"Fetched products (count: %tu", _products.count);
}
- (void)createCart
{
_cart = [[BUYCart alloc] init];
_cart = [_modelManager insertCartWithJSONDictionary:nil];
for (BUYProduct *product in _products) {
[_cart addVariant:product.variants[0]];
}
......@@ -132,20 +134,22 @@
return [OHHTTPStubsResponse responseWithKey:@"testCheckoutFlowUsingCreditCard_1"];
}];
[self createCart];
_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;
NSArray *attributes = @[ [[BUYCheckoutAttribute alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"name" : @"attribute1", @"value" : @"value1" }],
[[BUYCheckoutAttribute alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"name" : @"attribute2", @"value" : @"value2" }] ];
_checkout.attributes = [NSSet setWithArray: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);
XCTAssertEqualObjects(returnedCheckout.attributes, _checkout.attributes);
_checkout = returnedCheckout;
[expectation fulfill];
......@@ -509,7 +513,7 @@
return [OHHTTPStubsResponse responseWithKey:@"testRemovingInvalidGiftCardFromCheckout_2"];
}];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithDictionary:@{ @"id" : @"000" }];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @"000" }];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client removeGiftCard:giftCard fromCheckout:_checkout completion:^(BUYCheckout *checkout, NSError *error) {
XCTAssertNotNil(error);
......@@ -537,7 +541,7 @@
return [OHHTTPStubsResponse responseWithKey:@"testRemovingExpiredGiftCardFromCheckout_2"];
}];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithDictionary:@{ @"id" : self.giftCardIdExpired }];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : self.giftCardIdExpired }];
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
[self.client removeGiftCard:giftCard fromCheckout:_checkout completion:^(BUYCheckout *checkout, NSError *error) {
XCTAssertNotNil(error);
......@@ -998,7 +1002,7 @@
_checkout.shippingAddress = [self partialShippingAddress];
if ([_checkout.shippingAddress isPartialAddress]) {
_checkout.partialAddresses = YES;
_checkout.partialAddressesValue = YES;
}
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
......@@ -1181,7 +1185,7 @@
- (BUYAddress *)billingAddress
{
BUYAddress *address = [[BUYAddress alloc] init];
BUYAddress *address = [_modelManager insertAddressWithJSONDictionary:nil];
address.address1 = @"150 Elgin Street";
address.address2 = @"8th Floor";
address.city = @"Ottawa";
......@@ -1197,7 +1201,7 @@
- (BUYAddress *)shippingAddress
{
BUYAddress *address = [[BUYAddress alloc] init];
BUYAddress *address = [_modelManager insertAddressWithJSONDictionary:nil];
address.address1 = @"150 Elgin Street";
address.address2 = @"8th Floor";
address.city = @"Ottawa";
......@@ -1213,7 +1217,7 @@
- (BUYAddress *)partialShippingAddress
{
BUYAddress *address = [[BUYAddress alloc] init];
BUYAddress *address = [_modelManager insertAddressWithJSONDictionary:nil];
address.address1 = nil;
address.city = @"Ottawa";
address.firstName = nil;
......@@ -1227,20 +1231,17 @@
- (BUYDiscount *)applicableDiscount
{
BUYDiscount *discount = [[BUYDiscount alloc] initWithCode:self.discountCodeValid];
return discount;
return [_modelManager discountWithCode:self.discountCodeValid];
}
- (BUYDiscount *)inapplicableDiscount
{
BUYDiscount *discount = [[BUYDiscount alloc] initWithCode:self.discountCodeExpired];
return discount;
return [_modelManager discountWithCode:self.discountCodeExpired];
}
- (BUYDiscount *)nonExistentDiscount
{
BUYDiscount *discount = [[BUYDiscount alloc] initWithCode:@"asdfasdfasdfasdf"];
return discount;
return [_modelManager discountWithCode:@"asdfasdfasdfasdf"];
}
- (void)testExpiringCheckout
......@@ -1248,6 +1249,8 @@
[self createCart];
[self createCheckout];
XCTAssertGreaterThanOrEqual([_checkout.lineItems count], 1);
XCTAssertNotNil(_checkout.reservationTime);
XCTAssertTrue([_checkout.reservationTime isKindOfClass:[NSNumber class]]);
XCTAssertEqual(300, _checkout.reservationTime.intValue);
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest * _Nonnull request) {
......
......@@ -32,25 +32,30 @@
@end
@implementation BUYLineItemTest {
BUYProductVariant *_variant;
BUYLineItem *_lineItem;
BUYModelManager *_modelManager;
}
- (void)setUp
{
[super setUp];
_lineItem = [[BUYLineItem alloc] init];
_modelManager = [BUYModelManager modelManager];
_variant = [[BUYProductVariant alloc] initWithModelManager:_modelManager JSONDictionary:@{ @"id" : @1, @"requires_shipping" : @YES }];
_lineItem = [[BUYLineItem alloc] initWithVariant:_variant];
}
- (void)tearDown
{
_modelManager = nil;
}
- (void)testInitRespectsVariantShippingFlag
{
XCTAssertFalse([[_lineItem requiresShipping] boolValue]);
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @1, @"requires_shipping" : @YES }];
_lineItem = [[BUYLineItem alloc] initWithVariant:variant];
XCTAssertTrue([[_lineItem requiresShipping] boolValue]);
BUYLineItem *newLineItem = [[BUYLineItem alloc] initWithVariant:variant];
XCTAssertTrue([[newLineItem requiresShipping] boolValue]);
_variant.requiresShipping = @NO;
XCTAssertTrue([[_lineItem requiresShipping] boolValue]);
}
#pragma mark - Serialization Tests
......@@ -59,13 +64,13 @@
{
NSDictionary *json = [_lineItem jsonDictionaryForCheckout];
XCTAssertNotNil(json);
XCTAssertEqualObjects([NSDecimalNumber zero], json[@"price"]);
XCTAssertEqualObjects([NSDecimalNumber zero], json[@"quantity"]);
XCTAssertEqualObjects(@"0", json[@"price"]);
XCTAssertEqualObjects(@"1", json[@"quantity"]);
}
- (void)testJsonDictionaryDoesntIncludeVariantsWithoutIds
{
_lineItem = [[BUYLineItem alloc] initWithVariant:nil];
_lineItem = [_modelManager lineItemWithVariant:nil];
NSDictionary *json = [_lineItem jsonDictionaryForCheckout];
XCTAssertNotNil(json);
XCTAssertNil(json[@"variant_id"]);
......@@ -73,7 +78,7 @@
- (void)testJsonDictionaryShouldShowAllProperties
{
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithDictionary:@{ @"id" : @5 }];
BUYProductVariant *variant = [[BUYProductVariant alloc] initWithModelManager:[BUYModelManager modelManager] JSONDictionary:@{ @"id" : @5 }];
_lineItem = [[BUYLineItem alloc] initWithVariant:variant];
_lineItem.quantity = [NSDecimalNumber decimalNumberWithString:@"3"];
_lineItem.price = [NSDecimalNumber decimalNumberWithString:@"5.55"];
......@@ -81,17 +86,15 @@
NSDictionary *json = [_lineItem jsonDictionaryForCheckout];
XCTAssertEqualObjects(@5, json[@"variant_id"]);
XCTAssertEqualObjects([NSDecimalNumber decimalNumberWithString:@"3"], json[@"quantity"]);
XCTAssertEqualObjects([NSDecimalNumber decimalNumberWithString:@"5.55"], json[@"price"]);
XCTAssertEqualObjects(@"3", json[@"quantity"]);
XCTAssertEqualObjects(@"5.55", json[@"price"]);
XCTAssertEqualObjects(@"banana", json[@"title"]);
}
- (void)testUpdatingFromJsonShouldUpdateAllValues
{
XCTAssertFalse([[_lineItem requiresShipping] boolValue]);
BUYLineItem *lineItem = [[BUYLineItem alloc] initWithDictionary:@{ @"id" : @5, @"price" : @"5.99", @"quantity" : @5, @"requires_shipping" : @YES, @"title" : @"banana" }];
XCTAssertEqualObjects(@5, lineItem.lineItemIdentifier);
BUYLineItem *lineItem = [[BUYLineItem alloc] initWithModelManager:[BUYModelManager modelManager] JSONDictionary:@{ @"id" : @"5", @"price" : @"5.99", @"quantity" : @5, @"requires_shipping" : @YES, @"title" : @"banana" }];
XCTAssertEqualObjects(@"5", lineItem.identifier);
XCTAssertEqualObjects([NSDecimalNumber decimalNumberWithString:@"5.99"], lineItem.price);
XCTAssertEqualObjects([NSDecimalNumber decimalNumberWithString:@"5"], lineItem.quantity);
XCTAssertEqualObjects(@"banana", lineItem.title);
......
......@@ -50,77 +50,33 @@
@property (nonatomic, readonly) NSArray *array;
@property (nonatomic, readonly) NSMutableArray *mutableArray;
- (NSArray *)propertyNames;
@end
@interface BUYObjectSubclass : BUYObject
@property (nonatomic, strong) NSNumber *identifier;
@end
@interface BUYObjectTests : XCTestCase
@property (nonatomic, strong) BUYModelManager *modelManager;
@end
@implementation BUYObjectTests
- (void)testInitWithDictionaryParsesIdentifier
{
BUYObject *object = [[BUYObject alloc] initWithDictionary:@{ @"id" : @5 }];
XCTAssert([object isDirty] == NO);
XCTAssertEqual(@5, [object identifier]);
}
- (void)testInitWithDictionaryWithoutIdentifier
{
BUYObject *object = [[BUYObject alloc] initWithDictionary:@{}];
XCTAssertNil([object identifier]);
}
- (void)testConvertObject
{
BUYObject *object = [BUYObject convertObject:@{ @"id" : @10 }];
XCTAssertNotNil(object);
XCTAssertEqual(@10, [object identifier]);
}
- (void)testConvertObjectWorksWithSubclasses
{
BUYObject *object = [BUYObjectSubclass convertObject:@{ @"id" : @10 }];
XCTAssertNotNil(object);
XCTAssertTrue([object isKindOfClass:[BUYObjectSubclass class]]);
XCTAssertEqual(@10, [object identifier]);
}
- (void)testConvertJSONArrayWithEmptyArray
{
NSArray *json = @[];
XCTAssertEqual(0, [[BUYObject convertJSONArray:json] count]);
}
@interface BUYModelManager (BUYDirtyTracked)
+ (BUYModelManager *)testModelManager;
@end
- (void)testConvertJSONArrayCreatesObjectOfClass
{
NSArray *json = @[@{ @"id" : @5 }, @{ @"id" : @7 }];
NSArray *convertedArray = [BUYObject convertJSONArray:json];
XCTAssertEqual(2, [convertedArray count]);
XCTAssertTrue([convertedArray[0] isKindOfClass:[BUYObject class]]);
XCTAssertTrue([convertedArray[1] isKindOfClass:[BUYObject class]]);
XCTAssertEqualObjects(@5, [convertedArray[0] identifier]);
XCTAssertEqualObjects(@7, [convertedArray[1] identifier]);
}
@implementation BUYObjectTests
- (void)testConvertJSONArrayWithCreatedBlock
- (void)setUp
{
NSArray *json = @[@{ @"id" : @5 }, @{ @"id" : @6 }, @{ @"id" : @7 }];
__block NSUInteger numberOfInvokes = 0;
NSArray *convertedArray = [BUYObject convertJSONArray:json block:^(id obj) {
XCTAssertTrue([obj isKindOfClass:[BUYObject class]]);
++numberOfInvokes;
}];
XCTAssertNotNil(convertedArray);
XCTAssertEqual([json count], [convertedArray count]);
XCTAssertEqual([json count], numberOfInvokes);
[super setUp];
self.modelManager = [BUYModelManager testModelManager];
}
- (void)testDirtyTracking
{
BUYDirtyTracked *object = [[BUYDirtyTracked alloc] init];
BUYDirtyTracked *object = [self dirtyTrackedObject];
object.s = @"short property name test";
object.dirtyObjectValue = @"Banana";
object.dirtyBooleanValue = true;
......@@ -136,19 +92,14 @@
object.dirtyUnsignedLongLongValue = 1234123412341234;
object.dirtyFloatValue = 0.5f;
object.dirtyDoubleValue = 0.5;
NSSet *expected = [NSSet setWithArray:@[@"s", @"dirtyObjectValue", @"dirtyBooleanValue", @"dirtyCharacterValue",
@"dirtyUnsignedCharValue", @"dirtyIntegerValue", @"dirtyUnsignedIntegerValue",
@"dirtyShortValue", @"dirtyUnsignedShortValue", @"dirtyLongValue",
@"dirtyUnsignedLongValue", @"dirtyLongLongValue", @"dirtyUnsignedLongLongValue",
@"dirtyFloatValue", @"dirtyDoubleValue"]];
NSSet *expected = [NSSet setWithArray:[object propertyNames]];
NSSet *actual = [object dirtyProperties];
XCTAssert([expected isEqual:actual]);
XCTAssertEqual([actual count], [expected count]);
XCTAssertEqualObjects(actual, expected);
}
- (void)testIsDirtyReturnsFalseWhenClean
{
BUYDirtyTracked *object = [[BUYDirtyTracked alloc] init];
BUYDirtyTracked *object = [self dirtyTrackedObject];
XCTAssert([object isDirty] == NO);
object.dirtyObjectValue = @"Banana";
[object markAsClean];
......@@ -157,18 +108,23 @@
- (void)testIsDirtyReturnsTrueWhenDirty
{
BUYDirtyTracked *object = [[BUYDirtyTracked alloc] init];
BUYDirtyTracked *object = [self dirtyTrackedObject];
object.dirtyObjectValue = @"Banana";
XCTAssert([object isDirty]);
}
- (void)testMarkAsClean
{
BUYDirtyTracked *object = [[BUYDirtyTracked alloc] init];
BUYDirtyTracked *object = [self dirtyTrackedObject];
object.dirtyObjectValue = @"Banana";
XCTAssert([object dirtyProperties]);
}
- (BUYDirtyTracked *)dirtyTrackedObject
{
return [[BUYDirtyTracked alloc] initWithModelManager:nil JSONDictionary:nil];
}
@end
#pragma mark - Helper Impls
......@@ -180,7 +136,44 @@
return YES;
}
+ (NSString *)entityName
{
return nil;
}
// Overriding private BUYObject class method to avoid need for entity
- (NSArray *)propertyNames
{
return @[@"s", @"dirtyObjectValue", @"dirtyBooleanValue", @"dirtyCharacterValue",
@"dirtyUnsignedCharValue", @"dirtyIntegerValue", @"dirtyUnsignedIntegerValue",
@"dirtyShortValue", @"dirtyUnsignedShortValue", @"dirtyLongValue",
@"dirtyUnsignedLongValue", @"dirtyLongLongValue", @"dirtyUnsignedLongLongValue",
@"dirtyFloatValue", @"dirtyDoubleValue"];
}
@end
@implementation BUYObjectSubclass
+ (NSString *)entityName
{
return @"ObjectSubclass";
}
@end
@implementation BUYModelManager (BUYDirtyTracked)
+ (BUYModelManager *)testModelManager
{
static dispatch_once_t onceToken;
static BUYModelManager *modelManager;
dispatch_once(&onceToken, ^{
NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:@[[NSBundle bundleForClass:self]]];
modelManager = [[BUYModelManager alloc] initWithModel:model];
});
return modelManager;
}
@end
......@@ -33,44 +33,44 @@
/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
841ADDFF1CB6C942000004B0 /* NSArray+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEB1CB6C942000004B0 /* NSArray+BUYAdditions.h */; };
841ADE001CB6C942000004B0 /* NSArray+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEB1CB6C942000004B0 /* NSArray+BUYAdditions.h */; };
841ADDFF1CB6C942000004B0 /* NSArray+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEB1CB6C942000004B0 /* NSArray+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE001CB6C942000004B0 /* NSArray+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEB1CB6C942000004B0 /* NSArray+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE011CB6C942000004B0 /* NSArray+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDEC1CB6C942000004B0 /* NSArray+BUYAdditions.m */; };
841ADE021CB6C942000004B0 /* NSArray+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDEC1CB6C942000004B0 /* NSArray+BUYAdditions.m */; };
841ADE031CB6C942000004B0 /* NSDate+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDED1CB6C942000004B0 /* NSDate+BUYAdditions.h */; };
841ADE041CB6C942000004B0 /* NSDate+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDED1CB6C942000004B0 /* NSDate+BUYAdditions.h */; };
841ADE031CB6C942000004B0 /* NSDate+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDED1CB6C942000004B0 /* NSDate+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE041CB6C942000004B0 /* NSDate+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDED1CB6C942000004B0 /* NSDate+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE051CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDEE1CB6C942000004B0 /* NSDate+BUYAdditions.m */; };
841ADE061CB6C942000004B0 /* NSDate+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDEE1CB6C942000004B0 /* NSDate+BUYAdditions.m */; };
841ADE071CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEF1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h */; };
841ADE081CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEF1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h */; };
841ADE071CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEF1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE081CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDEF1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE091CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF01CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m */; };
841ADE0A1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF01CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m */; };
841ADE0B1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF11CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h */; };
841ADE0C1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF11CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h */; };
841ADE0B1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF11CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE0C1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF11CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE0D1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF21CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m */; };
841ADE0E1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF21CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m */; };
841ADE0F1CB6C942000004B0 /* NSDictionary+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF31CB6C942000004B0 /* NSDictionary+BUYAdditions.h */; };
841ADE101CB6C942000004B0 /* NSDictionary+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF31CB6C942000004B0 /* NSDictionary+BUYAdditions.h */; };
841ADE0F1CB6C942000004B0 /* NSDictionary+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF31CB6C942000004B0 /* NSDictionary+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE101CB6C942000004B0 /* NSDictionary+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF31CB6C942000004B0 /* NSDictionary+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE111CB6C942000004B0 /* NSDictionary+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF41CB6C942000004B0 /* NSDictionary+BUYAdditions.m */; };
841ADE121CB6C942000004B0 /* NSDictionary+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF41CB6C942000004B0 /* NSDictionary+BUYAdditions.m */; };
841ADE131CB6C942000004B0 /* NSException+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF51CB6C942000004B0 /* NSException+BUYAdditions.h */; };
841ADE141CB6C942000004B0 /* NSException+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF51CB6C942000004B0 /* NSException+BUYAdditions.h */; };
841ADE131CB6C942000004B0 /* NSException+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF51CB6C942000004B0 /* NSException+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE141CB6C942000004B0 /* NSException+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF51CB6C942000004B0 /* NSException+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE151CB6C942000004B0 /* NSException+BUYModelAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF61CB6C942000004B0 /* NSException+BUYModelAdditions.m */; };
841ADE161CB6C942000004B0 /* NSException+BUYModelAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF61CB6C942000004B0 /* NSException+BUYModelAdditions.m */; };
841ADE171CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF71CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h */; };
841ADE181CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF71CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h */; };
841ADE171CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF71CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE181CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF71CB6C942000004B0 /* NSRegularExpression+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE191CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF81CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m */; };
841ADE1A1CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDF81CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m */; };
841ADE1B1CB6C942000004B0 /* NSString+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF91CB6C942000004B0 /* NSString+BUYAdditions.h */; };
841ADE1C1CB6C942000004B0 /* NSString+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF91CB6C942000004B0 /* NSString+BUYAdditions.h */; };
841ADE1B1CB6C942000004B0 /* NSString+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF91CB6C942000004B0 /* NSString+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE1C1CB6C942000004B0 /* NSString+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDF91CB6C942000004B0 /* NSString+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE1D1CB6C942000004B0 /* NSString+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFA1CB6C942000004B0 /* NSString+BUYAdditions.m */; };
841ADE1E1CB6C942000004B0 /* NSString+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFA1CB6C942000004B0 /* NSString+BUYAdditions.m */; };
841ADE1F1CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFB1CB6C942000004B0 /* NSURL+BUYAdditions.h */; };
841ADE201CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFB1CB6C942000004B0 /* NSURL+BUYAdditions.h */; };
841ADE1F1CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFB1CB6C942000004B0 /* NSURL+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE201CB6C942000004B0 /* NSURL+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFB1CB6C942000004B0 /* NSURL+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE211CB6C942000004B0 /* NSURL+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFC1CB6C942000004B0 /* NSURL+BUYAdditions.m */; };
841ADE221CB6C942000004B0 /* NSURL+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFC1CB6C942000004B0 /* NSURL+BUYAdditions.m */; };
841ADE231CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFD1CB6C942000004B0 /* NSURLComponents+BUYAdditions.h */; };
841ADE241CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFD1CB6C942000004B0 /* NSURLComponents+BUYAdditions.h */; };
841ADE231CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFD1CB6C942000004B0 /* NSURLComponents+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE241CB6C942000004B0 /* NSURLComponents+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 841ADDFD1CB6C942000004B0 /* NSURLComponents+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
841ADE251CB6C942000004B0 /* NSURLComponents+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFE1CB6C942000004B0 /* NSURLComponents+BUYAdditions.m */; };
841ADE261CB6C942000004B0 /* NSURLComponents+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 841ADDFE1CB6C942000004B0 /* NSURLComponents+BUYAdditions.m */; };
849110311CCE708900E53B93 /* BUYArrayAdditionsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8491102E1CCE708900E53B93 /* BUYArrayAdditionsTests.m */; };
......@@ -88,12 +88,12 @@
84980F2A1CB75AC200CFAB58 /* BUYObjectProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F281CB75AC200CFAB58 /* BUYObjectProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F2C1CB75B5E00CFAB58 /* BUYModelManagerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2B1CB75B5E00CFAB58 /* BUYModelManagerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F2D1CB75B5E00CFAB58 /* BUYModelManagerProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2B1CB75B5E00CFAB58 /* BUYModelManagerProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F321CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2E1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h */; };
84980F331CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2E1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h */; };
84980F321CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2E1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F331CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F2E1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F341CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 84980F2F1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m */; };
84980F351CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 84980F2F1CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m */; };
84980F361CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F301CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h */; };
84980F371CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F301CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h */; };
84980F361CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F301CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F371CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F301CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
84980F381CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 84980F311CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m */; };
84980F391CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 84980F311CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m */; };
84980F4C1CB7613700CFAB58 /* BUYIdentityTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84980F4A1CB7613700CFAB58 /* BUYIdentityTransformer.h */; };
......@@ -120,6 +120,10 @@
849810971CB7E07900CFAB58 /* BUYFlatCollectionTransformer.h in Headers */ = {isa = PBXBuildFile; fileRef = 849810901CB7E07900CFAB58 /* BUYFlatCollectionTransformer.h */; };
849810981CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 849810911CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m */; };
849810991CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m in Sources */ = {isa = PBXBuildFile; fileRef = 849810911CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m */; };
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, ); }; };
84CD7C2F1CC65D7B00B6EE61 /* _BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */; };
84CD7C301CC65D7C00B6EE61 /* _BUYCheckoutAttribute.m in Sources */ = {isa = PBXBuildFile; fileRef = 84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */; };
84D915431CC0359700D334FB /* BUYObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915411CC0359700D334FB /* BUYObserver.h */; settings = {ATTRIBUTES = (Public, ); }; };
84D915441CC0359700D334FB /* BUYObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915411CC0359700D334FB /* BUYObserver.h */; settings = {ATTRIBUTES = (Public, ); }; };
84D915451CC0359700D334FB /* BUYObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915421CC0359700D334FB /* BUYObserver.m */; };
......@@ -134,14 +138,92 @@
84D915521CC03F1600D334FB /* BUYModelManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9154A1CC03F1600D334FB /* BUYModelManager.m */; };
84D915581CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84D915561CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld */; };
84D915591CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 84D915561CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld */; };
84DD12811CC63FE600A2442D /* _BUYCart.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155A1CC0416800D334FB /* _BUYCart.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12821CC63FE600A2442D /* _BUYCart.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155B1CC0416800D334FB /* _BUYCart.m */; };
84DD12831CC63FE600A2442D /* _BUYCartLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155C1CC0416800D334FB /* _BUYCartLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12841CC63FE600A2442D /* _BUYCartLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155D1CC0416800D334FB /* _BUYCartLineItem.m */; };
84DD12851CC63FE600A2442D /* _BUYCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155E1CC0416800D334FB /* _BUYCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12861CC63FE600A2442D /* _BUYCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155F1CC0416800D334FB /* _BUYCollection.m */; };
84DD12871CC63FE600A2442D /* _BUYCustomer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915601CC0416800D334FB /* _BUYCustomer.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12881CC63FE600A2442D /* _BUYCustomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915611CC0416800D334FB /* _BUYCustomer.m */; };
84DD12891CC63FE600A2442D /* _BUYImageLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915621CC0416800D334FB /* _BUYImageLink.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD128A1CC63FE600A2442D /* _BUYImageLink.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915631CC0416800D334FB /* _BUYImageLink.m */; };
84DD128B1CC63FE600A2442D /* _BUYLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915641CC0416800D334FB /* _BUYLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD128C1CC63FE600A2442D /* _BUYLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915651CC0416800D334FB /* _BUYLineItem.m */; };
84DD128D1CC63FE600A2442D /* _BUYOption.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915661CC0416800D334FB /* _BUYOption.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD128E1CC63FE600A2442D /* _BUYOption.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915671CC0416800D334FB /* _BUYOption.m */; };
84DD128F1CC63FE600A2442D /* _BUYOptionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915681CC0416800D334FB /* _BUYOptionValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12901CC63FE600A2442D /* _BUYOptionValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915691CC0416800D334FB /* _BUYOptionValue.m */; };
84DD12911CC63FE600A2442D /* _BUYOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156A1CC0416800D334FB /* _BUYOrder.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12921CC63FE600A2442D /* _BUYOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156B1CC0416800D334FB /* _BUYOrder.m */; };
84DD12931CC63FE600A2442D /* _BUYProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156C1CC0416800D334FB /* _BUYProduct.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12941CC63FE600A2442D /* _BUYProduct.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156D1CC0416800D334FB /* _BUYProduct.m */; };
84DD12951CC63FE600A2442D /* _BUYProductVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156E1CC0416800D334FB /* _BUYProductVariant.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12961CC63FE600A2442D /* _BUYProductVariant.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156F1CC0416800D334FB /* _BUYProductVariant.m */; };
84DD12971CC63FE600A2442D /* _BUYShop.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915701CC0416800D334FB /* _BUYShop.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12981CC63FE600A2442D /* _BUYShop.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915711CC0416800D334FB /* _BUYShop.m */; };
84DD12991CC63FE600A2442D /* _BUYCart.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155A1CC0416800D334FB /* _BUYCart.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD129A1CC63FE600A2442D /* _BUYCart.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155B1CC0416800D334FB /* _BUYCart.m */; };
84DD129B1CC63FE600A2442D /* _BUYCartLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155C1CC0416800D334FB /* _BUYCartLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD129C1CC63FE600A2442D /* _BUYCartLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155D1CC0416800D334FB /* _BUYCartLineItem.m */; };
84DD129D1CC63FE600A2442D /* _BUYCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9155E1CC0416800D334FB /* _BUYCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD129E1CC63FE600A2442D /* _BUYCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9155F1CC0416800D334FB /* _BUYCollection.m */; };
84DD129F1CC63FE600A2442D /* _BUYCustomer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915601CC0416800D334FB /* _BUYCustomer.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12A01CC63FE600A2442D /* _BUYCustomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915611CC0416800D334FB /* _BUYCustomer.m */; };
84DD12A11CC63FE600A2442D /* _BUYImageLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915621CC0416800D334FB /* _BUYImageLink.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12A21CC63FE600A2442D /* _BUYImageLink.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915631CC0416800D334FB /* _BUYImageLink.m */; };
84DD12A31CC63FE600A2442D /* _BUYLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915641CC0416800D334FB /* _BUYLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12A41CC63FE600A2442D /* _BUYLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915651CC0416800D334FB /* _BUYLineItem.m */; };
84DD12A51CC63FE600A2442D /* _BUYOption.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915661CC0416800D334FB /* _BUYOption.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12A61CC63FE600A2442D /* _BUYOption.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915671CC0416800D334FB /* _BUYOption.m */; };
84DD12A71CC63FE600A2442D /* _BUYOptionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915681CC0416800D334FB /* _BUYOptionValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12A81CC63FE600A2442D /* _BUYOptionValue.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915691CC0416800D334FB /* _BUYOptionValue.m */; };
84DD12A91CC63FE600A2442D /* _BUYOrder.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156A1CC0416800D334FB /* _BUYOrder.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12AA1CC63FE600A2442D /* _BUYOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156B1CC0416800D334FB /* _BUYOrder.m */; };
84DD12AB1CC63FE600A2442D /* _BUYProduct.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156C1CC0416800D334FB /* _BUYProduct.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12AC1CC63FE600A2442D /* _BUYProduct.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156D1CC0416800D334FB /* _BUYProduct.m */; };
84DD12AD1CC63FE600A2442D /* _BUYProductVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D9156E1CC0416800D334FB /* _BUYProductVariant.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12AE1CC63FE600A2442D /* _BUYProductVariant.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D9156F1CC0416800D334FB /* _BUYProductVariant.m */; };
84DD12AF1CC63FE600A2442D /* _BUYShop.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915701CC0416800D334FB /* _BUYShop.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12B01CC63FE600A2442D /* _BUYShop.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915711CC0416800D334FB /* _BUYShop.m */; };
84DD12B11CC63FEE00A2442D /* _BUYAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915A81CC0417700D334FB /* _BUYAddress.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12B21CC63FEE00A2442D /* _BUYAddress.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915A91CC0417700D334FB /* _BUYAddress.m */; };
84DD12B31CC63FEE00A2442D /* _BUYCheckout.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AA1CC0417700D334FB /* _BUYCheckout.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12B41CC63FEE00A2442D /* _BUYCheckout.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AB1CC0417700D334FB /* _BUYCheckout.m */; };
84DD12B51CC63FEE00A2442D /* _BUYDiscount.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AC1CC0417700D334FB /* _BUYDiscount.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12B61CC63FEE00A2442D /* _BUYDiscount.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AD1CC0417700D334FB /* _BUYDiscount.m */; };
84DD12B71CC63FEE00A2442D /* _BUYGiftCard.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AE1CC0417700D334FB /* _BUYGiftCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12B81CC63FEE00A2442D /* _BUYGiftCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AF1CC0417700D334FB /* _BUYGiftCard.m */; };
84DD12B91CC63FEE00A2442D /* _BUYMaskedCreditCard.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B01CC0417700D334FB /* _BUYMaskedCreditCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12BA1CC63FEE00A2442D /* _BUYMaskedCreditCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B11CC0417700D334FB /* _BUYMaskedCreditCard.m */; };
84DD12BB1CC63FEE00A2442D /* _BUYShippingRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B21CC0417700D334FB /* _BUYShippingRate.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12BC1CC63FEE00A2442D /* _BUYShippingRate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B31CC0417700D334FB /* _BUYShippingRate.m */; };
84DD12BD1CC63FEE00A2442D /* _BUYTaxLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B41CC0417700D334FB /* _BUYTaxLine.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12BE1CC63FEE00A2442D /* _BUYTaxLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B51CC0417700D334FB /* _BUYTaxLine.m */; };
84DD12BF1CC63FEE00A2442D /* _BUYAddress.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915A81CC0417700D334FB /* _BUYAddress.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12C01CC63FEE00A2442D /* _BUYAddress.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915A91CC0417700D334FB /* _BUYAddress.m */; };
84DD12C11CC63FEE00A2442D /* _BUYCheckout.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AA1CC0417700D334FB /* _BUYCheckout.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12C21CC63FEE00A2442D /* _BUYCheckout.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AB1CC0417700D334FB /* _BUYCheckout.m */; };
84DD12C31CC63FEE00A2442D /* _BUYDiscount.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AC1CC0417700D334FB /* _BUYDiscount.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12C41CC63FEE00A2442D /* _BUYDiscount.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AD1CC0417700D334FB /* _BUYDiscount.m */; };
84DD12C51CC63FEE00A2442D /* _BUYGiftCard.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915AE1CC0417700D334FB /* _BUYGiftCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12C61CC63FEE00A2442D /* _BUYGiftCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915AF1CC0417700D334FB /* _BUYGiftCard.m */; };
84DD12C71CC63FEE00A2442D /* _BUYMaskedCreditCard.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B01CC0417700D334FB /* _BUYMaskedCreditCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12C81CC63FEE00A2442D /* _BUYMaskedCreditCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B11CC0417700D334FB /* _BUYMaskedCreditCard.m */; };
84DD12C91CC63FEE00A2442D /* _BUYShippingRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B21CC0417700D334FB /* _BUYShippingRate.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12CA1CC63FEE00A2442D /* _BUYShippingRate.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B31CC0417700D334FB /* _BUYShippingRate.m */; };
84DD12CB1CC63FEE00A2442D /* _BUYTaxLine.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915B41CC0417700D334FB /* _BUYTaxLine.h */; settings = {ATTRIBUTES = (Public, ); }; };
84DD12CC1CC63FEE00A2442D /* _BUYTaxLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915B51CC0417700D334FB /* _BUYTaxLine.m */; };
84DD12CD1CC6401400A2442D /* BUYCustomer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915721CC0416800D334FB /* BUYCustomer.h */; };
84DD12CE1CC6401400A2442D /* BUYCustomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915731CC0416800D334FB /* BUYCustomer.m */; };
84DD12CF1CC6401400A2442D /* BUYCustomer.h in Headers */ = {isa = PBXBuildFile; fileRef = 84D915721CC0416800D334FB /* BUYCustomer.h */; };
84DD12D01CC6401400A2442D /* BUYCustomer.m in Sources */ = {isa = PBXBuildFile; fileRef = 84D915731CC0416800D334FB /* BUYCustomer.m */; };
9003969B1B601DF400226B73 /* BUYCartLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396991B601DF400226B73 /* BUYCartLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
9003969C1B601DF400226B73 /* BUYCartLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 9003969A1B601DF400226B73 /* BUYCartLineItem.m */; };
900396AC1B627CB900226B73 /* BUYProductView.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396AA1B627CB900226B73 /* BUYProductView.h */; };
900396AD1B627CB900226B73 /* BUYProductView.m in Sources */ = {isa = PBXBuildFile; fileRef = 900396AB1B627CB900226B73 /* BUYProductView.m */; };
900396B01B67BD0A00226B73 /* BUYCheckoutButton.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396AE1B67BD0A00226B73 /* BUYCheckoutButton.h */; };
900396B11B67BD0A00226B73 /* BUYCheckoutButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 900396AF1B67BD0A00226B73 /* BUYCheckoutButton.m */; };
900396F61B69563400226B73 /* BUYCollection+Additions.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396F41B69563400226B73 /* BUYCollection+Additions.h */; };
900396F71B69563400226B73 /* BUYCollection+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 900396F51B69563400226B73 /* BUYCollection+Additions.m */; };
900E7C841B5DA553006F3C81 /* BUYImageKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 900E7C811B5DA32F006F3C81 /* BUYImageKit.h */; };
900E7C851B5DA559006F3C81 /* BUYImageKit.m in Sources */ = {isa = PBXBuildFile; fileRef = 900E7C821B5DA32F006F3C81 /* BUYImageKit.m */; };
901930E31BC5B9BC00D1134E /* BUYApplePayHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = BE33B4EE1B15FF4D0067982B /* BUYApplePayHelpers.m */; };
......@@ -156,18 +238,15 @@
901930EE1BC5B9BC00D1134E /* BUYNavigationController.m in Sources */ = {isa = PBXBuildFile; fileRef = 90516CC21B4F1ED700E35E45 /* BUYNavigationController.m */; };
901930EF1BC5B9BC00D1134E /* BUYVariantSelectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9496B11B4D96D800B38949 /* BUYVariantSelectionViewController.m */; };
901930F21BC5B9BC00D1134E /* BUYOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = 90E83BC31B9F550E00C95A1B /* BUYOrder.m */; };
901930F31BC5B9BC00D1134E /* BUYAddress+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = BE33B4FA1B177EC80067982B /* BUYAddress+Additions.m */; };
901930F41BC5B9BC00D1134E /* BUYProductViewHeaderBackgroundImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 90FC31A71B50371600AFAB51 /* BUYProductViewHeaderBackgroundImageView.m */; };
901930F51BC5B9BC00D1134E /* BUYProductViewHeaderOverlay.m in Sources */ = {isa = PBXBuildFile; fileRef = 907874981B7276BA0023775B /* BUYProductViewHeaderOverlay.m */; };
901930F61BC5B9BC00D1134E /* BUYProductVariantCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 90516C9A1B4D76D900E35E45 /* BUYProductVariantCell.m */; };
901930F71BC5B9BC00D1134E /* BUYTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = 90516CB71B4F0DD500E35E45 /* BUYTheme.m */; };
901930F81BC5B9BC00D1134E /* BUYProductVariant+Options.m in Sources */ = {isa = PBXBuildFile; fileRef = BE1007941B6038150031CEE7 /* BUYProductVariant+Options.m */; };
901930F91BC5B9BC00D1134E /* BUYProductViewErrorView.m in Sources */ = {isa = PBXBuildFile; fileRef = 903BCC7B1B7D1C2D00C21FEB /* BUYProductViewErrorView.m */; };
901930FA1BC5B9BC00D1134E /* BUYLineItem.m in Sources */ = {isa = PBXBuildFile; fileRef = F7FDA16D19C939FF00AF4E93 /* BUYLineItem.m */; };
901930FB1BC5B9BC00D1134E /* BUYCheckoutButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 900396AF1B67BD0A00226B73 /* BUYCheckoutButton.m */; };
901930FC1BC5B9BC00D1134E /* BUYCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = 9089CC5D1BB48D06009726D6 /* BUYCollection.m */; };
901930FD1BC5B9BC00D1134E /* BUYTaxLine.m in Sources */ = {isa = PBXBuildFile; fileRef = 90AFAA5D1B011EA600F21C23 /* BUYTaxLine.m */; };
901930FE1BC5B9BC00D1134E /* BUYCollection+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 900396F51B69563400226B73 /* BUYCollection+Additions.m */; };
901930FF1BC5B9BC00D1134E /* BUYVariantOptionBreadCrumbsView.m in Sources */ = {isa = PBXBuildFile; fileRef = 90DE926F1B9897B6002EF4DA /* BUYVariantOptionBreadCrumbsView.m */; };
901931011BC5B9BC00D1134E /* BUYTheme+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 906EAE421B836DE000976165 /* BUYTheme+Additions.m */; };
901931021BC5B9BC00D1134E /* BUYStoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BE1C4DF41AE98FBB00E21624 /* BUYStoreViewController.m */; };
......@@ -178,7 +257,6 @@
901931081BC5B9BC00D1134E /* BUYRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF52A741A700AC80087DB2C /* BUYRuntime.m */; };
901931091BC5B9BC00D1134E /* BUYCart.m in Sources */ = {isa = PBXBuildFile; fileRef = F773744819C77A210039681C /* BUYCart.m */; };
9019310A1BC5B9BC00D1134E /* BUYPaymentButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 905AA9701B3B32A500CAE037 /* BUYPaymentButton.m */; };
9019310B1BC5B9BC00D1134E /* BUYProduct+Options.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9496B71B4D96F100B38949 /* BUYProduct+Options.m */; };
9019310C1BC5B9BC00D1134E /* BUYGiftCard.m in Sources */ = {isa = PBXBuildFile; fileRef = 42488B331AB8761A005F21A9 /* BUYGiftCard.m */; };
9019310D1BC5B9BC00D1134E /* BUYOptionValueCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BE10079A1B6165EC0031CEE7 /* BUYOptionValueCell.m */; };
9019310E1BC5B9BC00D1134E /* BUYProduct.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF52A7D1A700B0A0087DB2C /* BUYProduct.m */; };
......@@ -213,7 +291,6 @@
9019312E1BC5B9BC00D1134E /* BUYProductDescriptionCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 90516C951B4D76D900E35E45 /* BUYProductDescriptionCell.h */; };
9019312F1BC5B9BC00D1134E /* BUYLineItem.h in Headers */ = {isa = PBXBuildFile; fileRef = F7FDA16C19C939FF00AF4E93 /* BUYLineItem.h */; settings = {ATTRIBUTES = (Public, ); }; };
901931311BC5B9BC00D1134E /* BUYProductViewHeaderOverlay.h in Headers */ = {isa = PBXBuildFile; fileRef = 907874971B7276BA0023775B /* BUYProductViewHeaderOverlay.h */; };
901931331BC5B9BC00D1134E /* BUYAddress+Additions.h in Headers */ = {isa = PBXBuildFile; fileRef = BE33B4F91B177EC80067982B /* BUYAddress+Additions.h */; };
901931341BC5B9BC00D1134E /* BUYViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1C4DF51AE98FBB00E21624 /* BUYViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
901931351BC5B9BC00D1134E /* BUYDiscount.h in Headers */ = {isa = PBXBuildFile; fileRef = 90AFAA681B0139DE00F21C23 /* BUYDiscount.h */; settings = {ATTRIBUTES = (Public, ); }; };
901931361BC5B9BC00D1134E /* BUYProductView.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396AA1B627CB900226B73 /* BUYProductView.h */; };
......@@ -225,7 +302,6 @@
9019313C1BC5B9BC00D1134E /* BUYShop.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A831A700B0A0087DB2C /* BUYShop.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019313D1BC5B9BC00D1134E /* BUYShippingRate.h in Headers */ = {isa = PBXBuildFile; fileRef = 90AFAA641B01398A00F21C23 /* BUYShippingRate.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019313E1BC5B9BC00D1134E /* BUYApplePayAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = F70CE40D1A8BF1D90055BEB8 /* BUYApplePayAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019313F1BC5B9BC00D1134E /* BUYProduct+Options.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9496B61B4D96F100B38949 /* BUYProduct+Options.h */; };
901931401BC5B9BC00D1134E /* BUYTheme+Additions.h in Headers */ = {isa = PBXBuildFile; fileRef = 906EAE411B836DE000976165 /* BUYTheme+Additions.h */; };
901931411BC5B9BC00D1134E /* BUYVariantOptionView.h in Headers */ = {isa = PBXBuildFile; fileRef = 90516CA11B4D771400E35E45 /* BUYVariantOptionView.h */; };
901931421BC5B9BC00D1134E /* BUYMaskedCreditCard.h in Headers */ = {isa = PBXBuildFile; fileRef = BE5DC3611B71022D00B2BC1E /* BUYMaskedCreditCard.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -244,13 +320,11 @@
901931531BC5B9BC00D1134E /* BUYOptionSelectionNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = BEB74A251B554BFB0005A300 /* BUYOptionSelectionNavigationController.h */; };
901931541BC5B9BC00D1134E /* BUYPresentationControllerWithNavigationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 90516CBD1B4F110A00E35E45 /* BUYPresentationControllerWithNavigationController.h */; };
901931551BC5B9BC00D1134E /* BUYPresentationControllerForVariantSelection.h in Headers */ = {isa = PBXBuildFile; fileRef = BEB74A1F1B554BF20005A300 /* BUYPresentationControllerForVariantSelection.h */; };
901931561BC5B9BC00D1134E /* BUYProductVariant+Options.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1007931B6038150031CEE7 /* BUYProductVariant+Options.h */; };
901931571BC5B9BC00D1134E /* BUYObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A931A7010B20087DB2C /* BUYObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
901931581BC5B9BC00D1134E /* BUYRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A731A700AC80087DB2C /* BUYRuntime.h */; };
901931591BC5B9BC00D1134E /* BUYCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BEB74A8E1B55A3D00005A300 /* BUYCollection.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019315A1BC5B9BC00D1134E /* BUYProductImageCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 904606AD1B6BC8D700754173 /* BUYProductImageCollectionViewCell.h */; };
9019315B1BC5B9BC00D1134E /* BUYImageKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 900E7C811B5DA32F006F3C81 /* BUYImageKit.h */; };
9019315C1BC5B9BC00D1134E /* BUYCollection+Additions.h in Headers */ = {isa = PBXBuildFile; fileRef = 900396F41B69563400226B73 /* BUYCollection+Additions.h */; };
9019315E1BC5B9BC00D1134E /* BUYError.h in Headers */ = {isa = PBXBuildFile; fileRef = BE47340D1B66C4EF00AA721A /* BUYError.h */; settings = {ATTRIBUTES = (Public, ); }; };
9019315F1BC5B9BC00D1134E /* BUYProductHeaderCell.h in Headers */ = {isa = PBXBuildFile; fileRef = 90516C971B4D76D900E35E45 /* BUYProductHeaderCell.h */; };
901931601BC5B9BC00D1134E /* BUYProductViewErrorView.h in Headers */ = {isa = PBXBuildFile; fileRef = 903BCC7A1B7D1C2D00C21FEB /* BUYProductViewErrorView.h */; };
......@@ -298,8 +372,6 @@
90F593091B0D5F4C0026B382 /* BUYClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 90F592FD1B0D5F4C0026B382 /* BUYClientTest.m */; };
90F5930A1B0D5F4C0026B382 /* BUYLineItemTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 90F592FE1B0D5F4C0026B382 /* BUYLineItemTest.m */; };
90F5930B1B0D5F4C0026B382 /* BUYObjectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 90F592FF1B0D5F4C0026B382 /* BUYObjectTests.m */; };
BE1007951B6038150031CEE7 /* BUYProductVariant+Options.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1007931B6038150031CEE7 /* BUYProductVariant+Options.h */; };
BE1007961B6038150031CEE7 /* BUYProductVariant+Options.m in Sources */ = {isa = PBXBuildFile; fileRef = BE1007941B6038150031CEE7 /* BUYProductVariant+Options.m */; };
BE10079B1B6165EC0031CEE7 /* BUYOptionValueCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1007991B6165EC0031CEE7 /* BUYOptionValueCell.h */; };
BE10079C1B6165EC0031CEE7 /* BUYOptionValueCell.m in Sources */ = {isa = PBXBuildFile; fileRef = BE10079A1B6165EC0031CEE7 /* BUYOptionValueCell.m */; };
BE47340F1B66C4EF00AA721A /* BUYError.h in Headers */ = {isa = PBXBuildFile; fileRef = BE47340D1B66C4EF00AA721A /* BUYError.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -344,16 +416,12 @@
BE9A64671B503D060033E558 /* BUYShop.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF52A841A700B0A0087DB2C /* BUYShop.m */; };
BE9A64681B503D080033E558 /* BUYOptionValue.h in Headers */ = {isa = PBXBuildFile; fileRef = BEEA83E51B0B76C7000C6483 /* BUYOptionValue.h */; settings = {ATTRIBUTES = (Public, ); }; };
BE9A64691B503D0C0033E558 /* BUYOptionValue.m in Sources */ = {isa = PBXBuildFile; fileRef = BEEA83E61B0B76C7000C6483 /* BUYOptionValue.m */; };
BE9A646A1B503D100033E558 /* BUYProduct+Options.h in Headers */ = {isa = PBXBuildFile; fileRef = BE9496B61B4D96F100B38949 /* BUYProduct+Options.h */; };
BE9A646B1B503D140033E558 /* BUYProduct+Options.m in Sources */ = {isa = PBXBuildFile; fileRef = BE9496B71B4D96F100B38949 /* BUYProduct+Options.m */; };
BE9A646C1B503D180033E558 /* BUYApplePayAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = F70CE40D1A8BF1D90055BEB8 /* BUYApplePayAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; };
BE9A646D1B503D1C0033E558 /* BUYApplePayAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = F70CE40E1A8BF1D90055BEB8 /* BUYApplePayAdditions.m */; };
BE9A646E1B503D1E0033E558 /* BUYRuntime.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AF52A731A700AC80087DB2C /* BUYRuntime.h */; };
BE9A646F1B503D210033E558 /* BUYRuntime.m in Sources */ = {isa = PBXBuildFile; fileRef = 2AF52A741A700AC80087DB2C /* BUYRuntime.m */; };
BE9A64741B503D2E0033E558 /* BUYApplePayHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = BE33B4ED1B15FF4D0067982B /* BUYApplePayHelpers.h */; settings = {ATTRIBUTES = (Public, ); }; };
BE9A64751B503D370033E558 /* BUYApplePayHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = BE33B4EE1B15FF4D0067982B /* BUYApplePayHelpers.m */; };
BE9A64781B503D3F0033E558 /* BUYAddress+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = BE33B4FA1B177EC80067982B /* BUYAddress+Additions.m */; };
BE9A64791B503D420033E558 /* BUYAddress+Additions.h in Headers */ = {isa = PBXBuildFile; fileRef = BE33B4F91B177EC80067982B /* BUYAddress+Additions.h */; };
BE9A647E1B503D930033E558 /* BUYStoreViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1C4DF31AE98FBB00E21624 /* BUYStoreViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
BE9A647F1B503D960033E558 /* BUYStoreViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = BE1C4DF41AE98FBB00E21624 /* BUYStoreViewController.m */; };
BE9A64801B503D990033E558 /* BUYViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = BE1C4DF51AE98FBB00E21624 /* BUYViewController.h */; settings = {ATTRIBUTES = (Public, ); }; };
......@@ -484,6 +552,8 @@
8498108F1CB7E07900CFAB58 /* BUYDeliveryRangeTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYDeliveryRangeTransformer.m; sourceTree = "<group>"; };
849810901CB7E07900CFAB58 /* BUYFlatCollectionTransformer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYFlatCollectionTransformer.h; sourceTree = "<group>"; };
849810911CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYFlatCollectionTransformer.m; 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>"; };
84D915411CC0359700D334FB /* BUYObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYObserver.h; sourceTree = "<group>"; };
84D915421CC0359700D334FB /* BUYObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYObserver.m; sourceTree = "<group>"; };
84D915471CC03F1600D334FB /* BUYManagedObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYManagedObject.h; sourceTree = "<group>"; };
......@@ -538,8 +608,6 @@
900396AB1B627CB900226B73 /* BUYProductView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYProductView.m; path = "Product View/BUYProductView.m"; sourceTree = "<group>"; };
900396AE1B67BD0A00226B73 /* BUYCheckoutButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BUYCheckoutButton.h; path = "Product View/BUYCheckoutButton.h"; sourceTree = "<group>"; };
900396AF1B67BD0A00226B73 /* BUYCheckoutButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYCheckoutButton.m; path = "Product View/BUYCheckoutButton.m"; sourceTree = "<group>"; };
900396F41B69563400226B73 /* BUYCollection+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BUYCollection+Additions.h"; sourceTree = "<group>"; };
900396F51B69563400226B73 /* BUYCollection+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYCollection+Additions.m"; sourceTree = "<group>"; };
900E7C811B5DA32F006F3C81 /* BUYImageKit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYImageKit.h; sourceTree = "<group>"; };
900E7C821B5DA32F006F3C81 /* BUYImageKit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYImageKit.m; sourceTree = "<group>"; };
901931701BC5B9BC00D1134E /* Buy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Buy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
......@@ -622,8 +690,6 @@
90F593001B0D5F4C0026B382 /* BUYTestConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYTestConstants.h; sourceTree = "<group>"; };
90FC31A61B50371600AFAB51 /* BUYProductViewHeaderBackgroundImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; name = BUYProductViewHeaderBackgroundImageView.h; path = "Product View/BUYProductViewHeaderBackgroundImageView.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
90FC31A71B50371600AFAB51 /* BUYProductViewHeaderBackgroundImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYProductViewHeaderBackgroundImageView.m; path = "Product View/BUYProductViewHeaderBackgroundImageView.m"; sourceTree = "<group>"; };
BE1007931B6038150031CEE7 /* BUYProductVariant+Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BUYProductVariant+Options.h"; sourceTree = "<group>"; };
BE1007941B6038150031CEE7 /* BUYProductVariant+Options.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYProductVariant+Options.m"; sourceTree = "<group>"; };
BE1007991B6165EC0031CEE7 /* BUYOptionValueCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYOptionValueCell.h; sourceTree = "<group>"; };
BE10079A1B6165EC0031CEE7 /* BUYOptionValueCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYOptionValueCell.m; sourceTree = "<group>"; };
BE1C4DF31AE98FBB00E21624 /* BUYStoreViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = BUYStoreViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
......@@ -632,8 +698,6 @@
BE1C4DF61AE98FBB00E21624 /* BUYViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = BUYViewController.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
BE33B4ED1B15FF4D0067982B /* BUYApplePayHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYApplePayHelpers.h; sourceTree = "<group>"; };
BE33B4EE1B15FF4D0067982B /* BUYApplePayHelpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYApplePayHelpers.m; sourceTree = "<group>"; };
BE33B4F91B177EC80067982B /* BUYAddress+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BUYAddress+Additions.h"; sourceTree = "<group>"; };
BE33B4FA1B177EC80067982B /* BUYAddress+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYAddress+Additions.m"; sourceTree = "<group>"; };
BE47340D1B66C4EF00AA721A /* BUYError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYError.h; sourceTree = "<group>"; };
BE47340E1B66C4EF00AA721A /* BUYError.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYError.m; sourceTree = "<group>"; };
BE5DC3611B71022D00B2BC1E /* BUYMaskedCreditCard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYMaskedCreditCard.h; sourceTree = "<group>"; };
......@@ -645,14 +709,11 @@
BE9496AF1B4D96D800B38949 /* BUYOptionSelectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYOptionSelectionViewController.m; sourceTree = "<group>"; };
BE9496B01B4D96D800B38949 /* BUYVariantSelectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = BUYVariantSelectionViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
BE9496B11B4D96D800B38949 /* BUYVariantSelectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BUYVariantSelectionViewController.m; sourceTree = "<group>"; };
BE9496B61B4D96F100B38949 /* BUYProduct+Options.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BUYProduct+Options.h"; sourceTree = "<group>"; };
BE9496B71B4D96F100B38949 /* BUYProduct+Options.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "BUYProduct+Options.m"; sourceTree = "<group>"; };
BE98DB4E1BB1ED3E00C29564 /* OHHTTPStubs */ = {isa = PBXFileReference; lastKnownFileType = folder; name = OHHTTPStubs; path = "Mobile Buy SDK Tests/OHHTTPStubs"; sourceTree = "<group>"; };
BE98DB501BB1ED5500C29564 /* libOHHTTPStubs.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libOHHTTPStubs.a; path = "Mobile Buy SDK Tests/OHHTTPStubs/libOHHTTPStubs.a"; sourceTree = "<group>"; };
BE98DB5A1BB1F4D000C29564 /* OHHTTPStubsResponse+Helpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "OHHTTPStubsResponse+Helpers.h"; sourceTree = "<group>"; };
BE98DB5B1BB1F4D000C29564 /* OHHTTPStubsResponse+Helpers.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "OHHTTPStubsResponse+Helpers.m"; sourceTree = "<group>"; };
BE9A64281B503C2F0033E558 /* Buy.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Buy.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BEB74A1B1B5490140005A300 /* BUYCheckout_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BUYCheckout_Private.h; sourceTree = "<group>"; };
BEB74A1F1B554BF20005A300 /* BUYPresentationControllerForVariantSelection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BUYPresentationControllerForVariantSelection.h; path = "Mobile Buy SDK/Product View/Variant Selection/BUYPresentationControllerForVariantSelection.h"; sourceTree = SOURCE_ROOT; };
BEB74A201B554BF20005A300 /* BUYPresentationControllerForVariantSelection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BUYPresentationControllerForVariantSelection.m; path = "Mobile Buy SDK/Product View/Variant Selection/BUYPresentationControllerForVariantSelection.m"; sourceTree = SOURCE_ROOT; };
BEB74A251B554BFB0005A300 /* BUYOptionSelectionNavigationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BUYOptionSelectionNavigationController.h; path = "Mobile Buy SDK/Product View/Variant Selection/BUYOptionSelectionNavigationController.h"; sourceTree = SOURCE_ROOT; };
......@@ -762,6 +823,8 @@
84D915A91CC0417700D334FB /* _BUYAddress.m */,
84D915AA1CC0417700D334FB /* _BUYCheckout.h */,
84D915AB1CC0417700D334FB /* _BUYCheckout.m */,
84CD7C2B1CC65D5500B6EE61 /* _BUYCheckoutAttribute.h */,
84CD7C2C1CC65D5500B6EE61 /* _BUYCheckoutAttribute.m */,
84D915AC1CC0417700D334FB /* _BUYDiscount.h */,
84D915AD1CC0417700D334FB /* _BUYDiscount.m */,
84D915AE1CC0417700D334FB /* _BUYGiftCard.h */,
......@@ -774,7 +837,6 @@
84D915B51CC0417700D334FB /* _BUYTaxLine.m */,
90AFAA601B01390F00F21C23 /* BUYAddress.h */,
90AFAA611B01390F00F21C23 /* BUYAddress.m */,
BEB74A1B1B5490140005A300 /* BUYCheckout_Private.h */,
F773749419C77C260039681C /* BUYCheckout.h */,
F773749519C77C260039681C /* BUYCheckout.m */,
9032F2D81BE9457A00BB9EEF /* BUYCheckoutAttribute.h */,
......@@ -1095,20 +1157,12 @@
F773744519C779C20039681C /* Utils */ = {
isa = PBXGroup;
children = (
BE33B4F91B177EC80067982B /* BUYAddress+Additions.h */,
BE33B4FA1B177EC80067982B /* BUYAddress+Additions.m */,
F70CE40D1A8BF1D90055BEB8 /* BUYApplePayAdditions.h */,
F70CE40E1A8BF1D90055BEB8 /* BUYApplePayAdditions.m */,
BE33B4ED1B15FF4D0067982B /* BUYApplePayHelpers.h */,
BE33B4EE1B15FF4D0067982B /* BUYApplePayHelpers.m */,
900396F41B69563400226B73 /* BUYCollection+Additions.h */,
900396F51B69563400226B73 /* BUYCollection+Additions.m */,
900E7C811B5DA32F006F3C81 /* BUYImageKit.h */,
900E7C821B5DA32F006F3C81 /* BUYImageKit.m */,
BE9496B61B4D96F100B38949 /* BUYProduct+Options.h */,
BE9496B71B4D96F100B38949 /* BUYProduct+Options.m */,
BE1007931B6038150031CEE7 /* BUYProductVariant+Options.h */,
BE1007941B6038150031CEE7 /* BUYProductVariant+Options.m */,
2AF52A731A700AC80087DB2C /* BUYRuntime.h */,
2AF52A741A700AC80087DB2C /* BUYRuntime.m */,
909944471B71B76800C40A33 /* UIFont+BUYAdditions.h */,
......@@ -1161,10 +1215,26 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
901931331BC5B9BC00D1134E /* BUYAddress+Additions.h in Headers */,
9019313F1BC5B9BC00D1134E /* BUYProduct+Options.h in Headers */,
84DD129B1CC63FE600A2442D /* _BUYCartLineItem.h in Headers */,
84DD12BF1CC63FEE00A2442D /* _BUYAddress.h in Headers */,
84DD12AF1CC63FE600A2442D /* _BUYShop.h in Headers */,
84DD12C71CC63FEE00A2442D /* _BUYMaskedCreditCard.h in Headers */,
84DD12C11CC63FEE00A2442D /* _BUYCheckout.h in Headers */,
84DD12CB1CC63FEE00A2442D /* _BUYTaxLine.h in Headers */,
84DD12C51CC63FEE00A2442D /* _BUYGiftCard.h in Headers */,
84DD12A91CC63FE600A2442D /* _BUYOrder.h in Headers */,
84DD129F1CC63FE600A2442D /* _BUYCustomer.h in Headers */,
84DD12991CC63FE600A2442D /* _BUYCart.h in Headers */,
84DD129D1CC63FE600A2442D /* _BUYCollection.h in Headers */,
84DD12A11CC63FE600A2442D /* _BUYImageLink.h in Headers */,
84DD12A51CC63FE600A2442D /* _BUYOption.h in Headers */,
84DD12C31CC63FEE00A2442D /* _BUYDiscount.h in Headers */,
84DD12A71CC63FE600A2442D /* _BUYOptionValue.h in Headers */,
84DD12C91CC63FEE00A2442D /* _BUYShippingRate.h in Headers */,
84DD12A31CC63FE600A2442D /* _BUYLineItem.h in Headers */,
84DD12AB1CC63FE600A2442D /* _BUYProduct.h in Headers */,
84DD12AD1CC63FE600A2442D /* _BUYProductVariant.h in Headers */,
84980F2A1CB75AC200CFAB58 /* BUYObjectProtocol.h in Headers */,
901931561BC5B9BC00D1134E /* BUYProductVariant+Options.h in Headers */,
901931271BC5B9BC00D1134E /* BUYAddress.h in Headers */,
901931281BC5B9BC00D1134E /* BUYApplePayHelpers.h in Headers */,
901931291BC5B9BC00D1134E /* BUYStoreViewController.h in Headers */,
......@@ -1216,11 +1286,13 @@
9019314D1BC5B9BC00D1134E /* BUYVariantOptionBreadCrumbsView.h in Headers */,
9019314E1BC5B9BC00D1134E /* BUYProductViewFooter.h in Headers */,
9019314F1BC5B9BC00D1134E /* BUYOptionSelectionViewController.h in Headers */,
84CD7C2E1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */,
901931501BC5B9BC00D1134E /* BUYOrder.h in Headers */,
901931531BC5B9BC00D1134E /* BUYOptionSelectionNavigationController.h in Headers */,
901931541BC5B9BC00D1134E /* BUYPresentationControllerWithNavigationController.h in Headers */,
84D9154C1CC03F1600D334FB /* BUYManagedObject.h in Headers */,
901931551BC5B9BC00D1134E /* BUYPresentationControllerForVariantSelection.h in Headers */,
84DD12CF1CC6401400A2442D /* BUYCustomer.h in Headers */,
901931571BC5B9BC00D1134E /* BUYObject.h in Headers */,
901931581BC5B9BC00D1134E /* BUYRuntime.h in Headers */,
901931591BC5B9BC00D1134E /* BUYCollection.h in Headers */,
......@@ -1230,7 +1302,6 @@
84980F591CB7617500CFAB58 /* BUYURLTransformer.h in Headers */,
9019315B1BC5B9BC00D1134E /* BUYImageKit.h in Headers */,
84D915501CC03F1600D334FB /* BUYModelManager.h in Headers */,
9019315C1BC5B9BC00D1134E /* BUYCollection+Additions.h in Headers */,
9032F2DB1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */,
9019315E1BC5B9BC00D1134E /* BUYError.h in Headers */,
84980F371CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */,
......@@ -1253,10 +1324,26 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
BE9A64791B503D420033E558 /* BUYAddress+Additions.h in Headers */,
BE9A646A1B503D100033E558 /* BUYProduct+Options.h in Headers */,
84DD12871CC63FE600A2442D /* _BUYCustomer.h in Headers */,
84DD12931CC63FE600A2442D /* _BUYProduct.h in Headers */,
84DD12951CC63FE600A2442D /* _BUYProductVariant.h in Headers */,
84DD12831CC63FE600A2442D /* _BUYCartLineItem.h in Headers */,
84DD12B11CC63FEE00A2442D /* _BUYAddress.h in Headers */,
84DD12971CC63FE600A2442D /* _BUYShop.h in Headers */,
84DD12B91CC63FEE00A2442D /* _BUYMaskedCreditCard.h in Headers */,
84DD12B31CC63FEE00A2442D /* _BUYCheckout.h in Headers */,
84DD12BD1CC63FEE00A2442D /* _BUYTaxLine.h in Headers */,
84DD12B71CC63FEE00A2442D /* _BUYGiftCard.h in Headers */,
84DD12911CC63FE600A2442D /* _BUYOrder.h in Headers */,
84DD12811CC63FE600A2442D /* _BUYCart.h in Headers */,
84DD12851CC63FE600A2442D /* _BUYCollection.h in Headers */,
84DD12891CC63FE600A2442D /* _BUYImageLink.h in Headers */,
84DD128D1CC63FE600A2442D /* _BUYOption.h in Headers */,
84DD12B51CC63FEE00A2442D /* _BUYDiscount.h in Headers */,
84DD128F1CC63FE600A2442D /* _BUYOptionValue.h in Headers */,
84DD12BB1CC63FEE00A2442D /* _BUYShippingRate.h in Headers */,
84DD128B1CC63FE600A2442D /* _BUYLineItem.h in Headers */,
84980F291CB75AC200CFAB58 /* BUYObjectProtocol.h in Headers */,
BE1007951B6038150031CEE7 /* BUYProductVariant+Options.h in Headers */,
BE9A64531B503CBE0033E558 /* BUYAddress.h in Headers */,
BE9A64741B503D2E0033E558 /* BUYApplePayHelpers.h in Headers */,
BE9A647E1B503D930033E558 /* BUYStoreViewController.h in Headers */,
......@@ -1308,11 +1395,13 @@
90DE92701B9897B6002EF4DA /* BUYVariantOptionBreadCrumbsView.h in Headers */,
BEB74A711B5564300005A300 /* BUYProductViewFooter.h in Headers */,
BEB74A791B5564790005A300 /* BUYOptionSelectionViewController.h in Headers */,
84CD7C2D1CC65D5A00B6EE61 /* _BUYCheckoutAttribute.h in Headers */,
90E83BC41B9F550E00C95A1B /* BUYOrder.h in Headers */,
BEB74A281B554BFB0005A300 /* BUYOptionSelectionNavigationController.h in Headers */,
BEB74A691B5564160005A300 /* BUYPresentationControllerWithNavigationController.h in Headers */,
84D9154B1CC03F1600D334FB /* BUYManagedObject.h in Headers */,
BEB74A221B554BF20005A300 /* BUYPresentationControllerForVariantSelection.h in Headers */,
84DD12CD1CC6401400A2442D /* BUYCustomer.h in Headers */,
BE9A645D1B503CE30033E558 /* BUYObject.h in Headers */,
BE9A646E1B503D1E0033E558 /* BUYRuntime.h in Headers */,
BEB74A901B55A3D00005A300 /* BUYCollection.h in Headers */,
......@@ -1322,7 +1411,6 @@
84980F581CB7617500CFAB58 /* BUYURLTransformer.h in Headers */,
900E7C841B5DA553006F3C81 /* BUYImageKit.h in Headers */,
84D9154F1CC03F1600D334FB /* BUYModelManager.h in Headers */,
900396F61B69563400226B73 /* BUYCollection+Additions.h in Headers */,
9032F2DA1BE9457A00BB9EEF /* BUYCheckoutAttribute.h in Headers */,
BE47340F1B66C4EF00AA721A /* BUYError.h in Headers */,
84980F361CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.h in Headers */,
......@@ -1536,6 +1624,7 @@
buildActionMask = 2147483647;
files = (
901930E31BC5B9BC00D1134E /* BUYApplePayHelpers.m in Sources */,
84DD12AA1CC63FE600A2442D /* _BUYOrder.m in Sources */,
901930E41BC5B9BC00D1134E /* BUYOptionSelectionViewController.m in Sources */,
901930E51BC5B9BC00D1134E /* BUYVariantOptionView.m in Sources */,
841ADE1E1CB6C942000004B0 /* NSString+BUYAdditions.m in Sources */,
......@@ -1543,30 +1632,33 @@
901930E61BC5B9BC00D1134E /* BUYPresentationControllerForVariantSelection.m in Sources */,
84980F611CB7617E00CFAB58 /* BUYDateTransformer.m in Sources */,
901930E81BC5B9BC00D1134E /* BUYImageLink.m in Sources */,
84DD129E1CC63FE600A2442D /* _BUYCollection.m in Sources */,
901930E91BC5B9BC00D1134E /* BUYProductVariant.m in Sources */,
84D9154E1CC03F1600D334FB /* BUYManagedObject.m in Sources */,
901930EA1BC5B9BC00D1134E /* BUYProductViewController.m in Sources */,
841ADE021CB6C942000004B0 /* NSArray+BUYAdditions.m in Sources */,
901930EC1BC5B9BC00D1134E /* BUYError.m in Sources */,
841ADE0E1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m in Sources */,
84DD12AE1CC63FE600A2442D /* _BUYProductVariant.m in Sources */,
901930ED1BC5B9BC00D1134E /* BUYProductViewHeader.m in Sources */,
901930EE1BC5B9BC00D1134E /* BUYNavigationController.m in Sources */,
901930EF1BC5B9BC00D1134E /* BUYVariantSelectionViewController.m in Sources */,
901930F21BC5B9BC00D1134E /* BUYOrder.m in Sources */,
901930F31BC5B9BC00D1134E /* BUYAddress+Additions.m in Sources */,
901930F41BC5B9BC00D1134E /* BUYProductViewHeaderBackgroundImageView.m in Sources */,
901930F51BC5B9BC00D1134E /* BUYProductViewHeaderOverlay.m in Sources */,
901930F61BC5B9BC00D1134E /* BUYProductVariantCell.m in Sources */,
849810991CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m in Sources */,
84DD12A41CC63FE600A2442D /* _BUYLineItem.m in Sources */,
901930F71BC5B9BC00D1134E /* BUYTheme.m in Sources */,
901930F81BC5B9BC00D1134E /* BUYProductVariant+Options.m in Sources */,
84DD12CC1CC63FEE00A2442D /* _BUYTaxLine.m in Sources */,
84DD12CA1CC63FEE00A2442D /* _BUYShippingRate.m in Sources */,
901930F91BC5B9BC00D1134E /* BUYProductViewErrorView.m in Sources */,
901930FA1BC5B9BC00D1134E /* BUYLineItem.m in Sources */,
901930FB1BC5B9BC00D1134E /* BUYCheckoutButton.m in Sources */,
849810951CB7E07900CFAB58 /* BUYDeliveryRangeTransformer.m in Sources */,
84DD12B01CC63FE600A2442D /* _BUYShop.m in Sources */,
901930FC1BC5B9BC00D1134E /* BUYCollection.m in Sources */,
901930FD1BC5B9BC00D1134E /* BUYTaxLine.m in Sources */,
901930FE1BC5B9BC00D1134E /* BUYCollection+Additions.m in Sources */,
84980F351CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m in Sources */,
84D915461CC0359700D334FB /* BUYObserver.m in Sources */,
901930FF1BC5B9BC00D1134E /* BUYVariantOptionBreadCrumbsView.m in Sources */,
......@@ -1577,18 +1669,24 @@
901931041BC5B9BC00D1134E /* BUYApplePayAdditions.m in Sources */,
901931051BC5B9BC00D1134E /* BUYOptionSelectionNavigationController.m in Sources */,
901931061BC5B9BC00D1134E /* BUYDiscount.m in Sources */,
84DD129A1CC63FE600A2442D /* _BUYCart.m in Sources */,
841ADE0A1CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m in Sources */,
901931081BC5B9BC00D1134E /* BUYRuntime.m in Sources */,
84DD12C21CC63FEE00A2442D /* _BUYCheckout.m in Sources */,
901931091BC5B9BC00D1134E /* BUYCart.m in Sources */,
9019310A1BC5B9BC00D1134E /* BUYPaymentButton.m in Sources */,
84D915521CC03F1600D334FB /* BUYModelManager.m in Sources */,
84DD129C1CC63FE600A2442D /* _BUYCartLineItem.m in Sources */,
841ADE121CB6C942000004B0 /* NSDictionary+BUYAdditions.m in Sources */,
9019310B1BC5B9BC00D1134E /* BUYProduct+Options.m in Sources */,
9019310C1BC5B9BC00D1134E /* BUYGiftCard.m in Sources */,
841ADE161CB6C942000004B0 /* NSException+BUYModelAdditions.m in Sources */,
84DD12A01CC63FE600A2442D /* _BUYCustomer.m in Sources */,
9019310D1BC5B9BC00D1134E /* BUYOptionValueCell.m in Sources */,
9019310E1BC5B9BC00D1134E /* BUYProduct.m in Sources */,
84DD12C81CC63FEE00A2442D /* _BUYMaskedCreditCard.m in Sources */,
84DD12AC1CC63FE600A2442D /* _BUYProduct.m in Sources */,
9019310F1BC5B9BC00D1134E /* BUYImageView.m in Sources */,
84DD12A21CC63FE600A2442D /* _BUYImageLink.m in Sources */,
901931101BC5B9BC00D1134E /* BUYProductHeaderCell.m in Sources */,
841ADE1A1CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m in Sources */,
9032F2DD1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */,
......@@ -1596,8 +1694,10 @@
901931121BC5B9BC00D1134E /* BUYMaskedCreditCard.m in Sources */,
901931131BC5B9BC00D1134E /* BUYCheckout.m in Sources */,
901931141BC5B9BC00D1134E /* BUYProductViewFooter.m in Sources */,
84DD12A61CC63FE600A2442D /* _BUYOption.m in Sources */,
841ADE261CB6C942000004B0 /* NSURLComponents+BUYAdditions.m in Sources */,
901931151BC5B9BC00D1134E /* BUYPresentationControllerWithNavigationController.m in Sources */,
84DD12D01CC6401400A2442D /* BUYCustomer.m in Sources */,
84980F391CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m in Sources */,
841ADE221CB6C942000004B0 /* NSURL+BUYAdditions.m in Sources */,
901931161BC5B9BC00D1134E /* BUYShippingRate.m in Sources */,
......@@ -1613,8 +1713,13 @@
901931201BC5B9BC00D1134E /* BUYCreditCard.m in Sources */,
901931211BC5B9BC00D1134E /* BUYProductImageCollectionViewCell.m in Sources */,
84980F4F1CB7613700CFAB58 /* BUYIdentityTransformer.m in Sources */,
84CD7C301CC65D7C00B6EE61 /* _BUYCheckoutAttribute.m in Sources */,
84DD12A81CC63FE600A2442D /* _BUYOptionValue.m in Sources */,
901931221BC5B9BC00D1134E /* BUYShop.m in Sources */,
901931231BC5B9BC00D1134E /* BUYObject.m in Sources */,
84DD12C01CC63FEE00A2442D /* _BUYAddress.m in Sources */,
84DD12C61CC63FEE00A2442D /* _BUYGiftCard.m in Sources */,
84DD12C41CC63FEE00A2442D /* _BUYDiscount.m in Sources */,
84D915591CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld in Sources */,
901931241BC5B9BC00D1134E /* BUYProductDescriptionCell.m in Sources */,
);
......@@ -1656,6 +1761,7 @@
buildActionMask = 2147483647;
files = (
BE9A64751B503D370033E558 /* BUYApplePayHelpers.m in Sources */,
84DD12921CC63FE600A2442D /* _BUYOrder.m in Sources */,
BEB74A7A1B55647C0005A300 /* BUYOptionSelectionViewController.m in Sources */,
BEB74A7C1B5564840005A300 /* BUYVariantOptionView.m in Sources */,
841ADE1D1CB6C942000004B0 /* NSString+BUYAdditions.m in Sources */,
......@@ -1663,30 +1769,33 @@
BEB74A241B554BF20005A300 /* BUYPresentationControllerForVariantSelection.m in Sources */,
84980F601CB7617E00CFAB58 /* BUYDateTransformer.m in Sources */,
BE9A645A1B503CD90033E558 /* BUYImageLink.m in Sources */,
84DD12861CC63FE600A2442D /* _BUYCollection.m in Sources */,
BE9A64641B503CFB0033E558 /* BUYProductVariant.m in Sources */,
84D9154D1CC03F1600D334FB /* BUYManagedObject.m in Sources */,
BEB74A2E1B554E8B0005A300 /* BUYProductViewController.m in Sources */,
841ADE011CB6C942000004B0 /* NSArray+BUYAdditions.m in Sources */,
BE4734101B66C4EF00AA721A /* BUYError.m in Sources */,
841ADE0D1CB6C942000004B0 /* NSDecimalNumber+BUYAdditions.m in Sources */,
84DD12961CC63FE600A2442D /* _BUYProductVariant.m in Sources */,
BEB74A741B5564380005A300 /* BUYProductViewHeader.m in Sources */,
BEB74A681B55640F0005A300 /* BUYNavigationController.m in Sources */,
BEB74A7E1B5564890005A300 /* BUYVariantSelectionViewController.m in Sources */,
90E83BC51B9F550E00C95A1B /* BUYOrder.m in Sources */,
BE9A64781B503D3F0033E558 /* BUYAddress+Additions.m in Sources */,
BEB74A761B55643E0005A300 /* BUYProductViewHeaderBackgroundImageView.m in Sources */,
9078749A1B7276BA0023775B /* BUYProductViewHeaderOverlay.m in Sources */,
BEB74A701B5564290005A300 /* BUYProductVariantCell.m in Sources */,
849810981CB7E07900CFAB58 /* BUYFlatCollectionTransformer.m in Sources */,
84DD128C1CC63FE600A2442D /* _BUYLineItem.m in Sources */,
BEB74A2C1B554C370005A300 /* BUYTheme.m in Sources */,
BE1007961B6038150031CEE7 /* BUYProductVariant+Options.m in Sources */,
84DD12BE1CC63FEE00A2442D /* _BUYTaxLine.m in Sources */,
84DD12BC1CC63FEE00A2442D /* _BUYShippingRate.m in Sources */,
903BCC7D1B7D1C2D00C21FEB /* BUYProductViewErrorView.m in Sources */,
BE9A645C1B503CE00033E558 /* BUYLineItem.m in Sources */,
900396B11B67BD0A00226B73 /* BUYCheckoutButton.m in Sources */,
849810941CB7E07900CFAB58 /* BUYDeliveryRangeTransformer.m in Sources */,
84DD12981CC63FE600A2442D /* _BUYShop.m in Sources */,
9089CC5E1BB48D06009726D6 /* BUYCollection.m in Sources */,
BE9A64521B503CB80033E558 /* BUYTaxLine.m in Sources */,
900396F71B69563400226B73 /* BUYCollection+Additions.m in Sources */,
84980F341CB75C2900CFAB58 /* NSEntityDescription+BUYAdditions.m in Sources */,
84D915451CC0359700D334FB /* BUYObserver.m in Sources */,
90DE92711B9897B6002EF4DA /* BUYVariantOptionBreadCrumbsView.m in Sources */,
......@@ -1697,18 +1806,24 @@
BE9A646D1B503D1C0033E558 /* BUYApplePayAdditions.m in Sources */,
BEB74A2A1B554BFB0005A300 /* BUYOptionSelectionNavigationController.m in Sources */,
BE9A64501B503CAD0033E558 /* BUYDiscount.m in Sources */,
84DD12821CC63FE600A2442D /* _BUYCart.m in Sources */,
841ADE091CB6C942000004B0 /* NSDateFormatter+BUYAdditions.m in Sources */,
BE9A646F1B503D210033E558 /* BUYRuntime.m in Sources */,
84DD12B41CC63FEE00A2442D /* _BUYCheckout.m in Sources */,
BE9A644A1B503C980033E558 /* BUYCart.m in Sources */,
BE9A64831B503DB10033E558 /* BUYPaymentButton.m in Sources */,
84D915511CC03F1600D334FB /* BUYModelManager.m in Sources */,
84DD12841CC63FE600A2442D /* _BUYCartLineItem.m in Sources */,
841ADE111CB6C942000004B0 /* NSDictionary+BUYAdditions.m in Sources */,
BE9A646B1B503D140033E558 /* BUYProduct+Options.m in Sources */,
BE9A64581B503CD10033E558 /* BUYGiftCard.m in Sources */,
841ADE151CB6C942000004B0 /* NSException+BUYModelAdditions.m in Sources */,
84DD12881CC63FE600A2442D /* _BUYCustomer.m in Sources */,
BE10079C1B6165EC0031CEE7 /* BUYOptionValueCell.m in Sources */,
BE9A64621B503CF40033E558 /* BUYProduct.m in Sources */,
84DD12BA1CC63FEE00A2442D /* _BUYMaskedCreditCard.m in Sources */,
84DD12941CC63FE600A2442D /* _BUYProduct.m in Sources */,
BEB74A781B55646F0005A300 /* BUYImageView.m in Sources */,
84DD128A1CC63FE600A2442D /* _BUYImageLink.m in Sources */,
BEB74A6E1B5564230005A300 /* BUYProductHeaderCell.m in Sources */,
841ADE191CB6C942000004B0 /* NSRegularExpression+BUYAdditions.m in Sources */,
9032F2DC1BE9457A00BB9EEF /* BUYCheckoutAttribute.m in Sources */,
......@@ -1716,8 +1831,10 @@
BE5DC3641B71022D00B2BC1E /* BUYMaskedCreditCard.m in Sources */,
BE9A644C1B503C9F0033E558 /* BUYCheckout.m in Sources */,
BEB74A721B5564320005A300 /* BUYProductViewFooter.m in Sources */,
84DD128E1CC63FE600A2442D /* _BUYOption.m in Sources */,
841ADE251CB6C942000004B0 /* NSURLComponents+BUYAdditions.m in Sources */,
BEB74A6A1B5564190005A300 /* BUYPresentationControllerWithNavigationController.m in Sources */,
84DD12CE1CC6401400A2442D /* BUYCustomer.m in Sources */,
84980F381CB75C2900CFAB58 /* NSPropertyDescription+BUYAdditions.m in Sources */,
841ADE211CB6C942000004B0 /* NSURL+BUYAdditions.m in Sources */,
BE9A644E1B503CA60033E558 /* BUYShippingRate.m in Sources */,
......@@ -1733,8 +1850,13 @@
BE9A64561B503CC90033E558 /* BUYCreditCard.m in Sources */,
904606B01B6BC8D700754173 /* BUYProductImageCollectionViewCell.m in Sources */,
84980F4E1CB7613700CFAB58 /* BUYIdentityTransformer.m in Sources */,
84CD7C2F1CC65D7B00B6EE61 /* _BUYCheckoutAttribute.m in Sources */,
84DD12901CC63FE600A2442D /* _BUYOptionValue.m in Sources */,
BE9A64671B503D060033E558 /* BUYShop.m in Sources */,
BE9A645E1B503CE60033E558 /* BUYObject.m in Sources */,
84DD12B21CC63FEE00A2442D /* _BUYAddress.m in Sources */,
84DD12B81CC63FEE00A2442D /* _BUYGiftCard.m in Sources */,
84DD12B61CC63FEE00A2442D /* _BUYDiscount.m in Sources */,
84D915581CC040C300D334FB /* Mobile Buy SDK.xcdatamodeld in Sources */,
BEB74A6C1B55641D0005A300 /* BUYProductDescriptionCell.m in Sources */,
);
......
......@@ -39,7 +39,6 @@ extern NSString * const BUYJSONPropertyKeyUserInfoKey; // = @"JSONPropertyK
* The name of a value transformer used to convert to JSON values and back.
* Uses the value specified in the property's user info dictionary under the "JSONValueTransformer" key.
*
* Currently only two transformers are supported: "BUYPublicationsDate" and "BUYShippingRateDate".
* Currently, only attributes (instances of NSAttributeDescription) use value transformers.
*/
@property (nonatomic, readonly, getter=buy_JSONValueTransformerName) NSString *JSONValueTransformerName;
......
......@@ -46,6 +46,8 @@ NSString * const BUYJSONPropertyKeyUserInfoKey = @"JSONPropertyKey";
// This is defined by mogenerator
static NSString * const BUYAttributeValueClassNameKey = @"attributeValueClassName";
static NSString * const BUYDateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ";
#pragma mark -
@interface NSObject (BUYValueTransforming)
......@@ -69,6 +71,7 @@ static NSString * const BUYAttributeValueClassNameKey = @"attributeValueClassNam
// value type transformers
[NSValueTransformer setValueTransformer:[[BUYURLTransformer alloc] init] forName:BUYURLTransformerName];
[NSValueTransformer setValueTransformer:[BUYDateTransformer dateTransformerWithFormat:BUYDateFormat] forName:BUYDateTransformerName];
});
return self.userInfo[BUYJSONValueTransformerUserInfoKey];
}
......
......@@ -68,3 +68,16 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYStoreViewController.h>
#import <Buy/BUYTheme.h>
#import <Buy/BUYViewController.h>
#import <Buy/NSArray+BUYAdditions.h>
#import <Buy/NSDateFormatter+BUYAdditions.h>
#import <Buy/NSDecimalNumber+BUYAdditions.h>
#import <Buy/NSDictionary+BUYAdditions.h>
#import <Buy/NSDictionary+BUYAdditions.h>
#import <Buy/NSEntityDescription+BUYAdditions.h>
#import <Buy/NSException+BUYAdditions.h>
#import <Buy/NSPropertyDescription+BUYAdditions.h>
#import <Buy/NSRegularExpression+BUYAdditions.h>
#import <Buy/NSString+BUYAdditions.h>
#import <Buy/NSURL+BUYAdditions.h>
#import <Buy/NSURLComponents+BUYAdditions.h>
......@@ -25,10 +25,10 @@
//
@import Foundation;
#import "BUYSerializable.h"
@class PKPaymentToken;
@class BUYAccountCredentials;
@class BUYCart;
@class BUYCheckout;
@class BUYCreditCard;
......@@ -37,6 +37,8 @@
@class BUYProductVariant;
@class BUYShop;
@class BUYCollection;
@class BUYOrder;
@class BUYModelManager;
/**
* The sort order for products in a collection
......@@ -176,12 +178,10 @@ typedef void (^BUYDataProductBlock)(BUYProduct *product, NSError *error);
typedef void (^BUYDataProductsBlock)(NSArray<BUYProduct *> *products, NSError *error);
/**
* Return block containing a list of BUYCollection objects
* Return block containing list of collections
*
* @param collections An array of BUYCollection objects
* @param page Index of the page requested
* @param reachedEnd Boolean indicating whether additional pages exist
* @param error An optional NSError
* @param error Optional NSError
*/
typedef void (^BUYDataCollectionsListBlock)(NSArray<BUYCollection *> *collections, NSUInteger page, BOOL reachedEnd, NSError *error);
......@@ -232,6 +232,11 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
- (instancetype)initWithShopDomain:(NSString *)shopDomain apiKey:(NSString *)apiKey appId:(NSString *)appId NS_DESIGNATED_INITIALIZER;
/**
*
*/
@property (nonatomic, strong) BUYModelManager *modelManager;
/**
* Queue where callbacks will be called
* defaults to main queue
*/
......@@ -260,7 +265,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
/**
* The Merchant ID is used for Apple Pay and set using `enableApplePayWithMerchantId:`
*/
@property (nonatomic, strong, readonly) NSString *merchantId DEPRECATED_MSG_ATTRIBUTE("Set the `merchantId` on a BUYViewController subclass");
@property (nonatomic, strong, readonly) NSString *merchantId NS_DEPRECATED_IOS(8_0, 9_0, "Set the `merchantId` on a BUYViewController subclass instead");
/**
* Application name to attribute orders to. Defaults to app bundle name (CFBundleName)
......@@ -515,7 +520,7 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
*
* @return The associated NSURLSessionDataTask
*/
- (NSURLSessionDataTask *)storeCreditCard:(id <BUYSerializable>)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block;
- (NSURLSessionDataTask *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block;
/**
* Convenience method to release all product inventory reservations by setting its
......@@ -536,6 +541,6 @@ typedef void (^BUYDataGiftCardBlock)(BUYGiftCard *giftCard, NSError *error);
*
* @param merchantId The Merchant ID generated on Shopify Admin
*/
- (void)enableApplePayWithMerchantId:(NSString *)merchantId DEPRECATED_MSG_ATTRIBUTE("Set the merchantId on a BUYViewController subclass instead");
- (void)enableApplePayWithMerchantId:(NSString *)merchantId NS_DEPRECATED_IOS(8_0, 9_0, "Set the merchantId on a `BUYViewController` subclass instead");
@end
......@@ -24,20 +24,22 @@
// THE SOFTWARE.
//
#import "BUYClient_Internal.h"
#import "BUYAddress.h"
#import "BUYCart.h"
#import "BUYCheckout.h"
#import "BUYCheckout_Private.h"
#import "BUYCreditCard.h"
#import "BUYClient.h"
#import "BUYCollection.h"
#import "BUYCollection+Additions.h"
#import "BUYError.h"
#import "BUYGiftCard.h"
#import "BUYModelManager.h"
#import "BUYOrder.h"
#import "BUYProduct.h"
#import "BUYShippingRate.h"
#import "BUYShop.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "NSURLComponents+BUYAdditions.h"
#if __has_include(<PassKit/PassKit.h>)
......@@ -47,18 +49,22 @@
#define kGET @"GET"
#define kPOST @"POST"
#define kPATCH @"PATCH"
#define kPUT @"PUT"
#define kDELETE @"DELETE"
#define kJSONType @"application/json"
#define kShopifyError @"shopify"
#define kMinSuccessfulStatusCode 200
#define kMaxSuccessfulStatusCode 299
NSString * const BUYVersionString = @"1.2.6";
NSString * const BUYVersionString = @"1.3";
NSString *const kShopifyError = @"shopify";
static NSString *const kBUYClientPathProductPublications = @"product_listings";
static NSString *const kBUYClientPathCollectionPublications = @"collection_listings";
NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token";
@interface BUYClient () <NSURLSessionDelegate>
@property (nonatomic, strong) NSString *shopDomain;
......@@ -83,18 +89,19 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
self = [super init];
if (self) {
self.modelManager = [BUYModelManager modelManager];
self.shopDomain = shopDomain;
self.apiKey = apiKey;
self.appId = appId;
self.applicationName = [[NSBundle mainBundle] infoDictionary][@"CFBundleName"] ?: @"";
self.queue = dispatch_get_main_queue();
self.session = [self createUrlSession];
self.session = [self urlSession];
self.pageSize = 25;
}
return self;
}
- (NSURLSession *)createUrlSession
- (NSURLSession *)urlSession
{
NSURLSessionConfiguration *config = [NSURLSessionConfiguration defaultSessionConfiguration];
......@@ -124,7 +131,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
return [self getRequestForURL:shopComponents.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
BUYShop *shop = nil;
if (json && error == nil) {
shop = [[BUYShop alloc] initWithDictionary:json];
shop = [self.modelManager insertShopWithJSONDictionary:json];
}
block(shop, error);
}];
......@@ -140,7 +147,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
NSArray *products = nil;
if (json && error == nil) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
products = [self.modelManager insertProductsWithJSONArray:json[kBUYClientPathProductPublications]];
}
block(products, page, [self hasReachedEndOfPage:products] || error, error);
}];
......@@ -169,7 +176,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
NSArray *products = nil;
if (json && error == nil) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
products = [self.modelManager insertProductsWithJSONArray:json[kBUYClientPathProductPublications]];
}
if (error == nil && [products count] == 0) {
error = [NSError errorWithDomain:kShopifyError code:BUYShopifyError_InvalidProductID userInfo:@{ NSLocalizedDescriptionKey : @"Product IDs are not valid. Confirm the product IDs on your shop's admin and also ensure that the visibility is on for the Mobile App channel." }];
......@@ -194,7 +201,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
NSArray *collections = nil;
if (json && error == nil) {
collections = [BUYCollection convertJSONArray:json[kBUYClientPathCollectionPublications]];
collections = [self.modelManager buy_objectsWithEntityName:[BUYCollection entityName] JSONArray:json[kBUYClientPathCollectionPublications]];
}
block(collections, page, [self hasReachedEndOfPage:collections], error);
}];
......@@ -219,7 +226,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
NSArray *products = nil;
if (json && error == nil) {
products = [BUYProduct convertJSONArray:json[kBUYClientPathProductPublications]];
products = [self.modelManager buy_objectsWithEntityName:[BUYProduct entityName] JSONArray:json[kBUYClientPathProductPublications]];
}
block(products, page, [self hasReachedEndOfPage:products] || error, error);
}];
......@@ -291,7 +298,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
{
BUYCheckout *checkout = nil;
if (error == nil) {
checkout = [[BUYCheckout alloc] initWithDictionary:json[@"checkout"]];
checkout = [self.modelManager insertCheckoutWithJSONDictionary:json[@"checkout"]];
}
block(checkout, error);
}
......@@ -301,7 +308,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
checkout.marketingAttribution = @{@"medium": @"iOS", @"source": self.applicationName};
checkout.sourceName = @"mobile_app";
if (self.urlScheme || checkout.webReturnToURL) {
checkout.webReturnToURL = checkout.webReturnToURL ?: self.urlScheme;
checkout.webReturnToURL = checkout.webReturnToURL ?: [NSURL URLWithString:self.urlScheme];
checkout.webReturnToLabel = checkout.webReturnToLabel ?: [@"Return to " stringByAppendingString:self.applicationName];
}
}
......@@ -317,7 +324,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
- (NSURLSessionDataTask *)createCheckoutWithCartToken:(NSString *)cartToken completion:(BUYDataCheckoutBlock)block
{
BUYCheckout *checkout = [[BUYCheckout alloc] initWithCartToken:cartToken];
BUYCheckout *checkout = [self.modelManager checkoutwithCartToken:cartToken];
[self configureCheckout:checkout];
NSDictionary *json = [checkout jsonDictionaryForCheckout];
......@@ -348,7 +355,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
block(nil, [NSError errorWithDomain:kShopifyError code:BUYShopifyError_NoGiftCardSpecified userInfo:nil]);
}
else {
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithDictionary:@{ @"code" : giftCardCode }];
BUYGiftCard *giftCard = [self.modelManager giftCardWithCode:giftCardCode];
NSURLComponents *components = [self URLComponentsForCheckoutsAppendingPath:@"gift_cards"
checkoutToken:checkout.token
queryItems:nil];
......@@ -389,14 +396,13 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
- (void)updateCheckout:(BUYCheckout *)checkout withGiftCardDictionary:(NSDictionary *)giftCardDictionary addingGiftCard:(BOOL)addingGiftCard
{
NSMutableArray *giftCardArray = [NSMutableArray arrayWithArray:checkout.giftCards];
BUYGiftCard *giftCard = [[BUYGiftCard alloc] initWithDictionary:giftCardDictionary];
if (addingGiftCard) {
[giftCardArray addObject:giftCard];
BUYGiftCard *giftCard = [self.modelManager insertGiftCardWithJSONDictionary:giftCardDictionary];
[checkout.giftCardsSet addObject:giftCard];
} else {
[giftCardArray removeObject:giftCard];
[checkout removeGiftCardWithIdentifier:giftCardDictionary[@"id"]];
}
checkout.giftCards = [giftCardArray copy];
checkout.paymentDue = [NSDecimalNumber buy_decimalNumberFromJSON:giftCardDictionary[@"checkout"][@"payment_due"]];
// Marking the checkout as clean. The properties we have updated above we don't need to re-sync with Shopify.
......@@ -552,7 +558,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
task = [self getRequestForURL:components.URL completionHandler:^(NSDictionary *json, NSURLResponse *response, NSError *error) {
NSArray *shippingRates = nil;
if (error == nil && json) {
shippingRates = [BUYShippingRate convertJSONArray:json[@"shipping_rates"]];
shippingRates = [self.modelManager insertShippingRatesWithJSONArray:json[@"shipping_rates"]];
}
NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
......@@ -567,7 +573,7 @@ static NSString *const kBUYClientPathCollectionPublications = @"collection_listi
#pragma mark - Payments
- (NSURLSessionDataTask *)storeCreditCard:(id <BUYSerializable>)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block
- (NSURLSessionDataTask *)storeCreditCard:(BUYCreditCard *)creditCard checkout:(BUYCheckout *)checkout completion:(BUYDataCreditCardBlock)block
{
NSURLSessionDataTask *task = nil;
......
//
// BUYClient_Internal.h
// Mobile Buy SDK
//
// Created by Gabriel O'Flaherty-Chan on 2016-04-04.
// Copyright © 2016 Shopify Inc. All rights reserved.
//
#import "BUYClient.h"
#import "BUYSerializable.h"
extern NSString *const kShopifyError;
@interface BUYClient (Internal)
- (NSURLSessionDataTask *)postRequestForURL:(NSURL *)url object:(id<BUYSerializable>)object completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler;
- (NSURLSessionDataTask *)putRequestForURL:(NSURL *)url body:(NSData *)body completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler;
- (NSURLSessionDataTask *)getRequestForURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler;
- (NSURLSessionDataTask *)requestForURL:(NSURL *)url method:(NSString *)method body:(NSData *)body additionalHeaders:(NSDictionary *)headers completionHandler:(void (^)(NSDictionary *json, NSURLResponse *response, NSError *error))completionHandler;
- (NSURLComponents *)URLComponentsForAPIPath:(NSString *)apiPath appendingPath:(NSString *)appendingPath queryItems:(NSDictionary*)queryItems;
- (NSError *)extractErrorFromResponse:(NSURLResponse *)response json:(NSDictionary *)json;
@end
......@@ -34,16 +34,11 @@
#import "NSEntityDescription+BUYAdditions.h"
#import "NSPropertyDescription+BUYAdditions.h"
// Custom value transformer names
NSString * const BUYPublicationsDateTransformerName = @"BUYPublicationsDate";
// Structured value transformer names
NSString * const BUYDeliveryRangeTransformerName = @"BUYDeliveryRange";
NSString * const BUYFlatArrayTransformerName = @"BUYFlatArray";
NSString * const BUYProductTagsTransformerName = @"BUYProductTags";
NSString * const BUYPublicationsDateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ";
@interface BUYModelManager ()
@property (nonatomic, strong) NSManagedObjectModel *model;
@end
......@@ -54,10 +49,6 @@ NSString * const BUYPublicationsDateFormat = @"yyyy-MM-dd'T'HH:mm:ssZ";
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// specialty type transformers
[NSValueTransformer setValueTransformer:[BUYDateTransformer dateTransformerWithFormat:BUYPublicationsDateFormat] forName:BUYPublicationsDateTransformerName];
// specialty collection transformers
[NSValueTransformer setValueTransformer:[[BUYDeliveryRangeTransformer alloc] init] forName:BUYDeliveryRangeTransformerName];
[NSValueTransformer setValueTransformer:[BUYFlatCollectionTransformer arrayTransformer] forName:BUYFlatArrayTransformerName];
[NSValueTransformer setValueTransformer:[BUYFlatCollectionTransformer setTransformerWithSeparator:@", "] forName:BUYProductTagsTransformerName];
......
......@@ -27,37 +27,16 @@
#import <Foundation/Foundation.h>
#import <Buy/BUYObjectProtocol.h>
#import <Buy/BUYModelManagerProtocol.h>
/**
* This is the base class for all Shopify model objects.
* This class takes care of convertion .json responses into
* the associated subclass.
*
* You will generally not need to interact with this class directly.
*/
@interface BUYObject : NSObject<BUYObject>
/**
* The identifier of any Shopify model object.
*/
@property (nonatomic, strong, readonly) NSNumber *identifier;
/**
* Objects marked as "dirty" are unsynced with Shopify and will
* sync on any calls to Shopify when updating a checkout.
*/
@property (nonatomic, readonly, getter=isDirty) BOOL dirty;
- (instancetype)initWithDictionary:(NSDictionary *)dictionary;
- (void)updateWithDictionary:(NSDictionary *)dictionary;
+ (NSArray *)convertJSONArray:(NSArray *)json block:(void (^)(id obj))createdBlock;
+ (NSArray *)convertJSONArray:(NSArray *)json;
+ (instancetype)convertObject:(id)object;
#pragma mark - Dirty Property Tracking
- (NSSet *)dirtyProperties;
- (void)markPropertyAsDirty:(NSString *)property;
- (void)markAsClean;
......
......@@ -43,7 +43,7 @@
- (instancetype)init
{
return [self initWithDictionary:nil];
return [self initWithModelManager:nil JSONDictionary:nil];
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionary
......@@ -100,23 +100,6 @@
[self.dirtyObserver reset];
}
- (BOOL)isEqual:(id)object
{
if (self == object) return YES;
if (![object isKindOfClass:self.class]) return NO;
BOOL same = ([self.identifier isEqual:((BUYObject*)object).identifier]);
return same;
}
- (NSUInteger)hash
{
NSUInteger hash = [self.identifier hash];
return hash;
}
- (void)trackDirtyProperties:(NSArray *)properties
{
self.dirtyObserver = [BUYObserver observeProperties:properties ofObject:self];
......@@ -124,29 +107,14 @@
#pragma mark - Dynamic JSON Serialization
+ (NSArray *)propertyNames
{
static NSMutableDictionary *namesCache;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
namesCache = [NSMutableDictionary dictionary];
});
NSString *className = NSStringFromClass(self);
NSArray *names = namesCache[className];
if (names == nil) {
NSMutableSet *allNames = [class_getBUYProperties(self) mutableCopy];
[allNames removeObject:NSStringFromSelector(@selector(dirtyObserver))];
names = [allNames allObjects];
namesCache[className] = names;
}
return names;
- (NSArray *)propertyNames
{
return [self.entity.JSONEncodedProperties allKeys];
}
+ (NSEntityDescription *)entity
- (NSEntityDescription *)entity
{
@throw BUYAbstractMethod();
return [self.modelManager buy_entityWithName:[[self class] entityName]];
}
+ (NSString *)entityName
......@@ -161,23 +129,17 @@
- (instancetype)initWithModelManager:(id<BUYModelManager>)modelManager JSONDictionary:(NSDictionary *)dictionary
{
self = [super init];
self = [self init];
if (self) {
self.modelManager = modelManager;
[self updateWithDictionary:dictionary];
self.JSONDictionary = dictionary;
if ([[self class] tracksDirtyProperties]) {
[self trackDirtyProperties:[[self class] propertyNames]];
[self trackDirtyProperties:[self propertyNames]];
}
}
return self;
}
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
_identifier = dictionary[@"id"];
[self markAsClean];
}
- (NSDictionary *)jsonDictionaryForCheckout
{
return self.JSONDictionary;
......@@ -198,11 +160,6 @@
return NO;
}
- (NSEntityDescription *)entity
{
return [self.modelManager buy_entityWithName:[[self class] entityName]];
}
- (NSDictionary *)JSONDictionary
{
// JSON generation starts in `-buy_JSONForObject`.
......
......@@ -74,11 +74,6 @@
*/
+ (BOOL)tracksDirtyProperties;
/**
* Use the values in the given dictionary to update properties.
*/
- (void)updateWithDictionary:(NSDictionary *)dictionary;
@optional
- (instancetype)initWithModelManager:(id<BUYModelManager>)modelManager JSONDictionary:(NSDictionary *)dictionary;
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10158" systemVersion="15D21" minimumToolsVersion="Xcode 7.0">
<model userDefinedModelVersionIdentifier="" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="10171" systemVersion="15E65" minimumToolsVersion="Xcode 7.0">
<entity name="Address" representedClassName="BUYAddress" syncable="YES">
<attribute name="address1" optional="YES" attributeType="String" syncable="YES">
<userInfo>
......@@ -255,6 +255,7 @@
<entry key="documentation" value="The URL Scheme of the host app."/>
</userInfo>
</attribute>
<relationship name="attributes" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="CheckoutAttribute" inverseName="checkout" inverseEntity="CheckoutAttribute" syncable="YES"/>
<relationship name="billingAddress" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Address" syncable="YES"/>
<relationship name="creditCard" optional="YES" maxCount="1" deletionRule="Cascade" destinationEntity="MaskedCreditCard" inverseName="checkout" inverseEntity="MaskedCreditCard" syncable="YES">
<userInfo>
......@@ -299,6 +300,18 @@
<entry key="documentation" value="The checkout object. This is the main object that you will interact with when creating orders on Shopify."/>
</userInfo>
</entity>
<entity name="CheckoutAttribute" representedClassName="BUYCheckoutAttribute" syncable="YES">
<attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="value" optional="YES" attributeType="String" syncable="YES">
<userInfo>
<entry key="documentation" value="The attribute value."/>
</userInfo>
</attribute>
<relationship name="checkout" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Checkout" inverseName="attributes" inverseEntity="Checkout" syncable="YES"/>
<userInfo>
<entry key="documentation" value="The attribute name."/>
</userInfo>
</entity>
<entity name="Collection" representedClassName="BUYCollection" syncable="YES">
<attribute name="collectionId" optional="YES" attributeType="Integer 64" defaultValueString="0" syncable="YES">
<userInfo>
......@@ -327,7 +340,6 @@
<attribute name="publishedAt" optional="YES" attributeType="Date" syncable="YES">
<userInfo>
<entry key="documentation" value="The publish date for the collection."/>
<entry key="JSONValueTransformer" value="BUYPublicationsDate"/>
</userInfo>
</attribute>
<attribute name="title" optional="YES" attributeType="String" syncable="YES">
......@@ -704,7 +716,6 @@
<attribute name="publishedAt" optional="YES" attributeType="Date" syncable="YES">
<userInfo>
<entry key="documentation" value="The publish date for a product."/>
<entry key="JSONValueTransformer" value="BUYPublicationsDate"/>
</userInfo>
</attribute>
<attribute name="tags" optional="YES" attributeType="Transformable" syncable="YES">
......@@ -972,12 +983,14 @@
<memberEntity name="TaxLine"/>
<memberEntity name="ShippingRate"/>
<memberEntity name="Address"/>
<memberEntity name="CheckoutAttribute"/>
</configuration>
<elements>
<element name="Address" positionX="126" positionY="521" width="128" height="225"/>
<element name="Cart" positionX="-576" positionY="558" width="128" height="60"/>
<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="645"/>
<element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/>
<element name="Collection" positionX="-963" positionY="772" width="128" height="210"/>
<element name="Customer" positionX="106" positionY="1263" width="128" height="60"/>
<element name="Discount" positionX="126" positionY="877" width="128" height="105"/>
......
//
// BUYCart.h
// _BUYCart.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,25 +24,11 @@
// THE SOFTWARE.
//
@import Foundation;
#import "BUYSerializable.h"
#import "_BUYCart.h"
@class BUYLineItem;
@class BUYCartLineItem;
@class BUYProductVariant;
/**
* The BUYCart is the starting point for the Checkout API. You are responsible for building a cart, then transforming it
* into a BUYCheckout using the BUYDataClient.
*/
@interface BUYCart : NSObject <BUYSerializable>
/**
* Array of BUYCartLineItem objects in the cart
* Note: These are different from BUYLineItem objects in that
* the line item objects do include the BUYProductVariant.
*/
@property (nonatomic, strong, readonly, nonnull) NSArray<BUYCartLineItem *> *lineItems;
@interface BUYCart : _BUYCart {}
/**
* Returns true if the cart is acceptable to send to Shopify.
......
//
// BUYCart.m
// _BUYCart.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,94 +25,91 @@
//
#import "BUYCart.h"
#import "BUYCartLineItem.h"
#import "BUYProductVariant.h"
@interface BUYCart ()
@property (nonatomic, strong, nonnull) NSMutableSet<BUYCartLineItem *> *lineItemsSet;
@end
#import "./BUYCartLineItem.h"
#import "BUYModelManager.h"
@implementation BUYCart
#if !defined CORE_DATA_PERSISTENCE
- (instancetype)init
{
self = [super init];
if (self) {
self.lineItemsSet = [[NSMutableSet alloc] init];
self.lineItems = [NSOrderedSet orderedSet];
}
return self;
}
- (nonnull NSArray<BUYCartLineItem *> *)lineItems
{
return [self.lineItemsSet allObjects];
}
#endif
- (BOOL)isValid
{
return [self.lineItemsSet count] > 0;
return [self.lineItems count] > 0;
}
- (void)clearCart
{
[self.lineItemsSet removeAllObjects];
self.lineItems = [NSOrderedSet orderedSet];
}
#pragma mark - Simple Cart Editing
- (void)addVariant:(nonnull BUYProductVariant *)variant
- (void)addVariant:(BUYProductVariant *)variant
{
BUYCartLineItem *lineItem = [[BUYCartLineItem alloc] initWithVariant:variant];
BUYCartLineItem *existingLineItem = [self.lineItemsSet member:lineItem];
if (existingLineItem) {
existingLineItem.quantity = [existingLineItem.quantity decimalNumberByAdding:[NSDecimalNumber one]];
} else {
[self.lineItemsSet addObject:lineItem];
[self willChangeValueForKey:BUYCartRelationships.lineItems];
BUYCartLineItem *lineItem = [self linetItemForVariant:variant];
if (lineItem) {
[lineItem incrementQuantity];
}
else {
// quantity is 1 by default
[self.lineItemsSet addObject:[self newCartLineItemWithVariant:variant]];
}
[self didChangeValueForKey:BUYCartRelationships.lineItems];
}
- (void)removeVariant:(nonnull BUYProductVariant *)variant
- (void)removeVariant:(BUYProductVariant *)variant
{
BUYCartLineItem *lineItem = [[BUYCartLineItem alloc] initWithVariant:variant];
BUYCartLineItem *existingLineItem = [self.lineItemsSet member:lineItem];
if (existingLineItem) {
existingLineItem.quantity = [existingLineItem.quantity decimalNumberBySubtracting:[NSDecimalNumber one]];
if ([[existingLineItem quantity] isEqual:[NSDecimalNumber zero]]) {
[self.lineItemsSet removeObject:existingLineItem];
}
[self willChangeValueForKey:BUYCartRelationships.lineItems];
BUYCartLineItem *lineItem = [self linetItemForVariant:variant];
if (lineItem && [lineItem decrementQuantity].integerValue <= 0) {
[self.lineItemsSet removeObject:lineItem];
}
[self didChangeValueForKey:BUYCartRelationships.lineItems];
}
- (void)setVariant:(nonnull BUYProductVariant *)variant withTotalQuantity:(NSInteger)quantity
- (void)setVariant:(BUYProductVariant *)variant withTotalQuantity:(NSInteger)quantity
{
BUYCartLineItem *lineItem = [[BUYCartLineItem alloc] initWithVariant:variant];
BUYCartLineItem *existingLineItem = [self.lineItemsSet member:lineItem];
if (existingLineItem && quantity > 0) {
existingLineItem.quantity = (NSDecimalNumber*)[NSDecimalNumber numberWithInteger:quantity];
} else if (existingLineItem && quantity == 0) {
[self.lineItemsSet removeObject:existingLineItem];
} else {
lineItem.quantity = (NSDecimalNumber*)[NSDecimalNumber numberWithInteger:quantity];
[self.lineItemsSet addObject:lineItem];
[self willChangeValueForKey:BUYCartRelationships.lineItems];
BUYCartLineItem *lineItem = [self linetItemForVariant:variant];
if (quantity == 0 && lineItem != nil) {
[self.lineItemsSet removeObject:lineItem];
}
else if (quantity > 0) {
if (lineItem == nil) {
lineItem = [self newCartLineItemWithVariant:variant];
[self.lineItemsSet addObject:lineItem];
}
lineItem.quantity = [NSDecimalNumber decimalNumberWithMantissa:quantity exponent:0 isNegative:NO];
}
[self didChangeValueForKey:BUYCartRelationships.lineItems];
}
#pragma mark - Helpers
- (BUYCartLineItem *)newCartLineItemWithVariant:(BUYProductVariant *)variant
{
BUYCartLineItem *lineItem = [self.modelManager buy_objectWithEntityName:[BUYCartLineItem entityName] JSONDictionary:nil];
lineItem.variant = variant;
return lineItem;
}
- (NSDictionary *)jsonDictionaryForCheckout
- (BUYCartLineItem *)linetItemForVariant:(BUYProductVariant *)variant
{
NSMutableDictionary *cart = [[NSMutableDictionary alloc] init];
NSArray *lineItems = [self lineItems];
if ([lineItems count] > 0) {
NSMutableArray *lineItemsJson = [[NSMutableArray alloc] init];
for (BUYCartLineItem *lineItem in lineItems) {
[lineItemsJson addObject:[lineItem jsonDictionaryForCheckout]];
}
cart[@"line_items"] = lineItemsJson;
}
return cart;
return [[self.lineItems filteredOrderedSetUsingPredicate:[NSPredicate predicateWithFormat:@"variant = %@", variant]] lastObject];
}
@end
//
// BUYCartLineItem.h
// _BUYCartLineItem.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,23 +24,48 @@
// THE SOFTWARE.
//
#import "BUYLineItem.h"
#import <Buy/_BUYCartLineItem.h>
/**
* BUYCartLineItem is a subclass of BUYLineItem that extends the object
* by exposing the BUYProductVariant that the line item was initialized with
* using `initWithVariant:`.
*
* Note that this object is only used for a BUYCart and line item objects on
* BUYCheckout are represented by BUYLineItem objects that only contain the
* variant ID (if created from a BUYProductVariant).
* Newly inserted `CartLineItem`s have an initial quantity of 1.
*/
@interface BUYCartLineItem : BUYLineItem
@interface BUYCartLineItem : _BUYCartLineItem {}
/**
* Convenience method for access the identifier of the underlying variant.
*/
- (NSNumber *)variantId;
/**
* The variant price times the quantity.
*/
@property (nonatomic, readonly) NSDecimalNumber *linePrice;
/**
* Add the amount to the current quantity.
*/
- (NSDecimalNumber *)addQuantity:(NSDecimalNumber *)amount;
/**
* The BUYProductVariant object associated with the line item
* when created using the preferred `initWithVariant:` initializer.
* Subtract the amount from the current quantity.
*/
@property (nonatomic, strong, readonly) BUYProductVariant *variant;
- (NSDecimalNumber *)subtractQuantity:(NSDecimalNumber *)amount;
/**
* Add 1 to the existing quantity;
*/
- (NSDecimalNumber *)incrementQuantity;
/**
* Subtract 1 from the existing quantity.
*/
- (NSDecimalNumber *)decrementQuantity;
@end
@interface BUYModelManager (BUYCartLineItemCreation)
- (BUYCartLineItem *)cartLineItemWithVariant:(BUYProductVariant *)variant;
@end
\ No newline at end of file
//
// BUYCartLineItem.m
// _BUYCartLineItem.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -26,39 +26,81 @@
#import "BUYCartLineItem.h"
#import "BUYProductVariant.h"
@interface BUYCartLineItem ()
@property (nonatomic, strong) BUYProductVariant *variant;
@end
#import "BUYModelManager.h"
@implementation BUYCartLineItem
- (instancetype)initWithVariant:(BUYProductVariant *)variant
#if defined CORE_DATA_PERSISTENCE
- (void)awakeFromInsert
{
self = [super initWithVariant:variant];
self.quantity = [NSDecimalNumber one];
}
#else
- (instancetype)init
{
self = [super init];
if (self) {
self.variant = variant;
self.quantity = [NSDecimalNumber one];
}
return self;
}
#endif
+ (NSSet *)keyPathsForValuesAffectingLinePrice
{
NSString *variantPriceKeyPath = [@[BUYCartLineItemRelationships.variant, BUYProductVariantAttributes.price] componentsJoinedByString:@"."];
return [NSSet setWithObjects:BUYCartLineItemAttributes.quantity, variantPriceKeyPath, nil];
}
- (NSNumber *)variantId
{
return self.variant.identifier;
}
- (NSDecimalNumber *)linePrice
{
return [self.quantity decimalNumberByMultiplyingBy:self.variant.price];
}
- (NSDecimalNumber *)addQuantity:(NSDecimalNumber *)amount
{
NSDecimalNumber *quantity = [self.quantity decimalNumberByAdding:amount];
self.quantity = quantity;
return quantity;
}
- (NSDecimalNumber *)subtractQuantity:(NSDecimalNumber *)amount
{
NSDecimalNumber *quantity = self.quantity ?: [NSDecimalNumber zero];
if ([quantity compare:amount] == NSOrderedDescending) {
quantity = [quantity decimalNumberBySubtracting:amount];
}
else {
quantity = [NSDecimalNumber zero];
}
self.quantity = quantity;
return quantity;
}
- (BOOL)isEqual:(id)object
- (NSDecimalNumber *)incrementQuantity
{
if (self == object) return YES;
if (![object isKindOfClass:self.class]) return NO;
BOOL same = ([self.identifier isEqual:((BUYObject*)object).identifier]) || [self.variantId isEqual:((BUYCartLineItem*)object).variant.identifier];
return [self addQuantity:[NSDecimalNumber one]];
}
return same;
- (NSDecimalNumber *)decrementQuantity
{
return [self subtractQuantity:[NSDecimalNumber one]];
}
- (NSUInteger)hash
@end
@implementation BUYModelManager (BUYCartLineItemCreation)
- (BUYCartLineItem *)cartLineItemWithVariant:(BUYProductVariant *)variant
{
NSUInteger hash = [self.identifier hash];
return hash;
BUYCartLineItem *lineItem = [self insertCartLineItemWithJSONDictionary:nil];
lineItem.variant = variant;
return lineItem;
}
@end
//
// BUYCollection.h
// _BUYCollection.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,57 +24,26 @@
// THE SOFTWARE.
//
@import Foundation;
#import "BUYObject.h"
#import <Buy/_BUYCollection.h>
#import "BUYClient.h"
/**
* Represents a collection of products on the shop
*/
@interface BUYCollection : BUYObject
/**
* The title of the collection
*/
@property (nonatomic, strong, readonly) NSString *title;
/**
* The unique collection ID
*/
@property (nonatomic, strong, readonly) NSNumber *collectionId;
@interface BUYCollection : _BUYCollection {}
/**
* The html description
*/
@property (nonatomic, strong, readonly) NSString *htmlDescription;
@property (nonatomic, readonly) NSDate *createdAtDate NS_DEPRECATED_IOS(8_0, 9_0);
@property (nonatomic, readonly) NSDate *updatedAtDate NS_DEPRECATED_IOS(8_0, 9_0);
@property (nonatomic, readonly) NSDate *publishedAtDate NS_DEPRECATED_IOS(8_0, 9_0);
/**
* The collection's image URL
*/
@property (nonatomic, strong, readonly) NSURL *imageURL;
@property (nonatomic, readonly) NSURL *imageURL NS_DEPRECATED_IOS(8_0, 9_0);
/**
* The handle of the collection
*/
@property (nonatomic, strong, readonly) NSString *handle;
/**
* The state of whether the collection is currently published or not
*/
@property (nonatomic, assign, readonly) BOOL published;
/**
* The creation date for the collection
*/
@property (nonatomic, readonly, copy) NSDate *createdAtDate;
/**
* The updated date for the collection
*/
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly) NSString *stringDescription;
/**
* The publish date for the collection
* Converts the BUYCollectionSort enum to an API-compatible string for the collection sort parameter
*
* @param sort BUYCollectionSort enum
*
* @return API-compatible string for the collection sort parameter
*/
@property (nonatomic, readonly, copy) NSDate *publishedAtDate;
+ (NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort;
@end
//
// BUYCollection.m
// _BUYCollection.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,35 +25,64 @@
//
#import "BUYCollection.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSURL+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
@interface BUYCollection ()
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSString *htmlDescription;
@property (nonatomic, strong) NSString *handle;
@property (nonatomic, assign) BOOL published;
@property (nonatomic, strong) NSNumber *collectionId;
@end
#import "BUYImageLink.h"
#import "NSString+BUYAdditions.h"
@implementation BUYCollection
@synthesize stringDescription=_stringDescription;
- (NSDate *)createdAtDate
{
return self.createdAt;
}
- (NSDate *)updatedAtDate
{
return self.updatedAt;
}
- (NSDate *)publishedAtDate
{
return self.publishedAt;
}
- (NSURL *)imageURL
{
return self.image.sourceURL;
}
- (void)updateStringDescription
{
// Force early cache of this value to prevent spooky behaviour
_stringDescription = [[self.htmlDescription buy_stringByStrippingHTML] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (void)setJSONDictionary:(NSDictionary *)JSONDictionary
{
[super setJSONDictionary:JSONDictionary];
[self updateStringDescription];
}
- (void)updateWithDictionary:(NSDictionary *)dictionary
+ (NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort
{
[super updateWithDictionary:dictionary];
_title = dictionary[@"title"];
_htmlDescription = dictionary[@"body_html"];
_imageURL = [NSURL buy_urlWithString:[dictionary buy_objectForKey:@"image"][@"src"]];
_handle = dictionary[@"handle"];
_published = [dictionary[@"published"] boolValue];
_collectionId = dictionary[@"collection_id"];
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForPublications];
_createdAtDate = [dateFormatter dateFromString:dictionary[@"created_at"]];
_updatedAtDate = [dateFormatter dateFromString:dictionary[@"updated_at"]];
_publishedAtDate = [dateFormatter dateFromString:dictionary[@"published_at"]];
switch (sort) {
case BUYCollectionSortBestSelling:
return @"best-selling";
case BUYCollectionSortCreatedAscending:
return @"created-ascending";
case BUYCollectionSortCreatedDescending:
return @"created-descending";
case BUYCollectionSortPriceAscending:
return @"price-ascending";
case BUYCollectionSortPriceDescending:
return @"price-descending";
case BUYCollectionSortTitleAscending:
return @"title-ascending";
case BUYCollectionSortTitleDescending:
return @"title-descending";
default:
return @"collection-default";
}
}
@end
//
// BUYImageLink.h
// _BUYImageLink.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,41 +24,64 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYImageLink.h>
/**
* Products are easier to sell if customers can see pictures of them, which is why there are product images.
*/
@interface BUYImageLink : BUYObject
@import UIKit;
/**
* Specifies the location of the product image.
*/
@property (nonatomic, readonly, copy) NSString *src;
// Defines for common maximum image sizes
typedef NS_ENUM(NSUInteger, BUYImageURLSize) {
BUYImageURLSize100x100,
BUYImageURLSize160x160,
BUYImageURLSize240x240,
BUYImageURLSize480x480,
BUYImageURLSize600x600,
BUYImageURLSize1024x1024,
BUYImageURLSize2048x2048
};
/**
* An array of variant ids associated with the image.
*/
@property (nonatomic, readonly, copy) NSArray<NSNumber *> *variantIds;
@interface BUYImageLink : _BUYImageLink {}
/**
* Creation date of the image
*/
@property (nonatomic, readonly, copy) NSDate *createdAtDate;
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly) NSString *src NS_DEPRECATED_IOS(8_0, 9_0);
@end
@interface BUYImageLink (BUYImageSizing)
/**
* The date the image was last updated
* Generates a link to the image with the specified size
*
* @param size desired maximum size of the image
*
* @return NSURL to the image resourse
*/
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
- (NSURL *)imageURLWithSize:(BUYImageURLSize)size;
@end
@interface NSURL (BUYImageSizing)
/**
* The position of the image for the product
* Generates a link to the image with the specified size
*
* @param size desired maximum size of the image
*
* @return NSURL to the image resourse
*/
@property (nonatomic, readonly, copy) NSNumber *position;
- (instancetype)buy_imageURLWithSize:(BUYImageURLSize)size;
@end
@interface UIView (BUYImageSizing)
/**
* The associated product ID for the image
* Determines the optimal size for the image for the given view
*
* @return the size enum value
*/
@property (nonatomic, readonly, copy) NSNumber *productId;
- (BUYImageURLSize)buy_imageSize;
@end
//
// BUYImageLink.m
// _BUYImageLink.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,22 +25,104 @@
//
#import "BUYImageLink.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "NSURL+BUYAdditions.h"
@implementation BUYImageLink
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (NSDate *)createdAtDate
{
[super updateWithDictionary:dictionary];
return self.createdAt;
}
- (NSDate *)updatedAtDate
{
return self.updatedAt;
}
- (NSString *)src
{
return self.sourceURL.absoluteString;
}
@end
@implementation BUYImageLink (BUYImageSizing)
- (NSURL *)imageURLWithSize:(BUYImageURLSize)size
{
return [self.sourceURL buy_imageURLWithSize:size];
}
+ (NSString *)keyForImageSize:(BUYImageURLSize)size
{
NSString *sizeKey = nil;
switch (size) {
case BUYImageURLSize100x100:
sizeKey = @"_small";
break;
case BUYImageURLSize160x160:
sizeKey = @"_compact";
break;
case BUYImageURLSize240x240:
sizeKey = @"_medium";
break;
case BUYImageURLSize480x480:
sizeKey = @"_large";
break;
case BUYImageURLSize600x600:
sizeKey = @"_grande";
break;
case BUYImageURLSize1024x1024:
sizeKey = @"_1024x1024";
break;
case BUYImageURLSize2048x2048:
sizeKey = @"_2048x2048";
break;
}
return sizeKey;
}
@end
#pragma mark -
@implementation NSURL (BUYImageSizing)
- (instancetype)buy_imageURLWithSize:(BUYImageURLSize)size
{
return [self buy_URLByAppendingFileBaseNameSuffix:[BUYImageLink keyForImageSize:size]];
}
@end
#pragma mark -
@implementation UIView (BUYImageSizing)
- (BUYImageURLSize)buy_imageSize
{
CGFloat scale = [[UIScreen mainScreen] scale];
CGFloat maxDimension = MAX(CGRectGetHeight(self.bounds), CGRectGetWidth(self.bounds));
CGFloat pixelSize = scale * maxDimension;
_src = [dictionary[@"src"] copy];
_variantIds = [dictionary[@"variant_ids"] copy];
_productId = [dictionary[@"product_id"] copy];
_position = [dictionary[@"position"] copy];
if (pixelSize <= 100.0) return BUYImageURLSize100x100;
if (pixelSize <= 160.0) return BUYImageURLSize160x160;
if (pixelSize <= 240.0) return BUYImageURLSize240x240;
if (pixelSize <= 480.0) return BUYImageURLSize480x480;
if (pixelSize <= 600.0) return BUYImageURLSize600x600;
if (pixelSize <= 1024.0) return BUYImageURLSize1024x1024;
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForPublications];
_createdAtDate = [dateFormatter dateFromString:dictionary[@"created_at"]];
_updatedAtDate = [dateFormatter dateFromString:dictionary[@"updated_at"]];
return BUYImageURLSize2048x2048;
}
@end
//
// BUYLineItem.h
// _BUYLineItem.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,104 +24,25 @@
// THE SOFTWARE.
//
#import "BUYSerializable.h"
#import "BUYObject.h"
#import <Buy/_BUYLineItem.h>
#import <Buy/BUYModelManager.h>
@class BUYProductVariant;
@class BUYCartLineItem, BUYProductVariant;
/**
* This represents a BUYLineItem on a BUYCart or on a BUYCheckout.
*/
@interface BUYLineItem : BUYObject <BUYSerializable>
@interface BUYLineItem : _BUYLineItem {}
/**
* The unique line item identifier
*/
@property (nonatomic, strong, readonly) NSString *lineItemIdentifier;
- (instancetype)initWithVariant:(BUYProductVariant *)variant NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead");
- (instancetype)initWithCartLineItem:(BUYCartLineItem *)cartLineItem NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead");
/**
* BUYProductVariant identifer. Keep a reference to a cart or products if you wish to
* display information for product variants in a BUYCheckout
*/
@property (nonatomic, strong, readonly) NSNumber *variantId;
@property (readonly) NSString *lineItemIdentifier NS_DEPRECATED_IOS(8_0, 9_0);
/**
* The `BUYProduct` product ID for the product in the line item
*/
@property (nonatomic, strong, readonly) NSNumber *productId;
/**
* The quantity of the BUYLineItem.
*/
@property (nonatomic, strong) NSDecimalNumber *quantity;
/**
* The weight of the BUYProductVariant in grams.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *grams;
/**
* The price of the BUYLineItem.
* Note: This price does not need to match the product variant.
*/
@property (nonatomic, strong) NSDecimalNumber *price;
/**
* The line price of the item (price * quantity)
*/
@property (nonatomic, strong) NSDecimalNumber *linePrice;
/**
* The competitor's prices for the same item.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *compareAtPrice;
/**
* The title of the BUYLineItem.
* Note: The title does not need to match the product variant.
*/
@property (nonatomic, copy) NSString *title;
/**
* The title for the variant in the line item
*/
@property (nonatomic, copy) NSString *variantTitle;
/**
* YES if this BUYLineItem requires shipping.
* Note: This needs to match the product variant.
*/
@property (nonatomic, strong) NSNumber *requiresShipping;
/**
* The unique SKU for the line item
*/
@property (nonatomic, readonly, copy) NSString *sku;
/**
* If the line item is taxable
*/
@property (nonatomic, readonly, assign) BOOL taxable;
@end
/**
* Custom properties set on the line item
*/
@property (nonatomic, copy) NSDictionary *properties;
@class BUYCartLineItem;
/**
* Service provider who is doing the fulfillment
*/
@property (nonatomic, readonly, copy) NSString *fulfillmentService;
@interface BUYModelManager (BUYLineItemCreation)
/**
* Initialize a BUYLineItem with an optional variant.
* Note: We recommend setting up a BUYCart and using `addVariant:`, which handles incrementing
* existing variants for line items in a cart
*
* @param variant A BUYProductVariant to initialize the BUYLineItem with
*
* @return Returns an instance of BUYLineItem
*/
- (instancetype)initWithVariant:(BUYProductVariant *)variant;
- (BUYLineItem *)lineItemWithVariant:(BUYProductVariant *)variant;
- (BUYLineItem *)lineItemWithCartLineItem:(BUYCartLineItem *)cartLineItem;
@end
//
// BUYLineItem.m
// _BUYLineItem.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -20,96 +20,75 @@
// 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 "BUYLineItem.h"
#import "BUYCartLineItem.h"
#import "BUYProductVariant.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "BUYProduct.h"
@interface BUYLineItem ()
@implementation BUYLineItem
@property (nonatomic, strong) NSString *lineItemIdentifier;
@property (nonatomic, strong) NSNumber *variantId;
@property (nonatomic, strong) NSNumber *productId;
@property (nonatomic, copy) NSString *sku;
@property (nonatomic, readwrite) BOOL taxable;
@property (nonatomic, strong) NSDecimalNumber *compareAtPrice;
@property (nonatomic, strong) NSDecimalNumber *grams;
@property (nonatomic, copy) NSString *fulfillmentService;
/**
* 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;
}
@end
- (instancetype)initWithVariant:(BUYProductVariant *)variant
{
BUYLineItem *lineItem = [[BUYLineItem alloc] initWithModelManager:variant.modelManager JSONDictionary:nil];
[lineItem updateWithVariant:variant];
return lineItem;
}
@implementation BUYLineItem
- (void)updateWithVariant:(BUYProductVariant *)variant
{
self.variantId = variant.identifier;
self.quantity = variant ? [NSDecimalNumber one] : [NSDecimalNumber zero];
self.price = variant.price ?: [NSDecimalNumber zero];
self.title = variant.title ?: @"";
self.requiresShipping = variant.requiresShipping;
self.compareAtPrice = variant.compareAtPrice;
self.grams = variant.grams;
}
- (instancetype)init
- (void)updateWithLineItem:(BUYCartLineItem *)lineItem
{
return [self initWithVariant:nil];
[self updateWithVariant:lineItem.variant];
self.quantity = lineItem.quantity;
}
- (instancetype)initWithVariant:(BUYProductVariant *)variant
- (NSString *)lineItemIdentifier
{
self = [super init];
if (self) {
self.variantId = variant.identifier;
self.productId = variant.product.productId;
self.quantity = variant ? [NSDecimalNumber one] : [NSDecimalNumber zero];
self.price = variant ? [variant price] : [NSDecimalNumber zero];
self.title = variant ? [variant title] : @"";
self.requiresShipping = variant.requiresShipping;
self.compareAtPrice = variant.compareAtPrice;
self.grams = variant.grams;
}
return self;
return self.identifier;
}
- (void)updateWithDictionary:(NSDictionary *)dictionary
@end
@implementation BUYModelManager (BUYLineItemCreation)
- (BUYLineItem *)lineItemWithVariant:(BUYProductVariant *)variant
{
self.lineItemIdentifier = dictionary[@"id"];
self.variantId = dictionary[@"variant_id"];
self.productId = dictionary[@"product_id"];
self.title = dictionary[@"title"];
self.variantTitle = dictionary[@"variant_title"];
self.quantity = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"quantity"]];
self.price = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"price"]];
self.linePrice = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"line_price"]];
self.compareAtPrice = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"compare_at_price"]];
self.requiresShipping = dictionary[@"requires_shipping"];
self.sku = dictionary[@"sku"];
self.taxable = [dictionary[@"taxable"] boolValue];
self.properties = dictionary[@"properties"];
self.grams = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"grams"]];
self.fulfillmentService = [dictionary[@"fulfillment_service"] copy];
BUYLineItem *lineItem = [self insertLineItemWithJSONDictionary:nil];
[lineItem updateWithVariant:variant];
return lineItem;
}
- (NSDictionary *)jsonDictionaryForCheckout
- (BUYLineItem *)lineItemWithCartLineItem:(BUYCartLineItem *)cartLineItem
{
NSMutableDictionary *lineItem = [[NSMutableDictionary alloc] init];
if (self.variantId) {
lineItem[@"variant_id"] = self.variantId;
}
if ([self.title length] > 0) {
lineItem[@"title"] = [self.title buy_trim];
}
if (self.quantity) {
lineItem[@"quantity"] = self.quantity;
}
if (self.price) {
lineItem[@"price"] = self.price;
}
if (self.properties) {
lineItem[@"properties"] = self.properties;
}
lineItem[@"requires_shipping"] = self.requiresShipping ?: @NO;
BUYLineItem *lineItem = [self insertLineItemWithJSONDictionary:nil];
[lineItem updateWithLineItem:cartLineItem];
return lineItem;
}
......
//
// BUYOption.h
// _BUYOption.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,27 +24,8 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYOption.h>
/**
* This represent a BUYOption on a BUYProduct
*/
@interface BUYOption : BUYObject
/**
* Custom product property names like "Size", "Color", and "Material".
* 255 characters limit each.
*/
@property (nonatomic, readonly, copy) NSString *name;
/**
* The order in which the option should optionally appear
*/
@property (nonatomic, readonly, strong) NSNumber *position;
/**
* The associated product ID for this option
*/
@property (nonatomic, readonly, copy) NSNumber *productId;
@interface BUYOption : _BUYOption {}
@end
//
// BUYOption.m
// _BUYOption.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -28,13 +28,4 @@
@implementation BUYOption
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
[super updateWithDictionary:dictionary];
_name = [dictionary[@"name"] copy];
_position = dictionary[@"position"];
_productId = [dictionary[@"product_id"] copy];
}
@end
//
// BUYOptionValue.h
// _BUYOptionValue.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,24 +24,10 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYOptionValue.h>
@interface BUYOptionValue : BUYObject
@interface BUYOptionValue : _BUYOptionValue {}
/**
* Custom product property names like "Size", "Color", and "Material".
* 255 characters limit each.
*/
@property (nonatomic, readonly, copy) NSString *name;
/**
* The value of the option
*/
@property (nonatomic, readonly, strong) NSString *value;
/**
* the option identifier
*/
@property (nonatomic, readonly, strong) NSNumber *optionId;
- (BOOL)isEqualToOptionValue:(BUYOptionValue *)other;
@end
//
// BUYOptionValue.m
// _BUYOptionValue.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -28,37 +28,22 @@
@implementation BUYOptionValue
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (BOOL)isEqualToOptionValue:(BUYOptionValue *)other
{
[super updateWithDictionary:dictionary];
_name = [dictionary[@"name"] copy];
_value = [dictionary[@"value"] copy];
_optionId = [dictionary[@"option_id"] copy];
return [other isKindOfClass:[self class]] && [self.name isEqual:other.name] && [self.optionId isEqual:other.optionId];
}
#if !defined CORE_DATA_PERSISTENCE
- (BOOL)isEqual:(id)object
{
BOOL same = NO;
if (self == object) {
same = YES;
}
else if ([object isKindOfClass:self.class]) {
BUYOptionValue *optionValue = (BUYOptionValue *)object;
same = ([self.optionId isEqualToNumber:optionValue.optionId] &&
[self.value isEqualToString:optionValue.value]);
}
return same;
return [super isEqual:object] || [self isEqualToOptionValue:object];
}
- (NSUInteger)hash
{
NSUInteger hash = [self.value hash];
hash ^= [self.optionId hash];
return hash;
NSUInteger hash = self.name.hash;
return ((hash << 5) + hash) + self.optionId.hash;
}
#endif
@end
//
// BUYOrder.h
// _BUYOrder.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,18 +24,15 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYOrder.h>
@interface BUYOrder : BUYObject
@interface BUYOrder : _BUYOrder {}
/**
* URL for the website showing the order status
*/
@property (nonatomic, strong, readonly) NSURL *statusURL;
@end
@interface BUYModelManager (BUYOrder)
/**
* The customer's order name as represented by a number.
*/
@property (nonatomic, strong, readonly) NSString *name;
- (NSArray<BUYOrder *> *)ordersWithJSONDictionary:(NSDictionary *)json;
@end
//
// BUYOrder.m
// _BUYOrder.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,24 +25,53 @@
//
#import "BUYOrder.h"
#import "NSURL+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "BUYLineItem.h"
@interface BUYOrder ()
@implementation BUYOrder
@property (nonatomic, strong) NSURL *statusURL;
@property (nonatomic, strong) NSString *name;
- (NSArray *)formatIDsForLineItemsJSON:(NSArray<NSDictionary *> *)lineItems
{
__block NSMutableArray<NSDictionary *> *mutableLineItems = [NSMutableArray array];
[lineItems enumerateObjectsUsingBlock:^(NSDictionary * _Nonnull lineItem, NSUInteger idx, BOOL * _Nonnull stop) {
NSNumber *identifier = lineItem[@"id"];
NSMutableDictionary *mutableLineItem = [lineItem mutableCopy];
if ([identifier isKindOfClass:[NSNumber class]]) {
mutableLineItem[@"id"] = identifier.stringValue;
}
[mutableLineItems addObject:mutableLineItem];
}];
return mutableLineItems;
}
- (void)setJSONDictionary:(NSDictionary *)JSONDictionary
{
// TODO: Have API return string IDs for line items instead of numbers
NSArray *fulfilledLineItemsJSON = [self formatIDsForLineItemsJSON:JSONDictionary[@"fulfilled_line_items"]];
NSArray *unFulfilledLineItemsJSON = [self formatIDsForLineItemsJSON:JSONDictionary[@"unfulfilled_line_items"]];
[super setJSONDictionary:JSONDictionary];
// Required if core data is not being used
if (!self.lineItems) {
self.lineItems = [NSOrderedSet orderedSet];
}
NSArray *fulfilledLineItems = [self.modelManager buy_objectsWithEntityName:[BUYLineItem entityName] JSONArray:fulfilledLineItemsJSON];
[fulfilledLineItems makeObjectsPerformSelector:@selector(setFulfilled:) withObject:@YES];
NSArray *unfulfilledLineItems = [self.modelManager buy_objectsWithEntityName:[BUYLineItem entityName] JSONArray:unFulfilledLineItemsJSON];
[self.lineItemsSet addObjectsFromArray:fulfilledLineItems];
[self.lineItemsSet addObjectsFromArray:unfulfilledLineItems];
}
@end
@implementation BUYOrder
@implementation BUYModelManager (BUYOrder)
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (NSArray<BUYOrder *> *)ordersWithJSONDictionary:(NSDictionary *)json
{
[super updateWithDictionary:dictionary];
NSString *statusURLString = dictionary[@"status_url"];
self.statusURL = [NSURL buy_urlWithString:statusURLString];
self.name = [dictionary buy_objectForKey:@"name"];
NSArray *orders = [json objectForKey:@"orders"];
return (id)[self buy_objectsWithEntityName:[BUYOrder entityName] JSONArray:orders];
}
@end
......@@ -24,94 +24,42 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYProduct.h>
@class BUYProductVariant;
@class BUYImageLink;
@class BUYOption;
@interface BUYProduct : _BUYProduct {}
/**
* A BUYProduct is an individual item for sale in a Shopify shop.
*/
@interface BUYProduct : BUYObject
/**
* The product ID
*/
@property (nonatomic, readonly, copy) NSNumber *productId;
/**
* The name of the product. In a shop's catalog, clicking on a product's title takes you to that product's page.
* On a product's page, the product's title typically appears in a large font.
*/
@property (nonatomic, readonly, copy) NSString *title;
/**
* The handle of the product. Can be used to construct links to the web page for the product
*/
@property (nonatomic, readonly, copy) NSString *handle;
/**
* The name of the vendor of the product.
*/
@property (nonatomic, readonly, copy) NSString *vendor;
/**
* A categorization that a product can be tagged with, commonly used for filtering and searching.
*/
@property (nonatomic, readonly, copy) NSString *productType;
/**
* A list of BUYProductVariant objects, each one representing a slightly different version of the product.
*/
@property (nonatomic, readonly, copy) NSArray<BUYProductVariant *> *variants;
/**
* A list of BUYImageLink objects, each one representing an image associated with the product.
*/
@property (nonatomic, readonly, copy) NSArray<BUYImageLink *> *images;
/**
* Custom product property names like "Size", "Color", and "Material".
* Products are based on permutations of these options.
* A product may have a maximum of 3 options. 255 characters limit each.
*/
@property (nonatomic, readonly, copy) NSArray<BUYOption *> *options;
/**
* The description of the product, complete with HTML formatting.
*/
@property (nonatomic, readonly, copy) NSString *htmlDescription;
/**
* If the product is in stock (see each variant for their specific availability)
*/
@property (nonatomic, readonly, assign) BOOL available;
@property (nonatomic, readonly, copy) NSDate *createdAtDate;
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly, copy) NSDate *publishedAtDate;
@property (nonatomic, readonly, copy) NSString *stringDescription;
/**
* A categorization that a product can be tagged with, commonly used for filtering and searching.
* Each tag has a character limit of 255.
*/
@property (nonatomic, readonly, copy) NSSet<NSString *> *tags;
@end
/**
* The product is published on the current sales channel
*/
@property (nonatomic, readonly, assign) BOOL published;
@interface BUYProduct (Options)
/**
* The creation date for a product
* Get the option values available for the given option
*
* @param option the option
*
* @return array of BUYOptionValues
*/
@property (nonatomic, readonly, copy) NSDate *createdAtDate;
- (NSArray *)valuesForOption:(BUYOption *)option variants:(NSArray *)variants;
/**
* The updated date for a product
* Determine the variant given an array of options
*
* @param options array of option values
*
* @return the product variant matching the set of options
*/
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
- (BUYProductVariant *)variantWithOptions:(NSArray *)options;
/**
* The publish date for a product
* Determine if the variant is a default variant automatically created by Shopify
*
* @return YES if its a default variant
*/
@property (nonatomic, readonly, copy) NSDate *publishedAtDate;
- (BOOL)isDefaultVariant;
@end
//
// BUYProduct.m
// _BUYProduct.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,39 +24,94 @@
// THE SOFTWARE.
//
#import "BUYImageLink.h"
#import "BUYOption.h"
#import "BUYProduct.h"
#import "BUYModelManager.h"
#import "BUYOption.h"
#import "BUYOptionValue.h"
#import "BUYProductVariant.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
@implementation BUYProduct
- (void)updateWithDictionary:(NSDictionary *)dictionary
@synthesize stringDescription=_stringDescription;
- (NSDate *)createdAtDate
{
return self.createdAt;
}
- (NSDate *)updatedAtDate
{
return self.updatedAt;
}
- (NSDate *)publishedAtDate
{
[super updateWithDictionary:dictionary];
return self.publishedAt;
}
- (NSString *)stringDescription
{
if (nil == _stringDescription) {
_stringDescription = [self.htmlDescription buy_stringByStrippingHTML];
}
return _stringDescription;
}
@end
@implementation BUYProduct (Options)
- (NSArray *)valuesForOption:(BUYOption *)option variants:(NSArray *)variants
{
NSMutableOrderedSet *set = [NSMutableOrderedSet new];
_title = [dictionary[@"title"] copy];
_handle = [dictionary[@"handle"] copy];
_productId = [dictionary[@"product_id"] copy];
_vendor = [dictionary[@"vendor"] copy];
_productType = [dictionary[@"product_type"] copy];
_variants = [BUYProductVariant convertJSONArray:dictionary[@"variants"] block:^(BUYProductVariant *variant) {
variant.product = self;
}];
_images = [BUYImageLink convertJSONArray:dictionary[@"images"]];
_options = [BUYOption convertJSONArray:dictionary[@"options"]];
_htmlDescription = [dictionary buy_objectForKey:@"body_html"];
_available = [dictionary[@"available"] boolValue];
_published = [dictionary[@"published"] boolValue];
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForPublications];
_createdAtDate = [dateFormatter dateFromString:dictionary[@"created_at"]];
_updatedAtDate = [dateFormatter dateFromString:dictionary[@"updated_at"]];
_publishedAtDate = [dateFormatter dateFromString:dictionary[@"published_at"]];
NSArray *tagsArray = [dictionary[@"tags"] componentsSeparatedByString:@", "];
NSSet *tagsSet = [NSSet setWithArray:tagsArray];
_tags = [tagsSet copy];
for (BUYProductVariant *variant in variants) {
BUYOptionValue *optionValue = [variant optionValueForName:option.name];
[set addObject:optionValue];
}
return [set array];
}
- (BUYProductVariant *)variantWithOptions:(NSArray *)options
{
BUYProductVariant *variant = nil;
for (BUYProductVariant *aVariant in self.variants) {
BOOL match = YES;
for (BUYOptionValue *value in options) {
BUYOptionValue *optionValue = [aVariant optionValueForName:value.name];
if (![optionValue isEqual:value]) {
match = NO;
break;
}
}
if (match) {
variant = aVariant;
}
}
return variant;
}
- (BOOL)isDefaultVariant
{
if ([self.variants count] == 1) {
BUYProductVariant *productVariant = [self.variants firstObject];
BUYOptionValue *optionValue = [productVariant.options anyObject];
NSString *defaultTitleString = @"Default Title";
NSString *defaultString = @"Default";
if ([productVariant.title isEqualToString:defaultTitleString] &&
([optionValue.value isEqualToString:defaultTitleString] || [optionValue.value isEqualToString:defaultString])) {
return YES;
}
}
return NO;
}
@end
//
// BUYProductVariant.h
// _BUYProductVariant.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,72 +24,29 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYProductVariant.h>
@class BUYProduct;
@class BUYOptionValue;
/**
* A BUYProductVariant is a different version of a product, such as differing sizes or differing colours.
*/
@interface BUYProductVariant : BUYObject
/**
* The BUYProduct associated this BUYProductVariant
*/
@property (nonatomic, strong) BUYProduct *product;
/**
* The title of the BUYProductVariant.
*/
@property (nonatomic, readonly, copy) NSString *title;
/**
* Custom properties that a shop owner can use to define BUYProductVariants.
*/
@property (nonatomic, readonly, copy) NSArray<BUYOptionValue *> *options;
/**
* The price of the BUYProductVariant.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *price;
/**
* The competitor's prices for the same item.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *compareAtPrice;
/**
* The weight of the BUYProductVariant in grams.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *grams;
/**
* Specifies whether or not a customer needs to provide a shipping address when placing an order for this BUYProductVariant.
* Valid values are:
* true: Customer needs to supply a shipping address.
* false: Customer does not need to supply a shipping address.
*/
@property (nonatomic, readonly, strong) NSNumber *requiresShipping;
/**
* A unique identifier for the product in the shop.
*/
@property (nonatomic, readonly, strong) NSString *sku;
/**
* Specifies whether or not a tax is charged when the BUYProductVariant is sold.
*/
@property (nonatomic, readonly, strong) NSNumber *taxable;
@interface BUYProductVariant : _BUYProductVariant {}
/**
* The order of the BUYProductVariant in the list of product variants. 1 is the first position.
* Returns the option value for the given name
*
* @param optionName name of the option
*
* @return the option value
*/
@property (nonatomic, readonly, strong) NSNumber *position;
- (BUYOptionValue *)optionValueForName:(NSString *)optionName;
/**
* If the variant is in stock
* Filters array of product variants filtered based on a selected option value
*
* @param productVariants BUYProductVariant objects to filter
* @param optionValue The option value to filter with
*
* @return A filtered copy of the original array
*/
@property (nonatomic, readonly, assign) BOOL available;
+ (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue;
@end
//
// BUYProductVariant.m
// _BUYProductVariant.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,29 +25,32 @@
//
#import "BUYProductVariant.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "BUYOptionValue.h"
@implementation BUYProductVariant
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (BUYOptionValue *)optionValueForName:(NSString *)optionName
{
[super updateWithDictionary:dictionary];
for (BUYOptionValue *value in self.options) {
if ([value.name isEqualToString:optionName]) {
return value;
}
}
_title = [dictionary[@"title"] copy];
_options = [BUYOptionValue convertJSONArray:dictionary[@"option_values"]];
_price = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"price"]];
_compareAtPrice = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"compare_at_price"]];
_grams = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"grams"]];
_requiresShipping = dictionary[@"requires_shipping"];
_sku = dictionary[@"sku"];
_taxable = dictionary[@"taxable"];
_position = dictionary[@"position"];
_available = [dictionary[@"available"] boolValue];
return nil;
}
+ (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue
{
NSMutableArray *filteredArray = [NSMutableArray new];
for (BUYProductVariant *variant in productVariants) {
for (BUYOptionValue *opValue in variant.options) {
if ([opValue isEqual:optionValue]) {
[filteredArray addObject:variant];
}
}
}
return [filteredArray copy];
}
@end
//
// BUYShop.h
// _BUYShop.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,66 +24,8 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYShop.h>
/**
* The BUYShop object is a collection of the general settings and information about the shop.
*/
@interface BUYShop : BUYObject
/**
* The name of the shop.
*/
@property (nonatomic, readonly, copy) NSString *name;
/**
* The city in which the shop is located.
*/
@property (nonatomic, readonly, copy) NSString *city;
/**
* The shop's normalized province or state name.
*/
@property (nonatomic, readonly, copy) NSString *province;
/**
* The country in which the shop is located
*/
@property (nonatomic, readonly, copy) NSString *country;
/**
* The three-letter code for the currency that the shop accepts.
*/
@property (nonatomic, readonly, copy) NSString *currency;
/**
* A string representing the way currency is formatted when the currency isn't specified.
*/
@property (nonatomic, readonly, copy) NSString *moneyFormat;
/**
* The shop's domain.
*/
@property (nonatomic, readonly, copy) NSString *domain;
/**
* The shop's description.
*/
@property (nonatomic, readonly, copy) NSString *shopDescription;
/**
* A list of two-letter country codes identifying the countries that the shop ships to.
*/
@property (nonatomic, readonly, copy) NSArray<NSString *> *shipsToCountries;
/**
* The URL for the web storefront
*/
@property (nonatomic, readonly) NSURL *shopURL;
/**
* The shop's 'myshopify.com' domain.
*/
@property (nonatomic, readonly) NSURL *myShopifyURL;
@interface BUYShop : _BUYShop {}
@end
//
// BUYShop.m
// _BUYShop.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -28,21 +28,4 @@
@implementation BUYShop
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
[super updateWithDictionary:dictionary];
_name = [dictionary[@"name"] copy];
_city = [dictionary[@"city"] copy];
_country = [dictionary[@"country"] copy];
_province = [dictionary[@"province"] copy];
_currency = [dictionary[@"currency"] copy];
_moneyFormat = [dictionary[@"money_format"] copy];
_domain = [dictionary[@"domain"] copy];
_shopDescription = [dictionary[@"description"] copy];
_shipsToCountries = [dictionary[@"ships_to_countries"] copy];
_shopURL = [NSURL URLWithString:dictionary[@"url"]];
_myShopifyURL = [NSURL URLWithString:dictionary[@"myshopify_domain"]];
}
@end
//
// BUYAddress.h
// _BUYAddress.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,72 +24,26 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYAddress.h>
/**
* A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion.
*/
@interface BUYAddress : BUYObject <BUYSerializable>
/**
* The street address of the address.
*/
@property (nonatomic, copy) NSString *address1;
/**
* An optional additional field for the street address of the address.
*/
@property (nonatomic, copy) NSString *address2;
/**
* The city of the address.
*/
@property (nonatomic, copy) NSString *city;
/**
* The company of the person associated with the address (optional).
*/
@property (nonatomic, copy) NSString *company;
/**
* The first name of the person associated with the payment method.
*/
@property (nonatomic, copy) NSString *firstName;
/**
* The last name of the person associated with the payment method.
*/
@property (nonatomic, copy) NSString *lastName;
/**
* The phone number at the address.
*/
@property (nonatomic, copy) NSString *phone;
/**
* The name of the country of the address.
*/
@property (nonatomic, copy) NSString *country;
/**
* The two-letter code (ISO 3166-1 alpha-2 two-letter country code) for the country of the address.
*/
@property (nonatomic, copy) NSString *countryCode;
/**
* The name of the state or province of the address
*/
@property (nonatomic, copy) NSString *province;
@interface BUYAddress : _BUYAddress {}
/**
* The two-letter abbreviation of the state or province of the address.
* Check if the address does not include first and last name
* and address1 field. This is used to determine whether a
* placeholder was set for shipping rates calculations in Apple Pay.
*
* @return True if first name, last name or address1 contain placeholders
*/
@property (nonatomic, copy) NSString *provinceCode;
- (BOOL)isPartialAddress;
/**
* The zip or postal code of the address.
* Local validation to check that the minimum set of properties required
* to calculate shipping rates are available.
*
* @return True if city, zip/postal code, province/state and country or
* country code are set.
*/
@property (nonatomic, copy) NSString *zip;
- (BOOL)isValidAddressForShippingRates;
@end
//
// BUYAddress.m
// _BUYAddress.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,65 +25,38 @@
//
#import "BUYAddress.h"
#import "NSString+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
@implementation BUYAddress
- (void)updateWithDictionary:(NSDictionary *)dictionary
-(NSString *)countryCode
{
self.address1 = dictionary[@"address1"];
self.address2 = dictionary[@"address2"];
self.city = dictionary[@"city"];
self.company = dictionary[@"company"];
self.firstName = dictionary[@"first_name"];
self.lastName = dictionary[@"last_name"];
self.phone = dictionary[@"phone"];
self.country = dictionary[@"country"];
self.countryCode = dictionary[@"country_code"];
self.province = [dictionary buy_objectForKey:@"province"];
self.provinceCode = [dictionary buy_objectForKey:@"province_code"];
self.zip = dictionary[@"zip"];
return [[super countryCode] uppercaseString];
}
- (NSDictionary *)jsonDictionaryForCheckout
- (BOOL)isPartialAddress
{
NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
json[@"address1"] = [self.address1 buy_trim] ?: @"";
json[@"address2"] = [self.address2 buy_trim] ?: @"";
json[@"city"] = [self.city buy_trim] ?: @"";
json[@"company"] = [self.company buy_trim] ?: @"";
json[@"first_name"] = [self.firstName buy_trim] ?: @"";
json[@"last_name"] = [self.lastName buy_trim] ?: @"";
json[@"phone"] = [self.phone buy_trim] ?: @"";
json[@"zip"] = [self.zip buy_trim] ?: @"";
NSString *country = [self.country buy_trim];
if ([country length] > 0) {
json[@"country"] = country;
}
NSString *countryCode = [self.countryCode buy_trim];
if ([countryCode length] > 0) {
json[@"country_code"] = countryCode;
}
NSString *province = [self.province buy_trim];
if ([province length] > 0) {
json[@"province"] = province;
if (self.address1.length == 0 ||
self.firstName.length == 0 ||
self.lastName.length == 0) {
return YES;
}
NSString *provinceCode = [self.provinceCode buy_trim];
if ([provinceCode length] > 0) {
json[@"province_code"] = provinceCode;
}
return json;
return NO;
}
-(NSString *)countryCode
- (BOOL)isValidAddressForShippingRates
{
return [_countryCode uppercaseString];
BOOL valid = NO;
if (self.city.length > 0 &&
self.zip.length > 0 &&
self.province.length > 0 &&
(self.country.length > 0 || self.countryCode.length == 2)) {
valid = YES;
}
return valid;
}
@end
//
// BUYCheckout.h
// _BUYCheckout.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,275 +24,36 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYCheckout.h>
#import <Buy/_BUYProductVariant.h>
#import <Buy/BUYModelManager.h>
@class BUYAddress;
@class BUYCart;
@class BUYCreditCard;
@class BUYDiscount;
@class BUYMaskedCreditCard;
@class BUYOrder;
@class BUYShippingRate;
@class BUYTaxLine;
@class BUYLineItem;
@class BUYGiftCard;
@class BUYCheckoutAttribute;
@class BUYCart, BUYCartLineItem, BUYAddress, BUYGiftCard;
/**
* The checkout object. This is the main object that you will interact with when creating orders on Shopify.
*
* Note: Do not create a BUYCheckout object directly. Use initWithCart: to transform a BUYCart into a BUYCheckout.
*/
@interface BUYCheckout : BUYObject <BUYSerializable>
@interface BUYCheckout : _BUYCheckout {}
/**
* The customer's email address
*/
@property (nonatomic, copy) NSString *email;
@property (nonatomic, copy) NSNumber *taxesIncluded;
@property (nonatomic, readonly, copy) NSDate *createdAtDate;
@property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly, copy) NSDictionary *attributesDictionary;
/**
* Unique token for the checkout on Shopify
*/
@property (nonatomic, copy, readonly) NSString *token;
@property (nonatomic) BOOL hasToken;
/**
* Unique token for a cart which can be used to convert to a checkout
*/
@property (nonatomic, copy, readonly) NSString *cartToken;
- (instancetype)initWithCart:(BUYCart *)cart NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead");
- (instancetype)initWithCartToken:(NSString *)token NS_DEPRECATED_IOS(8_0, 9_0, "Use `BUYModelManager` to create new instances of model objects instead");;
/**
* States whether or not the fulfillment requires shipping
*/
@property (nonatomic, assign, readonly) BOOL requiresShipping;
- (void)updateWithCart:(BUYCart *)cart;
/**
* States whether or not the taxes are included in the price
*/
@property (nonatomic, assign, readonly) BOOL taxesIncluded;
- (BUYGiftCard *)giftCardWithIdentifier:(NSNumber *)identifier;
- (void)removeGiftCardWithIdentifier:(NSNumber *)identifier;
/**
* The three letter code (ISO 4217) for the currency used for the payment
*/
@property (nonatomic, copy, readonly) NSString *currency;
/**
* Price of the order before shipping and taxes
*/
@property (nonatomic, strong, readonly) NSDecimalNumber *subtotalPrice;
/**
* The sum of all the taxes applied to the line items in the order
*/
@property (nonatomic, strong, readonly) NSDecimalNumber *totalTax;
/**
* The sum of all the prices of all the items in the order, taxes and discounts included
*/
@property (nonatomic, strong, readonly) NSDecimalNumber *totalPrice;
/**
* The Payment Session ID associated with a credit card transaction
*/
@property (nonatomic, strong, readonly) NSString *paymentSessionId;
/**
* URL to the payment gateway
*/
@property (nonatomic, strong, readonly) NSURL *paymentURL;
/**
* Reservation time on the checkout in seconds. Setting to @0 and updating the checkout
* will release inventory reserved by the checkout (when product inventory is not infinite).
*
* 300 seconds is default and maximum. `reservationTime` is reset to @300 on every
* `updateCheckout:completion:` call.
*
* Note: This can also be done with `removeProductReservationsFromCheckout:completion`
* found in the BUYClient.
*/
@property (nonatomic, strong) NSNumber *reservationTime;
/**
* Reservation time remaining on the checkout in seconds
*/
@property (nonatomic, strong, readonly) NSNumber *reservationTimeLeft;
/**
* Amount of payment due on the checkout
*/
@property (nonatomic, strong, readonly) NSDecimalNumber *paymentDue;
/**
* Array of BUYLineItem objects in the checkout
* Note: These are different from BUYCartLineItems in that the line item
* objects do not include the BUYProductVariant
*/
@property (nonatomic, readonly, copy) NSArray<__kindof BUYLineItem *> *lineItems;
/**
* Array of tax line objects on the checkout
*/
@property (nonatomic, readonly, copy) NSArray<BUYTaxLine *> *taxLines;
/**
* The mailing address associated with the payment method
*/
@property (nonatomic, strong) BUYAddress *billingAddress;
/**
* The mailing address to where the order will be shipped
*/
@property (nonatomic, strong) BUYAddress *shippingAddress;
/**
* The shipping rate chosen for the checkout
*/
@property (nonatomic, strong) BUYShippingRate *shippingRate;
/**
* Shipping rate identifier
*/
@property (nonatomic, readonly) NSString *shippingRateId DEPRECATED_MSG_ATTRIBUTE("Use shippingRate.shippingRateIdentifier");
/**
* A discount added to the checkout
* Only one discount can be added to a checkout. Call `updateCheckout:completion:`
* after adding a discount to apply the discount code to the checkout.
*/
@property (nonatomic, strong) BUYDiscount *discount;
/**
* An array of BUYGiftCard objects applied to the checkout
*/
@property (nonatomic, strong, readonly) NSArray<BUYGiftCard *> *giftCards;
/**
* Attributions for the checkout, containing the application name and platform (defaults to applicationName set
* on the BUYClient, and "iOS" respectively
*/
@property (nonatomic, strong) NSDictionary *marketingAttribution;
/**
* URL which is used for completing checkout. It is recommended to open the URL in Safari to take
* advantage of its autocompletion and credit card capture capabilities
*/
@property (nonatomic, strong, readonly) NSURL *webCheckoutURL;
/**
* The URL Scheme of the host app. Used to return to the app from the web checkout
*/
@property (nonatomic, strong) NSString *webReturnToURL;
/**
* The button title that will appear after checkout to return to the host app. Defaults to "Return to 'application'",
* where 'application' is the `applicationName` set on the BUYClient
*/
@property (nonatomic, strong) NSString *webReturnToLabel;
/**
* Creation date of the checkout
*/
@property (nonatomic, copy, readonly) NSDate *createdAtDate;
/**
* Last updated date for the checkout
*/
@property (nonatomic, copy, readonly) NSDate *updatedAtDate;
/**
* The website URL for the privacy policy for the checkout
*/
@property (nonatomic, strong, readonly) NSURL *privacyPolicyURL;
/**
* The website URL for the refund policy for the checkout
*/
@property (nonatomic, strong, readonly) NSURL *refundPolicyURL;
/**
* The website URL for the terms of service for the checkout
*/
@property (nonatomic, strong, readonly) NSURL *termsOfServiceURL;
/**
* The name of the source of the checkout: "mobile_app"
*/
@property (nonatomic, copy, readonly) NSString *sourceName;
/**
* Credit card stored on the checkout
*/
@property (nonatomic, strong, readonly) BUYMaskedCreditCard *creditCard;
/**
* Customer ID associated with the checkout
*/
@property (nonatomic, copy, readonly) NSString *customerId;
/**
* An optional note attached to the order
*/
@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
*/
@property (nonatomic, strong, readonly) BUYOrder *order;
/**
* Flag used to inform server that the shipping address is partially filled, suitable to retrieve shipping rates
* with partial shipping addresses provided by PKPaymentAuthorizationViewController.
* Note: This should only ever be set to YES. Setting it to NO throws an exception.
*/
@property (nonatomic, assign) BOOL partialAddresses;
/**
* It is recommended to instantiate a checkout with a cart, or cart token
*
* @return Checkout
*/
- (instancetype)init NS_UNAVAILABLE;
/**
* Creates a new checkout
*
* @param cart a Cart with line items on it
*
* @return a checkout object
*/
- (instancetype)initWithCart:(BUYCart *)cart;
/**
* Creates a new checkout
*
* @param cartToken a token for a previously created cart
*
* @return a checkout object
*/
- (instancetype)initWithCartToken:(NSString *)cartToken;
/**
* Helper method to determine if there is a valid token on the checkout
*
* @return YES if the token is valid
*/
- (BOOL)hasToken;
#pragma mark - Deprecated properties
@end
/**
* The unique order ID
*/
@property (nonatomic, copy, readonly) NSNumber *orderId DEPRECATED_MSG_ATTRIBUTE("Available on the BUYOrder object");
@interface BUYModelManager (BUYCheckoutCreating)
/**
* URL for the website showing the order status
*/
@property (nonatomic, strong, readonly) NSURL *orderStatusURL DEPRECATED_MSG_ATTRIBUTE("Available on the BUYOrder object");
- (BUYCheckout *)checkout;
- (BUYCheckout *)checkoutWithCart:(BUYCart *)cart;
- (BUYCheckout *)checkoutWithVariant:(BUYProductVariant *)productVariant;
- (BUYCheckout *)checkoutwithCartToken:(NSString *)token;
@end
//
// BUYCheckout.m
// _BUYCheckout.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,192 +24,166 @@
// THE SOFTWARE.
//
#import "BUYCheckout.h"
#import "BUYAddress.h"
#import "BUYCart.h"
#import "BUYCheckout.h"
#import "BUYCheckout_Private.h"
#import "BUYDiscount.h"
#import "BUYCheckoutAttribute.h"
#import "BUYGiftCard.h"
#import "BUYLineItem.h"
#import "BUYMaskedCreditCard.h"
#import "BUYOrder.h"
#import "BUYProductVariant.h"
#import "BUYShippingRate.h"
#import "BUYTaxLine.h"
#import "BUYMaskedCreditCard.h"
#import "BUYGiftCard.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSURL+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "BUYCheckoutAttribute.h"
#import "NSArray+BUYAdditions.h"
#import "NSEntityDescription+BUYAdditions.h"
@implementation BUYCheckout
+ (NSSet *)keyPathsForValuesAffectingAttributesDictionary
{
return [NSSet setWithObject:BUYCheckoutRelationships.attributes];
}
- (NSDictionary *)attributesDictionary
{
NSArray *attributesArray = [self.attributes allObjects];
NSArray *objects = [attributesArray valueForKey:BUYCheckoutAttributeAttributes.value];
NSArray *keys = [attributesArray valueForKey:BUYCheckoutAttributeAttributes.name];
return [NSDictionary dictionaryWithObjects:objects forKeys:keys];
}
+ (BOOL)tracksDirtyProperties
{
return YES;
}
- (instancetype)initWithCart:(BUYCart *)cart
- (BOOL)hasToken
{
return [self.token length] > 0;
}
- (void)setShippingRate:(BUYShippingRate *)shippingRate
{
[super setShippingRate:shippingRate];
self.shippingRateId = shippingRate.shippingRateIdentifier;
}
-(void)setPartialAddresses:(NSNumber *)partialAddresses
{
if (partialAddresses.boolValue == NO) {
@throw [NSException exceptionWithName:@"partialAddress" reason:@"partialAddresses can only be set to true and should never be set to false on a complete address" userInfo:nil];
}
[ super setPartialAddresses:partialAddresses];
}
/**
* We must initialize to-many relationships to ensure that
* -mutableSetValueForKey: works properly. e.g. -giftCardsSet
*/
#if !defined CORE_DATA_PERSISTENCE
- (instancetype)init
{
self = [super init];
if (self) {
_lineItems = [cart.lineItems copy];
[self markPropertyAsDirty:@"lineItems"];
self.attributes = [NSSet set];
self.giftCards = [NSOrderedSet orderedSet];
self.lineItems = [NSOrderedSet orderedSet];
self.taxLines = [NSSet set];
[self markAsClean];
}
return self;
}
#endif
- (instancetype)initWithCartToken:(NSString *)cartToken
- (instancetype)initWithCart:(BUYCart *)cart
{
self = [super initWithDictionary:@{@"cart_token" : cartToken}];
self = [self initWithModelManager:cart.modelManager JSONDictionary:nil];
if (self) {
[self markPropertyAsDirty:@"cartToken"];
[self updateWithCart:cart];
}
return self;
}
+ (NSString *)jsonKeyForProperty:(NSString *)property
- (instancetype)initWithCartToken:(NSString *)token
{
NSString *key = nil;
if ([property isEqual:@"identifier"]) {
key = @"id";
}
else {
static NSCharacterSet *kUppercaseCharacters = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
kUppercaseCharacters = [NSCharacterSet uppercaseLetterCharacterSet];
});
if ([property containsString:@"URL"]) {
property = [property stringByReplacingOccurrencesOfString:@"URL" withString:@"Url"];
}
NSMutableString *output = [NSMutableString string];
for (NSInteger i = 0; i < [property length]; ++i) {
unichar c = [property characterAtIndex:i];
if ([kUppercaseCharacters characterIsMember:c]) {
[output appendFormat:@"_%@", [[NSString stringWithCharacters:&c length:1] lowercaseString]];
}
else {
[output appendFormat:@"%C", c];
}
}
key = output;
self = [self initWithModelManager:nil JSONDictionary:nil];
if (self) {
self.cartToken = token;
}
return key;
return self;
}
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (void)updateWithCart:(BUYCart *)cart
{
self.email = dictionary[@"email"];
self.token = dictionary[@"token"];
self.cartToken = dictionary[@"cart_token"];
self.requiresShipping = [dictionary[@"requires_shipping"] boolValue];
self.taxesIncluded = [dictionary[@"taxes_included"] boolValue];
self.currency = dictionary[@"currency"];
self.subtotalPrice = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"subtotal_price"]];
self.totalTax = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"total_tax"]];
self.totalPrice = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"total_price"]];
self.paymentDue = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"payment_due"]];
self.paymentSessionId = dictionary[@"payment_session_id"];
NSString *paymentURLString = dictionary[@"payment_url"];
self.paymentURL = paymentURLString ? [NSURL URLWithString:paymentURLString] : nil;
self.reservationTime = dictionary[@"reservation_time"];
self.reservationTimeLeft = dictionary[@"reservation_time_left"];
_lineItems = [BUYLineItem convertJSONArray:dictionary[@"line_items"]];
_taxLines = [BUYTaxLine convertJSONArray:dictionary[@"tax_lines"]];
self.billingAddress = [BUYAddress convertObject:dictionary[@"billing_address"]];
self.shippingAddress = [BUYAddress convertObject:dictionary[@"shipping_address"]];
self.shippingRate = [BUYShippingRate convertObject:dictionary[@"shipping_rate"]];
self.discount = [BUYDiscount convertObject:dictionary[@"discount"]];
self.giftCards = [BUYGiftCard convertJSONArray:dictionary[@"gift_cards"]];
self.order = [BUYOrder convertObject:dictionary[@"order"]];
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
self.orderId = self.order.identifier;
self.orderStatusURL = self.order.statusURL;
#pragma GCC diagnostic pop
self.webCheckoutURL = [NSURL URLWithString:dictionary[@"web_url"]];
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForPublications];
self.createdAtDate = [dateFormatter dateFromString:dictionary[@"created_at"]];
self.updatedAtDate = [dateFormatter dateFromString:dictionary[@"updated_at"]];
self.creditCard = [BUYMaskedCreditCard convertObject:dictionary[@"credit_card"]];
self.customerId = [dictionary buy_objectForKey:@"customer_id"];
self.note = dictionary[@"note"];
self.attributes = [BUYCheckoutAttribute convertJSONArray:dictionary[@"attributes"]];
self.privacyPolicyURL = [NSURL buy_urlWithString:dictionary[@"privacy_policy_url"]];
self.refundPolicyURL = [NSURL buy_urlWithString:dictionary[@"refund_policy_url"]];
self.termsOfServiceURL = [NSURL buy_urlWithString:dictionary[@"terms_of_service_url"]];
self.sourceName = dictionary[@"source_name"];
NSArray *lineItems = [[cart.lineItems array] buy_map:^id(BUYCartLineItem *cartLineItem) {
return [[BUYLineItem alloc] initWithCartLineItem:cartLineItem];
}];
self.lineItems = [NSOrderedSet orderedSetWithArray:lineItems];
}
- (NSString *)shippingRateId
{
return self.shippingRate.shippingRateIdentifier;
}
#pragma mark - BUYObject
- (id)jsonValueForValue:(id)value
- (NSDictionary *)JSONEncodedProperties
{
id newValue = value;
if ([value conformsToProtocol:@protocol(BUYSerializable)]) {
newValue = [(id <BUYSerializable>)value jsonDictionaryForCheckout];
}
else if ([value isKindOfClass:[NSArray class]]) {
NSMutableArray *newArray = [[NSMutableArray alloc] init];
for (id arrayValue in value) {
[newArray addObject:[self jsonValueForValue:arrayValue]];
}
newValue = newArray;
}
else if ([value isKindOfClass:[NSString class]]) {
newValue = [value buy_trim];
}
return newValue;
//We only need the dirty properties
return [[super JSONEncodedProperties] dictionaryWithValuesForKeys:[self.dirtyProperties allObjects]];
}
- (NSDictionary *)jsonDictionaryForCheckout
{
// We only need the dirty properties
NSSet *dirtyProperties = [self dirtyProperties];
NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
for (NSString *dirtyProperty in dirtyProperties) {
id value = [self jsonValueForValue:[self valueForKey:dirtyProperty]];
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;
}
NSMutableDictionary *json = [self.JSONDictionary mutableCopy];
json[@"attributes"] = self.attributesDictionary;
return @{ @"checkout" : json };
}
-(void)setPartialAddresses:(BOOL)partialAddresses
#pragma mark - Gift Card management
- (BUYGiftCard *)giftCardWithIdentifier:(NSNumber *)identifier
{
if (partialAddresses == NO) {
@throw [NSException exceptionWithName:@"partialAddress" reason:@"partialAddresses can only be set to true and should never be set to false on a complete address" userInfo:nil];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"identifier = %@", identifier];
return [[self.giftCards filteredOrderedSetUsingPredicate:predicate] firstObject];
}
- (void)removeGiftCardWithIdentifier:(NSNumber *)identifier
{
BUYGiftCard *giftCard = [self giftCardWithIdentifier:identifier];
if (giftCard) {
[self.giftCardsSet removeObject:giftCard];
}
_partialAddresses = partialAddresses;
}
- (BOOL)hasToken
@end
@implementation BUYModelManager (BUYCheckoutCreating)
- (BUYCheckout *)checkout
{
return [self checkoutWithCart:[self insertCartWithJSONDictionary:nil]];
}
- (BUYCheckout *)checkoutWithCart:(BUYCart *)cart
{
BUYCheckout *checkout = [self insertCheckoutWithJSONDictionary:nil];
[checkout updateWithCart:cart];
return checkout;
}
- (BUYCheckout *)checkoutWithVariant:(BUYProductVariant *)productVariant
{
BUYCheckout *checkout = [self insertCheckoutWithJSONDictionary:nil];
BUYLineItem *lineItem = [self lineItemWithVariant:productVariant];
checkout.lineItems = [NSOrderedSet orderedSetWithObject:lineItem];
return checkout;
}
- (BUYCheckout *)checkoutwithCartToken:(NSString *)token
{
return (_token && [_token length] > 0);
BUYCheckout *checkout = [self insertCheckoutWithJSONDictionary:nil];
checkout.cartToken = token;
return checkout;
}
@end
......@@ -24,22 +24,10 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYCheckoutAttribute.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;
@interface BUYCheckoutAttribute : _BUYCheckoutAttribute
@end
......@@ -28,17 +28,6 @@
@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;
......
//
// BUYDiscount.h
// _BUYDiscount.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,36 +24,12 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYDiscount.h>
#import <Buy/BUYModelManager.h>
/**
* BUYDiscount represents a discount that is applied to the BUYCheckout.
*/
@interface BUYDiscount : BUYObject <BUYSerializable>
/**
* The unique identifier for the discount code.
*/
@property (nonatomic, copy) NSString *code;
/**
* The amount that is deducted from `paymentDue` on BUYCheckout.
*/
@property (nonatomic, strong) NSDecimalNumber *amount;
/**
* Whether this discount code can be applied to the checkout.
*/
@property (nonatomic, assign) BOOL applicable;
/**
* Created a BUYDiscount with a code
*
* @param code The discount code
*
* @return BUYDiscount object
*/
- (instancetype)initWithCode:(NSString *)code;
@interface BUYDiscount : _BUYDiscount {}
@end
@interface BUYModelManager (BUYDiscountCreating)
- (BUYDiscount *)discountWithCode:(NSString *)code;
@end
//
// BUYDiscount.m
// _BUYDiscount.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,29 +25,24 @@
//
#import "BUYDiscount.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "NSEntityDescription+BUYAdditions.h"
@implementation BUYDiscount
- (instancetype)initWithCode:(NSString *)code
- (NSDictionary *)JSONEncodedProperties
{
return [super initWithDictionary:@{@"code": code ?: @""}];
return [self.entity.JSONEncodedProperties dictionaryWithValuesForKeys:@[@"code"]];
}
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
[super updateWithDictionary:dictionary];
self.code = dictionary[@"code"];
self.amount = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"amount"]];
self.applicable = [dictionary[@"applicable"] boolValue];
}
@end
- (NSDictionary *)jsonDictionaryForCheckout
@implementation BUYModelManager (BUYDiscountCreating)
- (BUYDiscount *)discountWithCode:(NSString *)code
{
NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
json[@"code"] = [self.code buy_trim] ?: @"";
return json;
BUYDiscount *discount = [self buy_objectWithEntityName:[BUYDiscount entityName] JSONDictionary:nil];
discount.code = code ?: @"";
return discount;
}
@end
@end
\ No newline at end of file
//
// BUYGiftCard.h
// _BUYGiftCard.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,30 +24,15 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYGiftCard.h>
#import <Buy/BUYModelManager.h>
@interface BUYGiftCard : BUYObject <BUYSerializable>
@interface BUYGiftCard : _BUYGiftCard {}
/**
* The gift card code. This is only used when applying a gift card and
* is not visible on a BUYCheckout object synced with Shopify.
*/
@property (nonatomic, readonly, copy) NSString *code;
/**
* The last characters of the applied gift card code.
*/
@property (nonatomic, readonly, copy) NSString *lastCharacters;
@end
/**
* The amount left on the gift card after being applied to this checkout.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *balance;
@interface BUYModelManager (BUYGiftCardCreation)
/**
* The amount of the gift card used by this checkout.
*/
@property (nonatomic, readonly, strong) NSDecimalNumber *amountUsed;
- (BUYGiftCard *)giftCardWithCode:(NSString *)code;
@end
//
// BUYGiftCard.m
// _BUYGiftCard.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,41 +25,23 @@
//
#import "BUYGiftCard.h"
#import "NSDecimalNumber+BUYAdditions.h"
@implementation BUYGiftCard
- (void)updateWithDictionary:(NSDictionary *)dictionary
- (NSDictionary *)jsonDictionaryForCheckout
{
[super updateWithDictionary:dictionary];
_code = dictionary[@"code"];
_lastCharacters = dictionary[@"last_characters"];
_balance = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"balance"]];
_amountUsed = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"amount_used"]];
return @{ @"gift_card" : self.JSONDictionary };
}
- (NSDictionary *)jsonDictionaryForCheckout
@end
@implementation BUYModelManager (BUYGiftCardCreation)
- (BUYGiftCard *)giftCardWithCode:(NSString *)code
{
NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
if (_code) {
json[@"code"] = _code;
}
if (_lastCharacters) {
json[@"last_characters"] = _lastCharacters;
}
if (_balance) {
json[@"balance"] = _balance;
}
if (_amountUsed) {
json[@"amount_used"] = _amountUsed;
}
return @{ @"gift_card" : json };
BUYGiftCard *giftCard = [self buy_objectWithEntityName:[BUYGiftCard entityName] JSONDictionary:nil];
giftCard.code = code;
return giftCard;
}
@end
//
// BUYMaskedCreditCard.h
// _BUYMaskedCreditCard.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,41 +24,8 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import <Buy/_BUYMaskedCreditCard.h>
/**
* This represents a masked credit card that has been applied to a checkout.
*/
@interface BUYMaskedCreditCard : BUYObject
/**
* The first name on the credit card
*/
@property (nonatomic, copy) NSString *firstName;
/**
* The last name on the credit card
*/
@property (nonatomic, copy) NSString *lastName;
/**
* The first digits of credit card number.
*/
@property (nonatomic, copy) NSString *firstDigits;
/**
* The last digits of credit card number.
*/
@property (nonatomic, copy) NSString *lastDigits;
/**
* The year the card expires
*/
@property (nonatomic, copy) NSNumber *expiryYear;
/**
* The two digits representing the month the card expires
*/
@property (nonatomic, copy) NSNumber *expiryMonth;
@interface BUYMaskedCreditCard : _BUYMaskedCreditCard {}
@end
//
// BUYMaskedCreditCard.m
// _BUYMaskedCreditCard.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -28,18 +28,4 @@
@implementation BUYMaskedCreditCard
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
[super updateWithDictionary:dictionary];
_firstName = [dictionary[@"first_name"] copy];
_lastName = [dictionary[@"last_name"] copy];
_firstDigits = [dictionary[@"first_digits"] copy];
_lastDigits = [dictionary[@"last_digits"] copy];
_expiryMonth = [dictionary[@"expiry_month"] copy];
_expiryYear = [dictionary[@"expiry_year"] copy];
}
@end
//
// BUYShippingRate.h
// _BUYShippingRate.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,32 +24,8 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYShippingRate.h>
/**
* BUYShippingRate represents the amount that the merchant is charging a customer for shipping to the specified address.
*/
@interface BUYShippingRate : BUYObject <BUYSerializable>
/**
* A reference to the shipping method.
*/
@property (nonatomic, strong, readonly) NSString *shippingRateIdentifier;
/**
* The shipping method name.
*/
@property (nonatomic, strong, readonly) NSString *title;
/**
* The price of this shipping method.
*/
@property (nonatomic, strong, readonly) NSDecimalNumber *price;
/**
* One or two NSDate objects of the potential delivery dates.
*/
@property (nonatomic, strong, readonly) NSArray *deliveryRange;
@interface BUYShippingRate : _BUYShippingRate {}
@end
//
// BUYShippingRate.m
// _BUYShippingRate.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,52 +25,7 @@
//
#import "BUYShippingRate.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h"
@interface BUYShippingRate ()
@property (nonatomic, strong) NSString *shippingRateIdentifier;
@property (nonatomic, strong) NSString *title;
@property (nonatomic, strong) NSDecimalNumber *price;
@property (nonatomic, strong) NSArray *deliveryRange;
@end
@implementation BUYShippingRate
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
self.shippingRateIdentifier = dictionary[@"id"];
self.price = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"price"]];
self.title = dictionary[@"title"];
if ([dictionary[@"delivery_range"] isKindOfClass:[NSNull class]] == NO && [dictionary[@"delivery_range"] count]) {
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForShippingRates];
NSMutableArray *shippingRangeDates = [NSMutableArray new];
for (NSString *dateString in dictionary[@"delivery_range"]) {
[shippingRangeDates addObject:[dateFormatter dateFromString:dateString]];
}
self.deliveryRange = [shippingRangeDates copy];
}
}
- (NSDictionary *)jsonDictionaryForCheckout
{
NSMutableDictionary *json = [[NSMutableDictionary alloc] init];
json[@"id"] = [self.shippingRateIdentifier buy_trim] ?: @"";
json[@"title"] = [self.title buy_trim] ?: @"";
json[@"price"] = self.price ?: [NSDecimalNumber zero];
if (self.deliveryRange) {
NSDateFormatter *dateFormatter = [NSDateFormatter dateFormatterForShippingRates];
NSMutableArray *shippingRangeStrings = [NSMutableArray new];
for (NSDate *date in self.deliveryRange) {
[shippingRangeStrings addObject:[dateFormatter stringFromDate:date]];
}
json[@"delivery_range"] = [shippingRangeStrings copy];
}
return json;
}
@end
//
// BUYTaxLine.h
// _BUYTaxLine.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -24,27 +24,8 @@
// THE SOFTWARE.
//
#import "BUYObject.h"
#import "BUYSerializable.h"
#import <Buy/_BUYTaxLine.h>
/**
* BUYTaxLine represents a single tax line on a checkout. Use this to display an itemized list of taxes that a customer is being charged for.
*/
@interface BUYTaxLine : BUYObject
/**
* The amount of tax to be charged.
*/
@property (nonatomic, strong) NSDecimalNumber *price;
/**
* The rate of tax to be applied.
*/
@property (nonatomic, strong) NSDecimalNumber *rate;
/**
* The name of the tax.
*/
@property (nonatomic, copy) NSString *title;
@interface BUYTaxLine : _BUYTaxLine {}
@end
//
// BUYTaxLine.m
// _BUYTaxLine.m
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -25,17 +25,7 @@
//
#import "BUYTaxLine.h"
#import "NSDecimalNumber+BUYAdditions.h"
@implementation BUYTaxLine
- (void)updateWithDictionary:(NSDictionary *)dictionary
{
[super updateWithDictionary:dictionary];
_price = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"price"]];
_rate = [NSDecimalNumber buy_decimalNumberFromJSON:dictionary[@"rate"]];
_title = dictionary[@"title"];
}
@end
......@@ -64,6 +64,7 @@ extern const struct BUYCheckoutAttributes {
} BUYCheckoutAttributes;
extern const struct BUYCheckoutRelationships {
__unsafe_unretained NSString *attributes;
__unsafe_unretained NSString *billingAddress;
__unsafe_unretained NSString *creditCard;
__unsafe_unretained NSString *discount;
......@@ -80,6 +81,7 @@ extern const struct BUYCheckoutUserInfo {
__unsafe_unretained NSString *documentation;
} BUYCheckoutUserInfo;
@class BUYCheckoutAttribute;
@class BUYAddress;
@class BUYMaskedCreditCard;
@class BUYDiscount;
......@@ -300,6 +302,10 @@ extern const struct BUYCheckoutUserInfo {
*/
@property (nonatomic, strong) NSURL* webReturnToURL;
@property (nonatomic, strong) NSSet *attributes;
- (NSMutableSet*)attributesSet;
@property (nonatomic, strong) BUYAddress *billingAddress;
/**
......@@ -351,6 +357,10 @@ extern const struct BUYCheckoutUserInfo {
@end
@interface _BUYCheckout (AttributesCoreDataGeneratedAccessors)
@end
@interface _BUYCheckout (GiftCardsCoreDataGeneratedAccessors)
- (void)insertObject:(BUYGiftCard*)value inGiftCardsAtIndex:(NSUInteger)idx;
......
......@@ -62,6 +62,7 @@ const struct BUYCheckoutAttributes BUYCheckoutAttributes = {
};
const struct BUYCheckoutRelationships BUYCheckoutRelationships = {
.attributes = @"attributes",
.billingAddress = @"billingAddress",
.creditCard = @"creditCard",
.discount = @"discount",
......@@ -175,6 +176,12 @@ const struct BUYCheckoutUserInfo BUYCheckoutUserInfo = {
[self setReservationTimeLeft:@(value_)];
}
- (NSMutableSet*)attributesSet {
return (NSMutableSet*)[self mutableSetValueForKey:@"attributes"];
}
- (NSMutableOrderedSet*)giftCardsSet {
return (NSMutableOrderedSet*)[self mutableOrderedSetValueForKey:@"giftCards"];
......
//
// BUYAddress+Additions.h
// _BUYCheckoutAttribute.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -23,28 +23,51 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
// Make changes to BUYCheckoutAttribute.h instead.
@import Foundation;
#import "BUYAddress.h"
#import "BUYObject.h"
@interface BUYAddress (Additions)
#import <Buy/BUYModelManager.h>
extern const struct BUYCheckoutAttributeAttributes {
__unsafe_unretained NSString *name;
__unsafe_unretained NSString *value;
} BUYCheckoutAttributeAttributes;
extern const struct BUYCheckoutAttributeRelationships {
__unsafe_unretained NSString *checkout;
} BUYCheckoutAttributeRelationships;
extern const struct BUYCheckoutAttributeUserInfo {
__unsafe_unretained NSString *documentation;
} BUYCheckoutAttributeUserInfo;
@class BUYCheckout;
@class BUYCheckoutAttribute;
@interface BUYModelManager (BUYCheckoutAttributeInserting)
- (NSArray<BUYCheckoutAttribute *> *)allCheckoutAttributeObjects;
- (BUYCheckoutAttribute *)fetchCheckoutAttributeWithIdentifierValue:(int64_t)identifier;
- (BUYCheckoutAttribute *)insertCheckoutAttributeWithJSONDictionary:(NSDictionary *)dictionary;
- (NSArray<BUYCheckoutAttribute *> *)insertCheckoutAttributesWithJSONArray:(NSArray <NSDictionary *> *)array;
@end
/**
* Check if the address does not include first and last name
* and address1 field. This is used to determine whether a
* placeholder was set for shipping rates calculations in Apple Pay.
*
* @return True if first name, last name or address1 contain placeholders
* The attribute name.
*/
- (BOOL)isPartialAddress;
@interface _BUYCheckoutAttribute : BUYObject
+ (NSString *)entityName;
@property (nonatomic, strong) NSString* name;
/**
* Local validation to check that the minimum set of properties required
* to calculate shipping rates are available.
*
* @return True if city, zip/postal code, province/state and country or
* country code are set.
* The attribute value.
*/
- (BOOL)isValidAddressForShippingRates;
@property (nonatomic, strong) NSString* value;
@property (nonatomic, strong) BUYCheckout *checkout;
@end
//
// BUYProductVariant+Options.m
// _BUYCheckoutAttribute.h
// Mobile Buy SDK
//
// Created by Shopify.
......@@ -23,33 +23,60 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// DO NOT EDIT. This file is machine-generated and constantly overwritten.
// Make changes to BUYCheckoutAttribute.m instead.
#import "BUYProductVariant+Options.h"
#import "_BUYCheckoutAttribute.h"
@implementation BUYProductVariant (Options)
const struct BUYCheckoutAttributeAttributes BUYCheckoutAttributeAttributes = {
.name = @"name",
.value = @"value",
};
- (BUYOptionValue *)optionValueForName:(NSString *)optionName
const struct BUYCheckoutAttributeRelationships BUYCheckoutAttributeRelationships = {
.checkout = @"checkout",
};
const struct BUYCheckoutAttributeUserInfo BUYCheckoutAttributeUserInfo = {
.documentation = @"The attribute name.",
};
@implementation _BUYCheckoutAttribute
+ (NSString *)entityName {
return @"CheckoutAttribute";
}
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
NSSet *keyPaths = [super keyPathsForValuesAffectingValueForKey:key];
return keyPaths;
}
@end
#pragma mark -
@implementation BUYModelManager (BUYCheckoutAttributeInserting)
- (BUYCheckoutAttribute *)insertCheckoutAttributeWithJSONDictionary:(NSDictionary *)dictionary
{
return (BUYCheckoutAttribute *)[self buy_objectWithEntityName:@"CheckoutAttribute" JSONDictionary:dictionary];
}
- (NSArray<BUYCheckoutAttribute *> *)insertCheckoutAttributesWithJSONArray:(NSArray <NSDictionary *> *)array
{
return (NSArray<BUYCheckoutAttribute *> *)[self buy_objectsWithEntityName:@"CheckoutAttribute" JSONArray:array];
}
- (NSArray<BUYCheckoutAttribute *> *)allCheckoutAttributeObjects
{
for (BUYOptionValue *value in self.options) {
if ([value.name isEqualToString:optionName]) {
return value;
}
}
return nil;
return (NSArray<BUYCheckoutAttribute *> *)[self buy_objectsWithEntityName:@"CheckoutAttribute" identifiers:nil];
}
+ (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue
- (BUYCheckoutAttribute *)fetchCheckoutAttributeWithIdentifierValue:(int64_t)identifier
{
NSMutableArray *filteredArray = [NSMutableArray new];
for (BUYProductVariant *variant in productVariants) {
for (BUYOptionValue *opValue in variant.options) {
if ([opValue isEqual:optionValue]) {
[filteredArray addObject:variant];
}
}
}
return [filteredArray copy];
return (BUYCheckoutAttribute *)[self buy_objectWithEntityName:@"CheckoutAttribute" identifier:@(identifier)];
}
@end
......@@ -105,7 +105,7 @@
self.priceLabel.text = [currencyFormatter stringFromNumber:productVariant.price];
}
if (productVariant.available == YES && productVariant.compareAtPrice) {
if (productVariant.available.boolValue && productVariant.compareAtPrice) {
NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:[currencyFormatter stringFromNumber:productVariant.compareAtPrice]
attributes:@{NSStrikethroughStyleAttributeName: @(NSUnderlineStyleSingle)}];
self.comparePriceLabel.attributedText = attributedString;
......
......@@ -97,7 +97,7 @@ CGFloat const buttonWidth = 10.0f;
- (void)setOptionsForProductVariant:(BUYProductVariant *)productVariant
{
NSArray *productOptions = productVariant.options;
NSArray *productOptions = productVariant.options.allObjects;
switch (productVariant.options.count) {
case 3:
......
......@@ -28,7 +28,7 @@
#import "BUYImageView.h"
#import "BUYOptionSelectionNavigationController.h"
#import "BUYPresentationControllerWithNavigationController.h"
#import "BUYProduct+Options.h"
#import "BUYProduct.h"
#import "BUYProductViewController.h"
#import "BUYImageKit.h"
#import "BUYProductView.h"
......@@ -397,8 +397,9 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
[self.variantCell setOptionsForProductVariant:self.selectedProductVariant];
}
if (self.productView.productViewHeader.collectionView) {
[self.productView.productViewHeader setImageForSelectedVariant:_selectedProductVariant withImages:self.product.images];
[self.productView updateBackgroundImage:self.product.images];
NSArray *images = self.product.images.array;
[self.productView.productViewHeader setImageForSelectedVariant:_selectedProductVariant withImages:images];
[self.productView updateBackgroundImage:images];
}
if (self.productView.productViewFooter) {
[self.productView.productViewFooter updateButtonsForProductVariant:selectedProductVariant];
......@@ -460,7 +461,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
if ([scrollView isKindOfClass:[UICollectionView class]]) {
[self.productView updateBackgroundImage:self.product.images];
[self.productView updateBackgroundImage:self.product.images.array];
}
}
......@@ -468,7 +469,7 @@ CGFloat const BUYMaxProductViewHeight = 640.0;
- (BUYCart *)cart
{
BUYCart *cart = [[BUYCart alloc] init];
BUYCart *cart = [self.client.modelManager insertCartWithJSONDictionary:nil];
[cart addVariant:self.selectedProductVariant];
return cart;
}
......
......@@ -25,7 +25,6 @@
//
#import "BUYImageKit.h"
#import "BUYProduct+Options.h"
#import "BUYOptionSelectionViewController.h"
#import "BUYOptionValue.h"
#import "BUYOptionValueCell.h"
......
......@@ -28,13 +28,14 @@
#import "BUYOptionSelectionNavigationController.h"
#import "BUYOptionSelectionViewController.h"
#import "BUYPresentationControllerForVariantSelection.h"
#import "BUYProduct+Options.h"
#import "BUYProductVariant+Options.h"
#import "BUYProduct.h"
#import "BUYProductVariant.h"
#import "BUYTheme.h"
#import "BUYTheme+Additions.h"
#import "BUYVariantSelectionViewController.h"
#import "BUYVariantOptionBreadCrumbsView.h"
#import "BUYOption.h"
#import "BUYOptionValue.h"
@interface BUYVariantSelectionViewController () <BUYOptionSelectionDelegate>
......
......@@ -65,3 +65,16 @@
#import "BUYStoreViewController.h"
#import "BUYTheme.h"
#import "BUYViewController.h"
#import "NSArray+BUYAdditions.h"
#import "NSDateFormatter+BUYAdditions.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "NSDictionary+BUYAdditions.h"
#import "NSEntityDescription+BUYAdditions.h"
#import "NSException+BUYAdditions.h"
#import "NSPropertyDescription+BUYAdditions.h"
#import "NSRegularExpression+BUYAdditions.h"
#import "NSString+BUYAdditions.h"
#import "NSURL+BUYAdditions.h"
#import "NSURLComponents+BUYAdditions.h"
//
// BUYAddress+Additions.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 "BUYAddress+Additions.h"
@implementation BUYAddress (Additions)
- (BOOL)isPartialAddress
{
if (self.address1.length == 0 ||
self.firstName.length == 0 ||
self.lastName.length == 0) {
return YES;
}
return NO;
}
- (BOOL)isValidAddressForShippingRates
{
BOOL valid = NO;
if (self.city.length > 0 &&
self.zip.length > 0 &&
(self.country.length > 0 || self.countryCode.length == 2)) {
valid = YES;
}
return valid;
}
@end
......@@ -67,22 +67,8 @@
+ (nullable NSString *)buy_emailFromRecord:(nullable ABRecordRef)record;
/**
* Creates a BUYAddress from an ABRecordRef
*
* @param record ABRecordRef to create a BUYAddress from
*
* @return The BUYAddress created from an ABRecordRef
*/
+ (nonnull BUYAddress *)buy_addressFromRecord:(nullable ABRecordRef)record NS_DEPRECATED_IOS(8_0, 9_0, "Use the CNContact backed `buy_addressFromContact:` instead");
- (void)updateWithRecord:(nullable ABRecordRef)record NS_DEPRECATED_IOS(8_0, 9_0, "Use the CNContact backed `updateWithContact:` instead");
/**
* Creates a BUYAddress from a PKContact
*
* @param contact PKContact to create a BUYAddress from
*
* @return The BUYAddress created from a PKContact
*/
+ (nonnull BUYAddress *)buy_addressFromContact:(nullable PKContact*)contact NS_AVAILABLE_IOS(9_0);
- (void)updateWithContact:(nullable PKContact*)contact NS_AVAILABLE_IOS(9_0);
@end
......@@ -30,7 +30,6 @@
#import "BUYGiftCard.h"
#import "BUYApplePayAdditions.h"
#import "BUYDiscount.h"
#import "BUYAddress+Additions.h"
#import "NSDecimalNumber+BUYAdditions.h"
#import "NSDate+BUYAdditions.h"
......@@ -137,13 +136,11 @@
return email;
}
+ (nonnull BUYAddress *)buy_addressFromRecord:(nullable ABRecordRef)record
- (void)updateWithRecord:(nullable ABRecordRef)record
{
BUYAddress *address = [[BUYAddress alloc] init];
//Grab the simple information
address.firstName = (__bridge_transfer NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty);
address.lastName = (__bridge_transfer NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty);
self.firstName = (__bridge_transfer NSString *)ABRecordCopyValue(record, kABPersonFirstNameProperty);
self.lastName = (__bridge_transfer NSString *)ABRecordCopyValue(record, kABPersonLastNameProperty);
//Grab the address information
ABMultiValueRef addressMultiValue = ABRecordCopyValue(record, kABPersonAddressProperty);
......@@ -152,17 +149,17 @@
CFDictionaryRef firstAddress = CFArrayGetValueAtIndex(allAddresses, 0);
//NOTE: We do not receive an address1 line right now via this partial address, as Apple deemds it unimportant to calculate the shipping rates. We get the actual address later on in a later step.
address.address1 = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressStreetKey);
address.city = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCityKey);
address.province = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressStateKey);
address.zip = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressZIPKey);
self.address1 = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressStreetKey);
self.city = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCityKey);
self.province = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressStateKey);
self.zip = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressZIPKey);
// The Checkout API accepts country OR ISO country code.
// We default to the ISO country code because it's more
// reliable regardless of locale. Fallback to country if
// we do not receive it (iOS 8 sometimes)
address.countryCode = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCountryCodeKey);
if ([address.countryCode length] == 0) {
address.country = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCountryKey);
self.countryCode = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCountryCodeKey);
if ([self.countryCode length] == 0) {
self.country = (__bridge NSString *)CFDictionaryGetValue(firstAddress, kABPersonAddressCountryKey);
}
}
CFSafeRelease(allAddresses);
......@@ -172,43 +169,37 @@
ABMultiValueRef phoneMultiValue = ABRecordCopyValue(record, kABPersonPhoneProperty);
CFArrayRef allPhoneNumbers = ABMultiValueCopyArrayOfAllValues(phoneMultiValue);
if (allPhoneNumbers && CFArrayGetCount(allPhoneNumbers) > 0) {
address.phone = (__bridge NSString *)CFArrayGetValueAtIndex(allPhoneNumbers, 0);
self.phone = (__bridge NSString *)CFArrayGetValueAtIndex(allPhoneNumbers, 0);
}
CFSafeRelease(phoneMultiValue);
CFSafeRelease(allPhoneNumbers);
return address;
}
+ (nonnull BUYAddress *)buy_addressFromContact:(nullable PKContact*)contact
- (void)updateWithContact:(nullable PKContact*)contact
{
BUYAddress *address = [[BUYAddress alloc] init];
address.firstName = contact.name.givenName;
address.lastName = contact.name.familyName;
self.firstName = contact.name.givenName;
self.lastName = contact.name.familyName;
if (contact.postalAddress) {
// break up the address:
NSArray *addressComponents = [contact.postalAddress.street componentsSeparatedByString:@"\n"];
address.address1 = addressComponents[0];
address.address2 = (addressComponents.count > 1) ? addressComponents[1] : nil;
address.city = contact.postalAddress.city;
address.province = contact.postalAddress.state;
address.zip = contact.postalAddress.postalCode;
self.address1 = addressComponents[0];
self.address2 = (addressComponents.count > 1) ? addressComponents[1] : nil;
self.city = contact.postalAddress.city;
self.province = contact.postalAddress.state;
self.zip = contact.postalAddress.postalCode;
// The Checkout API accepts country OR ISO country code.
// We default to the ISO country code because it's more
// reliable regardless of locale. Fallback to country if
// we do not receive it (iOS 8 sometimes)
address.countryCode = [contact.postalAddress.ISOCountryCode length] ? contact.postalAddress.ISOCountryCode : nil;
if (address.countryCode == nil) {
address.country = contact.postalAddress.country;
self.countryCode = [contact.postalAddress.ISOCountryCode length] ? contact.postalAddress.ISOCountryCode : nil;
if (self.countryCode == nil) {
self.country = contact.postalAddress.country;
}
}
address.phone = contact.phoneNumber.stringValue;
return address;
self.phone = contact.phoneNumber.stringValue;
}
@end
......@@ -27,6 +27,9 @@
@import Foundation;
@import PassKit;
#import <Buy/BUYModelManager.h>
@class BUYAddress;
@class BUYClient;
@class BUYCheckout;
@class BUYShop;
......@@ -60,7 +63,7 @@
* @param payment the authorized payment
* @param completion completion block thats called after Shopify authorizes the payment
*/
- (void)updateAndCompleteCheckoutWithPayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus status))completion DEPRECATED_MSG_ATTRIBUTE("BUYApplePayHelpers now implements PKPaymentAuthorizationViewControllerDelegate instead");
- (void)updateAndCompleteCheckoutWithPayment:(PKPayment *)payment completion:(void (^)(PKPaymentAuthorizationStatus status))completion NS_DEPRECATED_IOS(8_0, 9_0, "Use `PKPaymentAuthorizationViewControllerDelegate` instead");
/**
* Call this method in the PKPaymentAuthorizationViewControllerDelegate `paymentAuthorizationViewController:didSelectShippingMethod:completion`
......@@ -68,7 +71,7 @@
* @param shippingMethod The selected shipping method
* @param completion the completion block called after shipping method is updated on the checkout
*/
- (void)updateCheckoutWithShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *methods))completion DEPRECATED_MSG_ATTRIBUTE("BUYApplePayHelpers now implements PKPaymentAuthorizationViewControllerDelegate instead");
- (void)updateCheckoutWithShippingMethod:(PKShippingMethod *)shippingMethod completion:(void (^)(PKPaymentAuthorizationStatus status, NSArray *methods))completion NS_DEPRECATED_IOS(8_0, 9_0, "Use `PKPaymentAuthorizationViewControllerDelegate` instead");
/**
* Call this method in the PKPaymentAuthorizationViewControllerDelegate `paymentAuthorizationViewController:didSelectShippingAddress:completion`
......@@ -84,7 +87,7 @@
* @param contact The selected contact
* @param completion the completion block called after the shipping address is updated on the checkout
*/
- (void)updateCheckoutWithContact:(PKContact*)contact completion:(void (^)(PKPaymentAuthorizationStatus, NSArray *shippingMethods, NSArray *summaryItems))completion DEPRECATED_MSG_ATTRIBUTE("BUYApplePayHelpers now implements PKPaymentAuthorizationViewControllerDelegate instead");
- (void)updateCheckoutWithContact:(PKContact*)contact completion:(void (^)(PKPaymentAuthorizationStatus, NSArray *shippingMethods, NSArray *summaryItems))completion NS_DEPRECATED_IOS(8_0, 9_0, "Use `PKPaymentAuthorizationViewControllerDelegate` instead");
/**
* The current checkout
......@@ -107,3 +110,25 @@
@property (nonatomic, strong, readonly) BUYShop *shop;
@end
@interface BUYModelManager (ApplePay)
/**
* Creates a BUYAddress from an ABRecordRef
*
* @param record ABRecordRef to create a BUYAddress from
*
* @return The BUYAddress created from an ABRecordRef
*/
- (BUYAddress *)buyAddressWithABRecord:(ABRecordRef)addressRecord NS_DEPRECATED_IOS(8_0, 9_0, "Use the CNContact backed `buyAddressWithContact:` instead");
/**
* Creates a BUYAddress from a PKContact
*
* @param contact PKContact to create a BUYAddress from
*
* @return The BUYAddress created from a PKContact
*/
- (BUYAddress *)buyAddressWithContact:(PKContact *)contact NS_AVAILABLE_IOS(9_0);
@end
......@@ -25,11 +25,11 @@
//
#import "BUYApplePayHelpers.h"
#import "BUYApplePayAdditions.h"
#import "BUYClient.h"
#import "BUYCheckout.h"
#import "BUYApplePayAdditions.h"
#import "BUYError.h"
#import "BUYAddress+Additions.h"
#import "BUYModelManager.h"
#import "BUYShop.h"
const NSTimeInterval PollDelay = 0.5;
......@@ -88,19 +88,23 @@ const NSTimeInterval PollDelay = 0.5;
completion:(void (^)(PKPaymentAuthorizationStatus status))completion
{
// Update the checkout with the rest of the information. Apple has now provided us with a FULL billing address and a FULL shipping address.
// We now update the checkout with our new found data so that you can ship the products to the right address, and we collect whatever else we need.
// We now update the checkout with our new found data so that you can ship the products to the right address, and we collect whatever else we need.
if ([payment respondsToSelector:@selector(shippingContact)]) {
self.checkout.email = payment.shippingContact.emailAddress;
self.checkout.shippingAddress = self.checkout.requiresShipping ? [BUYAddress buy_addressFromContact:payment.shippingContact] : nil;
if (self.checkout.requiresShipping) {
self.checkout.shippingAddress = [self buyAddressWithContact:payment.shippingContact];
}
} else {
self.checkout.email = [BUYAddress buy_emailFromRecord:payment.shippingAddress];
self.checkout.shippingAddress = self.checkout.requiresShipping ? [BUYAddress buy_addressFromRecord:payment.shippingAddress] : nil;
if (self.checkout.requiresShipping) {
self.checkout.shippingAddress = [self buyAddressWithABRecord:payment.shippingAddress];
}
}
if ([payment respondsToSelector:@selector(billingContact)]) {
self.checkout.billingAddress = [BUYAddress buy_addressFromContact:payment.billingContact];
self.checkout.billingAddress = [self buyAddressWithContact:payment.billingContact];
} else {
self.checkout.billingAddress = [BUYAddress buy_addressFromRecord:payment.billingAddress];
self.checkout.billingAddress = [self buyAddressWithABRecord:payment.billingAddress];
}
[self.client updateCheckout:self.checkout completion:^(BUYCheckout *checkout, NSError *error) {
......@@ -127,6 +131,15 @@ const NSTimeInterval PollDelay = 0.5;
}];
}
- (BUYAddress *)buyAddressWithABRecord:(ABRecordRef)addressRecord
{
return [self.client.modelManager buyAddressWithABRecord:addressRecord];
}
- (BUYAddress *)buyAddressWithContact:(PKContact *)contact
{
return [self.client.modelManager buyAddressWithContact:contact];
}
- (void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewController *)controller
{
......@@ -135,13 +148,13 @@ const NSTimeInterval PollDelay = 0.5;
-(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingAddress:(ABRecordRef)address completion:(void (^)(PKPaymentAuthorizationStatus, NSArray<PKShippingMethod *> * _Nonnull, NSArray<PKPaymentSummaryItem *> * _Nonnull))completion
{
self.checkout.shippingAddress = [BUYAddress buy_addressFromRecord:address];
self.checkout.shippingAddress = [self buyAddressWithABRecord:address];
[self updateCheckoutWithAddressCompletion:completion];
}
-(void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController *)controller didSelectShippingContact:(PKContact *)contact completion:(void (^)(PKPaymentAuthorizationStatus, NSArray<PKShippingMethod *> * _Nonnull, NSArray<PKPaymentSummaryItem *> * _Nonnull))completion
{
self.checkout.shippingAddress = [BUYAddress buy_addressFromContact:contact];
self.checkout.shippingAddress = [self buyAddressWithContact:contact];
[self updateCheckoutWithAddressCompletion:completion];
}
......@@ -169,7 +182,7 @@ const NSTimeInterval PollDelay = 0.5;
// However, to ensure we never set partialAddresses to NO, we want to guard the setter. Should PKPaymentAuthorizationViewController ever
// return a full address through it's delegate method, this will still function since a complete address can be used to calculate shipping rates
if ([self.checkout.shippingAddress isPartialAddress] == YES) {
self.checkout.partialAddresses = YES;
self.checkout.partialAddresses = @YES;
}
if ([self.checkout.shippingAddress isValidAddressForShippingRates]) {
......@@ -338,3 +351,22 @@ const NSTimeInterval PollDelay = 0.5;
}
@end
@implementation BUYModelManager (ApplePay)
- (BUYAddress *)buyAddressWithABRecord:(ABRecordRef)addressRecord
{
BUYAddress *address = [self insertAddressWithJSONDictionary:nil];
[address updateWithRecord:addressRecord];
return address;
}
- (BUYAddress *)buyAddressWithContact:(PKContact *)contact
{
BUYAddress *address = [self insertAddressWithJSONDictionary:nil];
[address updateWithContact:contact];
return address;
}
@end
\ No newline at end of file
//
// BUYCollection+Additions.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 "BUYCollection.h"
#import "BUYClient.h"
@interface BUYCollection (Additions)
/**
* Converts the BUYCollectionSort enum to an API-compatible string for the collection sort parameter
*
* @param sort BUYCollectionSort enum
*
* @return API-compatible string for the collection sort parameter
*/
+(NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort;
@end
//
// BUYCollection+Additions.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 "BUYCollection+Additions.h"
@implementation BUYCollection (Additions)
+(NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort
{
switch (sort) {
case BUYCollectionSortBestSelling:
return @"best-selling";
case BUYCollectionSortCreatedAscending:
return @"created-ascending";
case BUYCollectionSortCreatedDescending:
return @"created-descending";
case BUYCollectionSortPriceAscending:
return @"price-ascending";
case BUYCollectionSortPriceDescending:
return @"price-descending";
case BUYCollectionSortTitleAscending:
return @"title-ascending";
case BUYCollectionSortTitleDescending:
return @"title-descending";
default:
return @"collection-default";
}
}
@end
//
// BUYProduct+Options.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 "BUYProduct.h"
@interface BUYProduct (Options)
/**
* Get the option values available for the given option
*
* @param option the option
*
* @return array of BUYOptionValues
*/
- (NSArray *)valuesForOption:(BUYOption *)option variants:(NSArray *)variants;
/**
* Determine the variant given an array of options
*
* @param options array of option values
*
* @return the product variant matching the set of options
*/
- (BUYProductVariant *)variantWithOptions:(NSArray *)options;
/**
* Determine if the variant is a default variant automatically created by Shopify
*
* @return YES if its a default variant
*/
- (BOOL)isDefaultVariant;
@end
//
// BUYProduct+Options.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 "BUYProduct+Options.h"
#import "BUYProductVariant+Options.h"
#import "BUYOption.h"
@implementation BUYProduct (Options)
- (NSArray *)valuesForOption:(BUYOption *)option variants:(NSArray *)variants
{
NSMutableOrderedSet *set = [NSMutableOrderedSet new];
for (BUYProductVariant *variant in variants) {
BUYOptionValue *optionValue = [variant optionValueForName:option.name];
[set addObject:optionValue];
}
return [set array];
}
- (BUYProductVariant *)variantWithOptions:(NSArray *)options
{
BUYProductVariant *variant = nil;
for (BUYProductVariant *aVariant in self.variants) {
BOOL match = YES;
for (BUYOptionValue *value in options) {
BUYOptionValue *optionValue = [aVariant optionValueForName:value.name];
if (![optionValue isEqual:value]) {
match = NO;
break;
}
}
if (match) {
variant = aVariant;
}
}
return variant;
}
- (BOOL)isDefaultVariant
{
if ([self.variants count] == 1) {
BUYProductVariant *productVariant = [self.variants firstObject];
BUYOptionValue *optionValue = [productVariant.options firstObject];
NSString *defaultTitleString = @"Default Title";
NSString *defaultString = @"Default";
if ([productVariant.title isEqualToString:defaultTitleString] &&
([optionValue.value isEqualToString:defaultTitleString] || [optionValue.value isEqualToString:defaultString])) {
return YES;
}
}
return NO;
}
@end
//
// BUYProductVariant+Options.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 "BUYProductVariant.h"
#import "BUYOptionValue.h"
@interface BUYProductVariant (Options)
/**
* Returns the option value for the given name
*
* @param optionName name of the option
*
* @return the option value
*/
- (BUYOptionValue *)optionValueForName:(NSString *)optionName;
/**
* Filters array of product variants filtered based on a selected option value
*
* @param productVariants BUYProductVariant objects to filter
* @param optionValue The option value to filter with
*
* @return A filtered copy of the original array
*/
+ (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue;
@end
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