Commit e19dab47 by Dima Bart

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

parent 5ee41564
......@@ -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
......@@ -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
......@@ -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
......
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