Commit fcf1748d by Brent Gulanowski

Add address relationship to customer and make Address persistent.

parent fa091337
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
<entry key="documentation" value="The zip or postal code of the address."/> <entry key="documentation" value="The zip or postal code of the address."/>
</userInfo> </userInfo>
</attribute> </attribute>
<relationship name="customer" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Customer" inverseName="addresses" inverseEntity="Customer" syncable="YES"/>
<userInfo> <userInfo>
<entry key="documentation" value="A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion."/> <entry key="documentation" value="A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion."/>
</userInfo> </userInfo>
...@@ -376,6 +377,8 @@ ...@@ -376,6 +377,8 @@
<attribute name="totalSpent" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/> <attribute name="totalSpent" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"/>
<attribute name="updatedAt" optional="YES" attributeType="Date" syncable="YES"/> <attribute name="updatedAt" optional="YES" attributeType="Date" syncable="YES"/>
<attribute name="verifiedEmail" optional="YES" attributeType="Boolean" syncable="YES"/> <attribute name="verifiedEmail" optional="YES" attributeType="Boolean" syncable="YES"/>
<relationship name="addresses" optional="YES" toMany="YES" deletionRule="Cascade" destinationEntity="Address" inverseName="customer" inverseEntity="Address" syncable="YES"/>
<relationship name="defaultAddres" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Address" syncable="YES"/>
</entity> </entity>
<entity name="Discount" representedClassName="BUYDiscount" syncable="YES"> <entity name="Discount" representedClassName="BUYDiscount" syncable="YES">
<attribute name="amount" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES"> <attribute name="amount" optional="YES" attributeType="Decimal" defaultValueString="0.0" syncable="YES">
...@@ -974,6 +977,7 @@ ...@@ -974,6 +977,7 @@
<memberEntity name="Shop"/> <memberEntity name="Shop"/>
<memberEntity name="LineItem"/> <memberEntity name="LineItem"/>
<memberEntity name="Order"/> <memberEntity name="Order"/>
<memberEntity name="Address"/>
</configuration> </configuration>
<configuration name="transient"> <configuration name="transient">
<memberEntity name="Checkout"/> <memberEntity name="Checkout"/>
...@@ -982,17 +986,16 @@ ...@@ -982,17 +986,16 @@
<memberEntity name="Discount"/> <memberEntity name="Discount"/>
<memberEntity name="TaxLine"/> <memberEntity name="TaxLine"/>
<memberEntity name="ShippingRate"/> <memberEntity name="ShippingRate"/>
<memberEntity name="Address"/>
<memberEntity name="CheckoutAttribute"/> <memberEntity name="CheckoutAttribute"/>
</configuration> </configuration>
<elements> <elements>
<element name="Address" positionX="126" positionY="521" width="128" height="225"/> <element name="Address" positionX="126" positionY="521" width="128" height="240"/>
<element name="Cart" positionX="-576" positionY="558" width="128" height="60"/> <element name="Cart" positionX="-576" positionY="558" width="128" height="60"/>
<element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/> <element name="CartLineItem" positionX="-380" positionY="558" width="128" height="90"/>
<element name="Checkout" positionX="333" positionY="442" width="128" height="645"/> <element name="Checkout" positionX="333" positionY="442" width="128" height="645"/>
<element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/> <element name="CheckoutAttribute" positionX="-954" positionY="594" width="128" height="90"/>
<element name="Collection" positionX="-963" positionY="772" width="128" height="210"/> <element name="Collection" positionX="-963" positionY="772" width="128" height="210"/>
<element name="Customer" positionX="106" positionY="1263" width="128" height="60"/> <element name="Customer" positionX="106" positionY="1263" width="128" height="330"/>
<element name="Discount" positionX="126" positionY="877" width="128" height="105"/> <element name="Discount" positionX="126" positionY="877" width="128" height="105"/>
<element name="GiftCard" positionX="531" positionY="862" width="128" height="135"/> <element name="GiftCard" positionX="531" positionY="862" width="128" height="135"/>
<element name="ImageLink" positionX="-1161" positionY="832" width="128" height="165"/> <element name="ImageLink" positionX="-1161" positionY="832" width="128" height="165"/>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
@interface BUYCustomer : _BUYCustomer {} @interface BUYCustomer : _BUYCustomer {}
@property (nonatomic, readonly) NSSet *addresses;
@property (readonly) NSString *fullName; @property (readonly) NSString *fullName;
@end @end
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
// DO NOT EDIT. This file is machine-generated and constantly overwritten. // DO NOT EDIT. This file is machine-generated and constantly overwritten.
// Make changes to BUYAddress.h instead. // Make changes to BUYAddress.h instead.
#import "BUYObject.h" #import <Buy/BUYManagedObject.h>
#import <Buy/BUYModelManager.h> #import "BUYModelManager.h"
extern const struct BUYAddressAttributes { extern const struct BUYAddressAttributes {
__unsafe_unretained NSString *address1; __unsafe_unretained NSString *address1;
...@@ -45,10 +45,16 @@ extern const struct BUYAddressAttributes { ...@@ -45,10 +45,16 @@ extern const struct BUYAddressAttributes {
__unsafe_unretained NSString *zip; __unsafe_unretained NSString *zip;
} BUYAddressAttributes; } BUYAddressAttributes;
extern const struct BUYAddressRelationships {
__unsafe_unretained NSString *customer;
} BUYAddressRelationships;
extern const struct BUYAddressUserInfo { extern const struct BUYAddressUserInfo {
__unsafe_unretained NSString *documentation; __unsafe_unretained NSString *documentation;
} BUYAddressUserInfo; } BUYAddressUserInfo;
@class BUYCustomer;
@class BUYAddress; @class BUYAddress;
@interface BUYModelManager (BUYAddressInserting) @interface BUYModelManager (BUYAddressInserting)
- (NSArray<BUYAddress *> *)allAddressObjects; - (NSArray<BUYAddress *> *)allAddressObjects;
...@@ -60,8 +66,7 @@ extern const struct BUYAddressUserInfo { ...@@ -60,8 +66,7 @@ extern const struct BUYAddressUserInfo {
/** /**
* A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion. * A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion.
*/ */
@interface _BUYAddress : BUYObject @interface _BUYAddress : BUYCachedObject
+ (NSString *)entityName; + (NSString *)entityName;
/** /**
...@@ -124,5 +129,49 @@ extern const struct BUYAddressUserInfo { ...@@ -124,5 +129,49 @@ extern const struct BUYAddressUserInfo {
*/ */
@property (nonatomic, strong) NSString* zip; @property (nonatomic, strong) NSString* zip;
@property (nonatomic, strong) BUYCustomer *customer;
@end @end
@interface _BUYAddress (CoreDataGeneratedPrimitiveAccessors)
- (NSString*)primitiveAddress1;
- (void)setPrimitiveAddress1:(NSString*)value;
- (NSString*)primitiveAddress2;
- (void)setPrimitiveAddress2:(NSString*)value;
- (NSString*)primitiveCity;
- (void)setPrimitiveCity:(NSString*)value;
- (NSString*)primitiveCompany;
- (void)setPrimitiveCompany:(NSString*)value;
- (NSString*)primitiveCountry;
- (void)setPrimitiveCountry:(NSString*)value;
- (NSString*)primitiveCountryCode;
- (void)setPrimitiveCountryCode:(NSString*)value;
- (NSString*)primitiveFirstName;
- (void)setPrimitiveFirstName:(NSString*)value;
- (NSString*)primitiveLastName;
- (void)setPrimitiveLastName:(NSString*)value;
- (NSString*)primitivePhone;
- (void)setPrimitivePhone:(NSString*)value;
- (NSString*)primitiveProvince;
- (void)setPrimitiveProvince:(NSString*)value;
- (NSString*)primitiveProvinceCode;
- (void)setPrimitiveProvinceCode:(NSString*)value;
- (NSString*)primitiveZip;
- (void)setPrimitiveZip:(NSString*)value;
- (BUYCustomer *)primitiveCustomer;
- (void)setPrimitiveCustomer:(BUYCustomer *)value;
@end
...@@ -43,6 +43,10 @@ const struct BUYAddressAttributes BUYAddressAttributes = { ...@@ -43,6 +43,10 @@ const struct BUYAddressAttributes BUYAddressAttributes = {
.zip = @"zip", .zip = @"zip",
}; };
const struct BUYAddressRelationships BUYAddressRelationships = {
.customer = @"customer",
};
const struct BUYAddressUserInfo BUYAddressUserInfo = { const struct BUYAddressUserInfo BUYAddressUserInfo = {
.documentation = @"A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion.", .documentation = @"A BUYAddress represents a shipping or billing address on an order. This will be associated with the customer upon completion.",
}; };
...@@ -59,6 +63,169 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = { ...@@ -59,6 +63,169 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = {
return keyPaths; return keyPaths;
} }
#if defined CORE_DATA_PERSISTENCE
- (NSString*)address1 {
[self willAccessValueForKey:@"address1"];
id value = [self primitiveValueForKey:@"address1"];
[self didAccessValueForKey:@"address1"];
return value;
}
- (void)setAddress1:(NSString*)value_ {
[self willChangeValueForKey:@"address1"];
[self setPrimitiveValue:value_ forKey:@"address1"];
[self didChangeValueForKey:@"address1"];
}
- (NSString*)address2 {
[self willAccessValueForKey:@"address2"];
id value = [self primitiveValueForKey:@"address2"];
[self didAccessValueForKey:@"address2"];
return value;
}
- (void)setAddress2:(NSString*)value_ {
[self willChangeValueForKey:@"address2"];
[self setPrimitiveValue:value_ forKey:@"address2"];
[self didChangeValueForKey:@"address2"];
}
- (NSString*)city {
[self willAccessValueForKey:@"city"];
id value = [self primitiveValueForKey:@"city"];
[self didAccessValueForKey:@"city"];
return value;
}
- (void)setCity:(NSString*)value_ {
[self willChangeValueForKey:@"city"];
[self setPrimitiveValue:value_ forKey:@"city"];
[self didChangeValueForKey:@"city"];
}
- (NSString*)company {
[self willAccessValueForKey:@"company"];
id value = [self primitiveValueForKey:@"company"];
[self didAccessValueForKey:@"company"];
return value;
}
- (void)setCompany:(NSString*)value_ {
[self willChangeValueForKey:@"company"];
[self setPrimitiveValue:value_ forKey:@"company"];
[self didChangeValueForKey:@"company"];
}
- (NSString*)country {
[self willAccessValueForKey:@"country"];
id value = [self primitiveValueForKey:@"country"];
[self didAccessValueForKey:@"country"];
return value;
}
- (void)setCountry:(NSString*)value_ {
[self willChangeValueForKey:@"country"];
[self setPrimitiveValue:value_ forKey:@"country"];
[self didChangeValueForKey:@"country"];
}
- (NSString*)countryCode {
[self willAccessValueForKey:@"countryCode"];
id value = [self primitiveValueForKey:@"countryCode"];
[self didAccessValueForKey:@"countryCode"];
return value;
}
- (void)setCountryCode:(NSString*)value_ {
[self willChangeValueForKey:@"countryCode"];
[self setPrimitiveValue:value_ forKey:@"countryCode"];
[self didChangeValueForKey:@"countryCode"];
}
- (NSString*)firstName {
[self willAccessValueForKey:@"firstName"];
id value = [self primitiveValueForKey:@"firstName"];
[self didAccessValueForKey:@"firstName"];
return value;
}
- (void)setFirstName:(NSString*)value_ {
[self willChangeValueForKey:@"firstName"];
[self setPrimitiveValue:value_ forKey:@"firstName"];
[self didChangeValueForKey:@"firstName"];
}
- (NSString*)lastName {
[self willAccessValueForKey:@"lastName"];
id value = [self primitiveValueForKey:@"lastName"];
[self didAccessValueForKey:@"lastName"];
return value;
}
- (void)setLastName:(NSString*)value_ {
[self willChangeValueForKey:@"lastName"];
[self setPrimitiveValue:value_ forKey:@"lastName"];
[self didChangeValueForKey:@"lastName"];
}
- (NSString*)phone {
[self willAccessValueForKey:@"phone"];
id value = [self primitiveValueForKey:@"phone"];
[self didAccessValueForKey:@"phone"];
return value;
}
- (void)setPhone:(NSString*)value_ {
[self willChangeValueForKey:@"phone"];
[self setPrimitiveValue:value_ forKey:@"phone"];
[self didChangeValueForKey:@"phone"];
}
- (NSString*)province {
[self willAccessValueForKey:@"province"];
id value = [self primitiveValueForKey:@"province"];
[self didAccessValueForKey:@"province"];
return value;
}
- (void)setProvince:(NSString*)value_ {
[self willChangeValueForKey:@"province"];
[self setPrimitiveValue:value_ forKey:@"province"];
[self didChangeValueForKey:@"province"];
}
- (NSString*)provinceCode {
[self willAccessValueForKey:@"provinceCode"];
id value = [self primitiveValueForKey:@"provinceCode"];
[self didAccessValueForKey:@"provinceCode"];
return value;
}
- (void)setProvinceCode:(NSString*)value_ {
[self willChangeValueForKey:@"provinceCode"];
[self setPrimitiveValue:value_ forKey:@"provinceCode"];
[self didChangeValueForKey:@"provinceCode"];
}
- (NSString*)zip {
[self willAccessValueForKey:@"zip"];
id value = [self primitiveValueForKey:@"zip"];
[self didAccessValueForKey:@"zip"];
return value;
}
- (void)setZip:(NSString*)value_ {
[self willChangeValueForKey:@"zip"];
[self setPrimitiveValue:value_ forKey:@"zip"];
[self didChangeValueForKey:@"zip"];
}
#endif
#if defined CORE_DATA_PERSISTENCE
@dynamic customer;
#endif
@end @end
#pragma mark - #pragma mark -
...@@ -77,7 +244,7 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = { ...@@ -77,7 +244,7 @@ const struct BUYAddressUserInfo BUYAddressUserInfo = {
- (NSArray<BUYAddress *> *)allAddressObjects - (NSArray<BUYAddress *> *)allAddressObjects
{ {
return (NSArray<BUYAddress *> *)[self buy_objectsWithEntityName:@"Address" identifiers:nil]; return (NSArray<BUYAddress *> *)[self buy_objectsWithEntityName:@"Address" identifiers:nil];
} }
- (BUYAddress *)fetchAddressWithIdentifierValue:(int64_t)identifier - (BUYAddress *)fetchAddressWithIdentifierValue:(int64_t)identifier
......
...@@ -50,6 +50,14 @@ extern const struct BUYCustomerAttributes { ...@@ -50,6 +50,14 @@ extern const struct BUYCustomerAttributes {
__unsafe_unretained NSString *verifiedEmail; __unsafe_unretained NSString *verifiedEmail;
} BUYCustomerAttributes; } BUYCustomerAttributes;
extern const struct BUYCustomerRelationships {
__unsafe_unretained NSString *addresses;
__unsafe_unretained NSString *defaultAddres;
} BUYCustomerRelationships;
@class BUYAddress;
@class BUYAddress;
@class BUYCustomer; @class BUYCustomer;
@interface BUYModelManager (BUYCustomerInserting) @interface BUYModelManager (BUYCustomerInserting)
- (NSArray<BUYCustomer *> *)allCustomerObjects; - (NSArray<BUYCustomer *> *)allCustomerObjects;
...@@ -123,6 +131,15 @@ extern const struct BUYCustomerAttributes { ...@@ -123,6 +131,15 @@ extern const struct BUYCustomerAttributes {
- (BOOL)verifiedEmailValue; - (BOOL)verifiedEmailValue;
- (void)setVerifiedEmailValue:(BOOL)value_; - (void)setVerifiedEmailValue:(BOOL)value_;
@property (nonatomic, strong) NSSet *addresses;
- (NSMutableSet *)addressesSet;
@property (nonatomic, strong) BUYAddress *defaultAddres;
@end
@interface _BUYCustomer (AddressesCoreDataGeneratedAccessors)
@end @end
@interface _BUYCustomer (CoreDataGeneratedPrimitiveAccessors) @interface _BUYCustomer (CoreDataGeneratedPrimitiveAccessors)
...@@ -178,4 +195,10 @@ extern const struct BUYCustomerAttributes { ...@@ -178,4 +195,10 @@ extern const struct BUYCustomerAttributes {
- (NSNumber*)primitiveVerifiedEmail; - (NSNumber*)primitiveVerifiedEmail;
- (void)setPrimitiveVerifiedEmail:(NSNumber*)value; - (void)setPrimitiveVerifiedEmail:(NSNumber*)value;
- (NSMutableSet *)primitiveAddresses;
- (void)setPrimitiveAddresses:(NSMutableSet *)value;
- (BUYAddress *)primitiveDefaultAddres;
- (void)setPrimitiveDefaultAddres:(BUYAddress *)value;
@end @end
...@@ -48,6 +48,11 @@ const struct BUYCustomerAttributes BUYCustomerAttributes = { ...@@ -48,6 +48,11 @@ const struct BUYCustomerAttributes BUYCustomerAttributes = {
.verifiedEmail = @"verifiedEmail", .verifiedEmail = @"verifiedEmail",
}; };
const struct BUYCustomerRelationships BUYCustomerRelationships = {
.addresses = @"addresses",
.defaultAddres = @"defaultAddres",
};
@implementation _BUYCustomer @implementation _BUYCustomer
+ (NSString *)entityName { + (NSString *)entityName {
...@@ -383,6 +388,23 @@ const struct BUYCustomerAttributes BUYCustomerAttributes = { ...@@ -383,6 +388,23 @@ const struct BUYCustomerAttributes BUYCustomerAttributes = {
[self setVerifiedEmail:@(value_)]; [self setVerifiedEmail:@(value_)];
} }
#if defined CORE_DATA_PERSISTENCE
@dynamic addresses;
#endif
- (NSMutableSet *)addressesSet {
[self willAccessValueForKey:@"addresses"];
NSMutableSet *result = (NSMutableSet *)[self mutableSetValueForKey:@"addresses"];
[self didAccessValueForKey:@"addresses"];
return result;
}
#if defined CORE_DATA_PERSISTENCE
@dynamic defaultAddres;
#endif
@end @end
#pragma mark - #pragma mark -
......
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