From e19dab470e01f451424ad7363d7bf6b751acc614 Mon Sep 17 00:00:00 2001 From: Dima Bart <dima.bart01@gmail.com> Date: Tue, 3 May 2016 09:59:20 -0400 Subject: [PATCH] Add addresses to customers. Fix NSNull values in BUYAddress objects. --- Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.h | 12 ++++++++++++ Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.m | 3 +++ Mobile Buy SDK/Mobile Buy SDK/Models/Transient/BUYAddress.m | 20 ++++++++++---------- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.h b/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.h index 476d766..6803043 100644 --- a/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.h +++ b/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.h @@ -26,6 +26,8 @@ #import "BUYObject.h" +@class BUYAddress; + @interface BUYCustomer : BUYObject /** @@ -118,4 +120,14 @@ */ @property (nonatomic, strong) NSDate *updatedAt; +/** + * An array of addresses for the customer. + */ +@property (nonatomic, strong) NSArray<BUYAddress *> *addresses; + +/** + * The default address for the customer. + */ +@property (nonatomic, strong) BUYAddress *defaultAddress; + @end diff --git a/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.m b/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.m index ad9022d..c14c114 100644 --- a/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.m +++ b/Mobile Buy SDK/Mobile Buy SDK/Models/BUYCustomer.m @@ -25,6 +25,7 @@ // #import "BUYCustomer.h" +#import "BUYAddress.h" @implementation BUYCustomer @@ -56,6 +57,8 @@ _totalSpent = dictionary[@"total_spent"]; _createdAt = dictionary[@"created_at"]; _updatedAt = dictionary[@"updated_at"]; + _addresses = [BUYAddress convertJSONArray:dictionary[@"addresses"]]; + _defaultAddress = [BUYAddress convertObject:dictionary[@"default_address"]]; } @end diff --git a/Mobile Buy SDK/Mobile Buy SDK/Models/Transient/BUYAddress.m b/Mobile Buy SDK/Mobile Buy SDK/Models/Transient/BUYAddress.m index 7eafbb6..d43697a 100644 --- a/Mobile Buy SDK/Mobile Buy SDK/Models/Transient/BUYAddress.m +++ b/Mobile Buy SDK/Mobile Buy SDK/Models/Transient/BUYAddress.m @@ -32,19 +32,19 @@ - (void)updateWithDictionary:(NSDictionary *)dictionary { - 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.address1 = [dictionary buy_objectForKey:@"address1"]; + self.address2 = [dictionary buy_objectForKey:@"address2"]; + self.city = [dictionary buy_objectForKey:@"city"]; + self.company = [dictionary buy_objectForKey:@"company"]; + self.firstName = [dictionary buy_objectForKey:@"first_name"]; + self.lastName = [dictionary buy_objectForKey:@"last_name"]; + self.phone = [dictionary buy_objectForKey:@"phone"]; - self.country = dictionary[@"country"]; - self.countryCode = dictionary[@"country_code"]; + self.country = [dictionary buy_objectForKey:@"country"]; + self.countryCode = [dictionary buy_objectForKey:@"country_code"]; self.province = [dictionary buy_objectForKey:@"province"]; self.provinceCode = [dictionary buy_objectForKey:@"province_code"]; - self.zip = dictionary[@"zip"]; + self.zip = [dictionary buy_objectForKey:@"zip"]; } - (NSDictionary *)jsonDictionaryForCheckout -- libgit2 0.26.0