Commit 002a528c by Brent Gulanowski

Add "Address.isDefault" boolean <-> "default".

parent a353280d
......@@ -232,6 +232,9 @@
XCTAssertTrue([addresses.firstObject isKindOfClass:[BUYAddress class]]);
XCTAssertNil(error);
NSArray *defaultAddresses = [addresses filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"isDefault == 1"]];
XCTAssertEqual(1, defaultAddresses.count);
[expectation fulfill];
}];
......
......@@ -41,6 +41,13 @@
<entry key="documentation" value="Unique identifier for the address"/>
</userInfo>
</attribute>
<attribute name="isDefault" optional="YES" attributeType="Boolean" syncable="YES">
<userInfo>
<entry key="discussion" value="Maps to &quot;default&quot; key in JSON."/>
<entry key="documentation" value="Whether the address is the owning customer's default address."/>
<entry key="JSONPropertyKey" value="default"/>
</userInfo>
</attribute>
<attribute name="lastName" optional="YES" attributeType="String" syncable="YES">
<userInfo>
<entry key="documentation" value="The last name of the person associated with the payment method."/>
......@@ -983,7 +990,7 @@
<memberEntity name="CheckoutAttribute"/>
</configuration>
<elements>
<element name="Address" positionX="-990" positionY="1444" width="128" height="255"/>
<element name="Address" positionX="-990" positionY="1444" width="128" height="270"/>
<element name="Cart" positionX="-1192" positionY="978" width="128" height="60"/>
<element name="CartLineItem" positionX="-987" positionY="1183" width="128" height="90"/>
<element name="Checkout" positionX="-765" positionY="1072" width="128" height="630"/>
......
......@@ -39,6 +39,7 @@ extern const struct BUYAddressAttributes {
__unsafe_unretained NSString *countryCode;
__unsafe_unretained NSString *firstName;
__unsafe_unretained NSString *identifier;
__unsafe_unretained NSString *isDefault;
__unsafe_unretained NSString *lastName;
__unsafe_unretained NSString *phone;
__unsafe_unretained NSString *province;
......@@ -115,6 +116,17 @@ extern const struct BUYAddressUserInfo {
- (void)setIdentifierValue:(int64_t)value_;
/**
* Whether the address is the owning customer's default address.
*
* Maps to "default" key in JSON.
*/
@property (nonatomic, strong) NSNumber* isDefault;
@property (atomic) BOOL isDefaultValue;
- (BOOL)isDefaultValue;
- (void)setIsDefaultValue:(BOOL)value_;
/**
* The last name of the person associated with the payment method.
*/
@property (nonatomic, strong) NSString* lastName;
......@@ -169,6 +181,9 @@ extern const struct BUYAddressUserInfo {
- (NSNumber*)primitiveIdentifier;
- (void)setPrimitiveIdentifier:(NSNumber*)value;
- (NSNumber*)primitiveIsDefault;
- (void)setPrimitiveIsDefault:(NSNumber*)value;
- (NSString*)primitiveLastName;
- (void)setPrimitiveLastName:(NSString*)value;
......
......@@ -37,6 +37,7 @@ const struct BUYAddressAttributes BUYAddressAttributes = {
.countryCode = @"countryCode",
.firstName = @"firstName",
.identifier = @"identifier",
.isDefault = @"isDefault",
.lastName = @"lastName",
.phone = @"phone",
.province = @"province",
......@@ -66,6 +67,11 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = {
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
return keyPaths;
}
if ([key isEqualToString:@"isDefaultValue"]) {
NSSet *affectingKey = [NSSet setWithObject:@"isDefault"];
keyPaths = [keyPaths setByAddingObjectsFromSet:affectingKey];
return keyPaths;
}
return keyPaths;
}
......@@ -79,6 +85,7 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = {
@dynamic countryCode;
@dynamic firstName;
@dynamic identifier;
@dynamic isDefault;
@dynamic lastName;
@dynamic phone;
@dynamic province;
......@@ -95,6 +102,15 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = {
[self setIdentifier:@(value_)];
}
- (BOOL)isDefaultValue {
NSNumber *result = [self isDefault];
return [result boolValue];
}
- (void)setIsDefaultValue:(BOOL)value_ {
[self setIsDefault:@(value_)];
}
#if defined CORE_DATA_PERSISTENCE
@dynamic customer;
#endif
......
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