Commit e19dab47 by Dima Bart

Add addresses to customers. Fix NSNull values in BUYAddress objects.

parent 5ee41564
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#import "BUYObject.h" #import "BUYObject.h"
@class BUYAddress;
@interface BUYCustomer : BUYObject @interface BUYCustomer : BUYObject
/** /**
...@@ -118,4 +120,14 @@ ...@@ -118,4 +120,14 @@
*/ */
@property (nonatomic, strong) NSDate *updatedAt; @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 @end
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// //
#import "BUYCustomer.h" #import "BUYCustomer.h"
#import "BUYAddress.h"
@implementation BUYCustomer @implementation BUYCustomer
...@@ -56,6 +57,8 @@ ...@@ -56,6 +57,8 @@
_totalSpent = dictionary[@"total_spent"]; _totalSpent = dictionary[@"total_spent"];
_createdAt = dictionary[@"created_at"]; _createdAt = dictionary[@"created_at"];
_updatedAt = dictionary[@"updated_at"]; _updatedAt = dictionary[@"updated_at"];
_addresses = [BUYAddress convertJSONArray:dictionary[@"addresses"]];
_defaultAddress = [BUYAddress convertObject:dictionary[@"default_address"]];
} }
@end @end
...@@ -32,19 +32,19 @@ ...@@ -32,19 +32,19 @@
- (void)updateWithDictionary:(NSDictionary *)dictionary - (void)updateWithDictionary:(NSDictionary *)dictionary
{ {
self.address1 = dictionary[@"address1"]; self.address1 = [dictionary buy_objectForKey:@"address1"];
self.address2 = dictionary[@"address2"]; self.address2 = [dictionary buy_objectForKey:@"address2"];
self.city = dictionary[@"city"]; self.city = [dictionary buy_objectForKey:@"city"];
self.company = dictionary[@"company"]; self.company = [dictionary buy_objectForKey:@"company"];
self.firstName = dictionary[@"first_name"]; self.firstName = [dictionary buy_objectForKey:@"first_name"];
self.lastName = dictionary[@"last_name"]; self.lastName = [dictionary buy_objectForKey:@"last_name"];
self.phone = dictionary[@"phone"]; self.phone = [dictionary buy_objectForKey:@"phone"];
self.country = dictionary[@"country"]; self.country = [dictionary buy_objectForKey:@"country"];
self.countryCode = dictionary[@"country_code"]; self.countryCode = [dictionary buy_objectForKey:@"country_code"];
self.province = [dictionary buy_objectForKey:@"province"]; self.province = [dictionary buy_objectForKey:@"province"];
self.provinceCode = [dictionary buy_objectForKey:@"province_code"]; self.provinceCode = [dictionary buy_objectForKey:@"province_code"];
self.zip = dictionary[@"zip"]; self.zip = [dictionary buy_objectForKey:@"zip"];
} }
- (NSDictionary *)jsonDictionaryForCheckout - (NSDictionary *)jsonDictionaryForCheckout
......
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