Commit 6c6a94a5 by Dima Bart

Add nullability annotation to model classes.

parent 2025e5fe
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
- (void)setUp - (void)setUp
{ {
_modelManager = [BUYModelManager modelManager]; _modelManager = [BUYModelManager modelManager];
_checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager cart:nil]; _checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager cart:[BUYCart new]];
} }
- (void)tearDown - (void)tearDown
......
...@@ -766,7 +766,7 @@ ...@@ -766,7 +766,7 @@
{ {
[OHHTTPStubs stubUsingResponseWithKey:@"testFetchingShippingRatesWithInvalidCheckout_1" useMocks:[self shouldUseMocks]]; [OHHTTPStubs stubUsingResponseWithKey:@"testFetchingShippingRatesWithInvalidCheckout_1" useMocks:[self shouldUseMocks]];
BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager cart:nil]; BUYCheckout *checkout = [[BUYCheckout alloc] initWithModelManager:_modelManager cart:[BUYCart new]];
checkout.token = @"bananaaaa"; checkout.token = @"bananaaaa";
XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)]; XCTestExpectation *expectation = [self expectationWithDescription:NSStringFromSelector(_cmd)];
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
- (void)testJsonDictionaryDoesntIncludeVariantsWithoutIds - (void)testJsonDictionaryDoesntIncludeVariantsWithoutIds
{ {
_lineItem = [_modelManager lineItemWithVariant:nil]; _lineItem = [_modelManager lineItemWithVariant:[BUYProductVariant new]];
NSDictionary *json = [_lineItem jsonDictionaryForCheckout]; NSDictionary *json = [_lineItem jsonDictionaryForCheckout];
XCTAssertNotNil(json); XCTAssertNotNil(json);
XCTAssertNil(json[@"variant_id"]); XCTAssertNil(json[@"variant_id"]);
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
- (BUYDirtyTracked *)dirtyTrackedObject - (BUYDirtyTracked *)dirtyTrackedObject
{ {
return [[BUYDirtyTracked alloc] initWithModelManager:nil JSONDictionary:nil]; return [[BUYDirtyTracked alloc] initWithModelManager:[BUYModelManager modelManager] JSONDictionary:nil];
} }
@end @end
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
@import Foundation; @import Foundation;
#import <Buy/BUYSerializable.h> #import <Buy/BUYSerializable.h>
NS_ASSUME_NONNULL_BEGIN
/** /**
* This represents raw credit card data that the user is posting. You MUST discard this object as soon as it has been posted * This represents raw credit card data that the user is posting. You MUST discard this object as soon as it has been posted
...@@ -37,27 +38,29 @@ ...@@ -37,27 +38,29 @@
* The full name on the credit card * The full name on the credit card
* First and Last in this format: 'First Last'. * First and Last in this format: 'First Last'.
*/ */
@property (nonatomic, copy) NSString *nameOnCard; @property (nonatomic, nullable, copy) NSString *nameOnCard;
/** /**
* The full credit card number. * The full credit card number.
* This should be a numerical value without spaces, dashes or any other special characters. * This should be a numerical value without spaces, dashes or any other special characters.
*/ */
@property (nonatomic, copy) NSString *number; @property (nonatomic, nullable, copy) NSString *number;
/** /**
* The month that the credit card expires, as a numerical value (i.e. 12 for December). * The month that the credit card expires, as a numerical value (i.e. 12 for December).
*/ */
@property (nonatomic, copy) NSString *expiryMonth; @property (nonatomic, nullable, copy) NSString *expiryMonth;
/** /**
* The last two digits of the year in which the credit card expires (i.e. 18 for 2018). * The last two digits of the year in which the credit card expires (i.e. 18 for 2018).
*/ */
@property (nonatomic, copy) NSString *expiryYear; @property (nonatomic, nullable, copy) NSString *expiryYear;
/** /**
* The Card Verification Value number (or whichever card security code should be used for the card type). * The Card Verification Value number (or whichever card security code should be used for the card type).
*/ */
@property (nonatomic, copy) NSString *cvv; @property (nonatomic, nullable, copy) NSString *cvv;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,15 +25,17 @@ ...@@ -25,15 +25,17 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@interface BUYError : NSObject @interface BUYError : NSObject
@property (nonatomic, copy) NSString *key; @property (nonatomic, nonnull, copy, readonly) NSString *key;
@property (nonatomic, nullable, copy, readonly) NSString *code;
@property (nonatomic, nullable, copy, readonly) NSString *message;
@property (nonatomic, nullable, copy, readonly) NSDictionary<NSString *, NSString *> *options;
- (instancetype)initWithKey:(NSString *)key json:(NSDictionary *)json; - (instancetype)initWithKey:(NSString *)key json:(NSDictionary *)json;
@property (nonatomic, copy) NSString *code;
@property (nonatomic, copy) NSString *message;
@property (nonatomic, copy) NSDictionary<NSString *, NSString *> *options;
@end @end
NS_ASSUME_NONNULL_END
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
{ {
self = [super init]; self = [super init];
if (self) { if (self) {
self.key = key; _key = [key copy];
[self setValuesForKeysWithDictionary:json]; [self setValuesForKeysWithDictionary:json];
} }
return self; return self;
......
...@@ -25,8 +25,8 @@ ...@@ -25,8 +25,8 @@
// //
#import <CoreData/CoreData.h> #import <CoreData/CoreData.h>
#import "BUYObject.h"
#import <Buy/BUYObject.h> NS_ASSUME_NONNULL_BEGIN
#if defined CORE_DATA_PERSISTENCE #if defined CORE_DATA_PERSISTENCE
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
@interface BUYManagedObject : NSManagedObject<BUYObject> @interface BUYManagedObject : NSManagedObject<BUYObject>
- (nonnull instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
@end @end
...@@ -56,11 +56,13 @@ ...@@ -56,11 +56,13 @@
*/ */
@interface BUYObject (BUYManagedObjectConformance) @interface BUYObject (BUYManagedObjectConformance)
- (void)willAccessValueForKey:(nonnull NSString *)key; - (void)willAccessValueForKey:(NSString *)key;
- (void)didAccessValueForKey:(nonnull NSString *)key; - (void)didAccessValueForKey:(NSString *)key;
- (nullable id)primitiveValueForKey:(nonnull NSString *)key; - (nullable id)primitiveValueForKey:(NSString *)key;
- (void)setPrimitiveValue:(nullable id)value forKey:(nonnull NSString *)key; - (void)setPrimitiveValue:(nullable id)value forKey:(NSString *)key;
@end @end
#endif #endif
NS_ASSUME_NONNULL_END
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "BUYObject.h"
#import <Buy/BUYObject.h> #import "BUYModelManagerProtocol.h"
#import <Buy/BUYModelManagerProtocol.h> NS_ASSUME_NONNULL_BEGIN
/** /**
* A basic implementation of the BUYModelManager interface that does no caching. New objects are created using alloc/init. * A basic implementation of the BUYModelManager interface that does no caching. New objects are created using alloc/init.
...@@ -54,3 +54,5 @@ ...@@ -54,3 +54,5 @@
+ (instancetype)modelManager; + (instancetype)modelManager;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// //
#import <CoreData/CoreData.h> #import <CoreData/CoreData.h>
NS_ASSUME_NONNULL_BEGIN
@protocol BUYObject; @protocol BUYObject;
...@@ -52,7 +53,7 @@ ...@@ -52,7 +53,7 @@
* *
* @return A new or existing model object. * @return A new or existing model object.
*/ */
- (id<BUYObject>)buy_objectWithEntityName:(NSString *)entityName JSONDictionary:(NSDictionary *)JSON; - (id<BUYObject>)buy_objectWithEntityName:(NSString *)entityName JSONDictionary:(nullable NSDictionary *)JSON;
- (NSArray<id<BUYObject>> *)buy_objectsWithEntityName:(NSString *)entityName JSONArray:(NSArray *)JSON; - (NSArray<id<BUYObject>> *)buy_objectsWithEntityName:(NSString *)entityName JSONArray:(NSArray *)JSON;
/** /**
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
* *
* @return An object from the cache matching the provided identifier, or nil if no matching object is found. * @return An object from the cache matching the provided identifier, or nil if no matching object is found.
*/ */
- (id<BUYObject>)buy_objectWithEntityName:(NSString *)entityName identifier:(NSNumber *)identifier; - (nullable id<BUYObject>)buy_objectWithEntityName:(NSString *)entityName identifier:(NSNumber *)identifier;
/** /**
* Find all the objects in the cache matching the provided identifiers. * Find all the objects in the cache matching the provided identifiers.
...@@ -74,7 +75,7 @@ ...@@ -74,7 +75,7 @@
* *
* @return An array of objects from the cache matching the provided identifiers, if any. * @return An array of objects from the cache matching the provided identifiers, if any.
*/ */
- (NSArray<id<BUYObject>> *)buy_objectsWithEntityName:(NSString *)entityName identifiers:(NSArray *)identifiers; - (NSArray<id<BUYObject>> *)buy_objectsWithEntityName:(NSString *)entityName identifiers:(nullable NSArray *)identifiers;
/** /**
* If there is a local cache available, and the object is cached, it is flushed from the cache. Depending on the type of * If there is a local cache available, and the object is cached, it is flushed from the cache. Depending on the type of
...@@ -109,3 +110,5 @@ ...@@ -109,3 +110,5 @@
- (BOOL)buy_purgeObjectsWithEntityName:(NSString *)entityName matchingPredicate:(NSPredicate *)predicate; - (BOOL)buy_purgeObjectsWithEntityName:(NSString *)entityName matchingPredicate:(NSPredicate *)predicate;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import "BUYObjectProtocol.h"
#import <Buy/BUYObjectProtocol.h> #import "BUYModelManagerProtocol.h"
#import <Buy/BUYModelManagerProtocol.h> NS_ASSUME_NONNULL_BEGIN
@interface BUYObject : NSObject<BUYObject> @interface BUYObject : NSObject<BUYObject>
...@@ -37,8 +37,10 @@ ...@@ -37,8 +37,10 @@
*/ */
@property (nonatomic, readonly, getter=isDirty) BOOL dirty; @property (nonatomic, readonly, getter=isDirty) BOOL dirty;
- (NSSet *)dirtyProperties; - (nullable NSSet *)dirtyProperties;
- (void)markPropertyAsDirty:(NSString *)property; - (void)markPropertyAsDirty:(NSString *)property;
- (void)markAsClean; - (void)markAsClean;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
#import <Buy/BUYSerializable.h> #import "BUYSerializable.h"
NS_ASSUME_NONNULL_BEGIN
@class NSEntityDescription; @class NSEntityDescription;
...@@ -37,12 +38,12 @@ ...@@ -37,12 +38,12 @@
*/ */
@protocol BUYObject <BUYSerializable> @protocol BUYObject <BUYSerializable>
@property (nonatomic, readonly, weak) id<BUYModelManager> modelManager; @property (nonatomic, readonly, nullable, weak) id<BUYModelManager> modelManager;
/** /**
* Transient model objects need an entity for introspection. * Transient model objects need an entity for introspection.
*/ */
@property (nonatomic, readonly, weak) NSEntityDescription *entity; @property (nonatomic, readonly, nullable, weak) NSEntityDescription *entity;
/** /**
* A dictionary of @{ NSString : NSPropertyDescription } where the keys are property names. * A dictionary of @{ NSString : NSPropertyDescription } where the keys are property names.
...@@ -63,7 +64,7 @@ ...@@ -63,7 +64,7 @@
/** /**
* A predicate composed of values from the JSON. For objects that do not have an "identifier"/"id" property. * A predicate composed of values from the JSON. For objects that do not have an "identifier"/"id" property.
*/ */
+ (NSPredicate *)fetchPredicateWithJSON:(NSDictionary *)JSONDictionary; + (nullable NSPredicate *)fetchPredicateWithJSON:(NSDictionary *)JSONDictionary;
/** /**
* Persistent classes return YES; transient classes return NO. * Persistent classes return YES; transient classes return NO.
...@@ -77,6 +78,8 @@ ...@@ -77,6 +78,8 @@
@optional @optional
- (instancetype)initWithModelManager:(id<BUYModelManager>)modelManager JSONDictionary:(NSDictionary *)dictionary; - (instancetype)initWithModelManager:(id<BUYModelManager>)modelManager JSONDictionary:(nullable NSDictionary *)dictionary;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,12 @@ ...@@ -24,8 +24,12 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
NS_ASSUME_NONNULL_BEGIN
@protocol BUYPaymentToken <NSObject> @protocol BUYPaymentToken <NSObject>
- (NSDictionary *)JSONDictionary; - (NSDictionary *)JSONDictionary;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// //
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol BUYSerializable <NSObject> @protocol BUYSerializable <NSObject>
...@@ -35,3 +36,5 @@ ...@@ -35,3 +36,5 @@
@interface NSDictionary (BUYSerializable) <BUYSerializable> @interface NSDictionary (BUYSerializable) <BUYSerializable>
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYAddress.h> #import "_BUYAddress.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYAddress : _BUYAddress {} @interface BUYAddress : _BUYAddress {}
...@@ -47,3 +48,5 @@ ...@@ -47,3 +48,5 @@
- (BOOL)isValidAddressForShippingRates; - (BOOL)isValidAddressForShippingRates;
@end @end
NS_ASSUME_NONNULL_END
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
// //
#import <Buy/_BUYCart.h> #import <Buy/_BUYCart.h>
NS_ASSUME_NONNULL_BEGIN
@class BUYProductVariant; @class BUYProductVariant;
@class BUYLineItem; @class BUYLineItem;
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
* *
* These are different from BUYLineItem objects. The line item objects do include the BUYProductVariant. * These are different from BUYLineItem objects. The line item objects do include the BUYProductVariant.
*/ */
- (nonnull NSArray<BUYCartLineItem *> *)lineItemsArray; - (NSArray<BUYCartLineItem *> *)lineItemsArray;
/** /**
* Returns true if the cart is acceptable to send to Shopify. * Returns true if the cart is acceptable to send to Shopify.
...@@ -56,7 +57,7 @@ ...@@ -56,7 +57,7 @@
* *
* @param variant The BUYProductVariant to add to the BUYCart or increase by one quantity * @param variant The BUYProductVariant to add to the BUYCart or increase by one quantity
*/ */
- (void)addVariant:(nonnull BUYProductVariant *)variant; - (void)addVariant:(BUYProductVariant *)variant;
/** /**
* Removes the BUYCartLineItem from the BUYCart associated with the given BUYProductVariant object. * Removes the BUYCartLineItem from the BUYCart associated with the given BUYProductVariant object.
...@@ -64,7 +65,7 @@ ...@@ -64,7 +65,7 @@
* *
* @param variant The BUYProductVariant to remove from the BUYCart or decrease by one quantity * @param variant The BUYProductVariant to remove from the BUYCart or decrease by one quantity
*/ */
- (void)removeVariant:(nonnull BUYProductVariant *)variant; - (void)removeVariant:(BUYProductVariant *)variant;
/** /**
* Adds a BUYCartLineItem with a set quantity to the BUYCart with the given BUYProductVariant object on it. * Adds a BUYCartLineItem with a set quantity to the BUYCart with the given BUYProductVariant object on it.
...@@ -74,6 +75,8 @@ ...@@ -74,6 +75,8 @@
* @param variant The BUYProductVariant to add to the BUYCart with a quantity * @param variant The BUYProductVariant to add to the BUYCart with a quantity
* @param quantity The quantity for the BUYCartLineItem associated with the BUYProductVariant * @param quantity The quantity for the BUYCartLineItem associated with the BUYProductVariant
*/ */
- (void)setVariant:(nonnull BUYProductVariant *)variant withTotalQuantity:(NSInteger)quantity; - (void)setVariant:(BUYProductVariant *)variant withTotalQuantity:(NSInteger)quantity;
@end @end
NS_ASSUME_NONNULL_END
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
} }
#endif #endif
- (nonnull NSArray<BUYCartLineItem *> *)lineItemsArray - (NSArray<BUYCartLineItem *> *)lineItemsArray
{ {
return self.lineItems.array; return self.lineItems.array ?: @[];
} }
- (BOOL)isValid - (BOOL)isValid
......
...@@ -24,12 +24,12 @@ ...@@ -24,12 +24,12 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYCartLineItem.h> #import "_BUYCartLineItem.h"
NS_ASSUME_NONNULL_BEGIN
/** /**
* Newly inserted `CartLineItem`s have an initial quantity of 1. * Newly inserted `CartLineItem`s have an initial quantity of 1.
*/ */
@interface BUYCartLineItem : _BUYCartLineItem {} @interface BUYCartLineItem : _BUYCartLineItem {}
/** /**
...@@ -69,3 +69,5 @@ ...@@ -69,3 +69,5 @@
- (BUYCartLineItem *)cartLineItemWithVariant:(BUYProductVariant *)variant; - (BUYCartLineItem *)cartLineItemWithVariant:(BUYProductVariant *)variant;
@end @end
NS_ASSUME_NONNULL_END
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
#import <Buy/_BUYCollection.h> #import <Buy/_BUYCollection.h>
#import <Buy/BUYClient+Storefront.h> #import <Buy/BUYClient+Storefront.h>
NS_ASSUME_NONNULL_BEGIN
@interface BUYCollection : _BUYCollection {} @interface BUYCollection : _BUYCollection {}
@property (nonatomic, readonly) NSString *stringDescription; @property (nonatomic, nullable, readonly) NSString *stringDescription;
- (NSArray<BUYProduct *> *)productsArray; - (NSArray<BUYProduct *> *)productsArray;
...@@ -43,3 +44,5 @@ ...@@ -43,3 +44,5 @@
+ (NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort; + (NSString *)sortOrderParameterForCollectionSort:(BUYCollectionSort)sort;
@end @end
NS_ASSUME_NONNULL_END
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
- (NSArray<BUYProduct *> *)productsArray - (NSArray<BUYProduct *> *)productsArray
{ {
return self.products.array; return self.products.array ?: @[];
} }
- (void)updateStringDescription - (void)updateStringDescription
......
...@@ -24,11 +24,12 @@ ...@@ -24,11 +24,12 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYCustomer.h> #import "_BUYCustomer.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYCustomer : _BUYCustomer {} @interface BUYCustomer : _BUYCustomer {}
@property (readonly) NSString *fullName; @property (nonatomic, strong, readonly) NSString *fullName;
@end @end
...@@ -37,3 +38,5 @@ ...@@ -37,3 +38,5 @@
- (BUYCustomer *)customerWithJSONDictionary:(NSDictionary *)json; - (BUYCustomer *)customerWithJSONDictionary:(NSDictionary *)json;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,9 +24,9 @@ ...@@ -24,9 +24,9 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYImageLink.h>
@import UIKit; @import UIKit;
#import "_BUYImageLink.h"
NS_ASSUME_NONNULL_BEGIN
// Defines for common maximum image sizes // Defines for common maximum image sizes
typedef NS_ENUM(NSUInteger, BUYImageURLSize) { typedef NS_ENUM(NSUInteger, BUYImageURLSize) {
...@@ -83,3 +83,5 @@ typedef NS_ENUM(NSUInteger, BUYImageURLSize) { ...@@ -83,3 +83,5 @@ typedef NS_ENUM(NSUInteger, BUYImageURLSize) {
- (BUYImageURLSize)buy_imageSize; - (BUYImageURLSize)buy_imageSize;
@end @end
NS_ASSUME_NONNULL_END
...@@ -51,39 +51,15 @@ ...@@ -51,39 +51,15 @@
+ (NSString *)keyForImageSize:(BUYImageURLSize)size + (NSString *)keyForImageSize:(BUYImageURLSize)size
{ {
NSString *sizeKey = nil;
switch (size) { switch (size) {
case BUYImageURLSize100x100: case BUYImageURLSize100x100: return @"_small";
sizeKey = @"_small"; case BUYImageURLSize160x160: return @"_compact";
break; case BUYImageURLSize240x240: return @"_medium";
case BUYImageURLSize480x480: return @"_large";
case BUYImageURLSize160x160: case BUYImageURLSize600x600: return @"_grande";
sizeKey = @"_compact"; case BUYImageURLSize1024x1024: return @"_1024x1024";
break; case BUYImageURLSize2048x2048: return @"_2048x2048";
case BUYImageURLSize240x240:
sizeKey = @"_medium";
break;
case BUYImageURLSize480x480:
sizeKey = @"_large";
break;
case BUYImageURLSize600x600:
sizeKey = @"_grande";
break;
case BUYImageURLSize1024x1024:
sizeKey = @"_1024x1024";
break;
case BUYImageURLSize2048x2048:
sizeKey = @"_2048x2048";
break;
} }
return sizeKey;
} }
@end @end
......
...@@ -24,10 +24,13 @@ ...@@ -24,10 +24,13 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYLineItem.h> #import "_BUYLineItem.h"
#import <Buy/BUYModelManager.h> #import "BUYModelManager.h"
NS_ASSUME_NONNULL_BEGIN
@class BUYCartLineItem, BUYProductVariant; @class BUYCartLineItem;
@class BUYProductVariant;
@class BUYCartLineItem;
@interface BUYLineItem : _BUYLineItem {} @interface BUYLineItem : _BUYLineItem {}
...@@ -36,11 +39,11 @@ ...@@ -36,11 +39,11 @@
@end @end
@class BUYCartLineItem;
@interface BUYModelManager (BUYLineItemCreation) @interface BUYModelManager (BUYLineItemCreation)
- (BUYLineItem *)lineItemWithVariant:(BUYProductVariant *)variant; - (BUYLineItem *)lineItemWithVariant:(BUYProductVariant *)variant;
- (BUYLineItem *)lineItemWithCartLineItem:(BUYCartLineItem *)cartLineItem; - (BUYLineItem *)lineItemWithCartLineItem:(BUYCartLineItem *)cartLineItem;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYOption.h> #import "_BUYOption.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYOption : _BUYOption {} @interface BUYOption : _BUYOption {}
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,10 +24,13 @@ ...@@ -24,10 +24,13 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYOptionValue.h> #import "_BUYOptionValue.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYOptionValue : _BUYOptionValue {} @interface BUYOptionValue : _BUYOptionValue {}
- (BOOL)isEqualToOptionValue:(BUYOptionValue *)other; - (BOOL)isEqualToOptionValue:(nullable BUYOptionValue *)other;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYOrder.h> #import "_BUYOrder.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYOrder : _BUYOrder {} @interface BUYOrder : _BUYOrder {}
...@@ -39,3 +40,5 @@ ...@@ -39,3 +40,5 @@
@end @end
NS_ASSUME_NONNULL_END
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
- (NSArray<BUYLineItem *> *)lineItemsArray - (NSArray<BUYLineItem *> *)lineItemsArray
{ {
return self.lineItems.array; return self.lineItems.array ?: @[];
} }
- (NSArray *)formatIDsForLineItemsJSON:(NSArray<NSDictionary *> *)lineItems - (NSArray *)formatIDsForLineItemsJSON:(NSArray<NSDictionary *> *)lineItems
......
...@@ -24,13 +24,15 @@ ...@@ -24,13 +24,15 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYProduct.h> #import "_BUYProduct.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYProduct : _BUYProduct {} @interface BUYProduct : _BUYProduct {}
@property (nonatomic, readonly, copy) NSDate *createdAtDate; @property (nonatomic, readonly, copy) NSDate *createdAtDate;
@property (nonatomic, readonly, copy) NSDate *updatedAtDate; @property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly, copy) NSDate *publishedAtDate; @property (nonatomic, readonly, copy) NSDate *publishedAtDate;
@property (nonatomic, readonly, copy) NSString *stringDescription; @property (nonatomic, readonly, copy) NSString *stringDescription;
/** /**
...@@ -70,7 +72,7 @@ ...@@ -70,7 +72,7 @@
* *
* @return the product variant matching the set of options * @return the product variant matching the set of options
*/ */
- (BUYProductVariant *)variantWithOptions:(NSArray *)options; - (nullable BUYProductVariant *)variantWithOptions:(NSArray *)options;
/** /**
* Determine if the variant is a default variant automatically created by Shopify * Determine if the variant is a default variant automatically created by Shopify
...@@ -80,3 +82,5 @@ ...@@ -80,3 +82,5 @@
- (BOOL)isDefaultVariant; - (BOOL)isDefaultVariant;
@end @end
NS_ASSUME_NONNULL_END
...@@ -60,17 +60,17 @@ ...@@ -60,17 +60,17 @@
- (NSArray<BUYImageLink *> *)imagesArray - (NSArray<BUYImageLink *> *)imagesArray
{ {
return self.images.array; return self.images.array ?: @[];
} }
- (NSArray<BUYOption *> *)optionsArray - (NSArray<BUYOption *> *)optionsArray
{ {
return self.options.array; return self.options.array ?: @[];
} }
- (NSArray<BUYProductVariant *> *)variantsArray - (NSArray<BUYProductVariant *> *)variantsArray
{ {
return self.variants.array; return self.variants.array ?: @[];
} }
@end @end
......
...@@ -24,7 +24,8 @@ ...@@ -24,7 +24,8 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYProductVariant.h> #import "_BUYProductVariant.h"
NS_ASSUME_NONNULL_BEGIN
@class BUYOptionValue; @class BUYOptionValue;
...@@ -37,7 +38,7 @@ ...@@ -37,7 +38,7 @@
* *
* @return the option value * @return the option value
*/ */
- (BUYOptionValue *)optionValueForName:(NSString *)optionName; - (nullable BUYOptionValue *)optionValueForName:(NSString *)optionName;
/** /**
* Filters array of product variants filtered based on a selected option value * Filters array of product variants filtered based on a selected option value
...@@ -50,3 +51,5 @@ ...@@ -50,3 +51,5 @@
+ (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue; + (NSArray *)filterProductVariants:(NSArray *)productVariants forOptionValue:(BUYOptionValue *)optionValue;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYShop.h> #import "_BUYShop.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYShop : _BUYShop {} @interface BUYShop : _BUYShop {}
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,15 +24,15 @@ ...@@ -24,15 +24,15 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYCheckout.h> #import "_BUYCheckout.h"
#import <Buy/_BUYProductVariant.h> #import "_BUYProductVariant.h"
#import <Buy/BUYModelManager.h> #import "BUYModelManager.h"
NS_ASSUME_NONNULL_BEGIN
@class BUYCart, BUYCartLineItem, BUYAddress, BUYGiftCard; @class BUYCart, BUYCartLineItem, BUYAddress, BUYGiftCard;
@interface BUYCheckout : _BUYCheckout {} @interface BUYCheckout : _BUYCheckout {}
@property (nonatomic, copy) NSNumber *taxesIncluded;
@property (nonatomic, readonly, copy) NSDate *createdAtDate; @property (nonatomic, readonly, copy) NSDate *createdAtDate;
@property (nonatomic, readonly, copy) NSDate *updatedAtDate; @property (nonatomic, readonly, copy) NSDate *updatedAtDate;
@property (nonatomic, readonly, copy) NSDictionary *attributesDictionary; @property (nonatomic, readonly, copy) NSDictionary *attributesDictionary;
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
- (void)updateWithCart:(BUYCart *)cart; - (void)updateWithCart:(BUYCart *)cart;
- (BUYGiftCard *)giftCardWithIdentifier:(NSNumber *)identifier; - (nullable BUYGiftCard *)giftCardWithIdentifier:(NSNumber *)identifier;
- (void)addGiftCard:(BUYGiftCard *)giftCard; - (void)addGiftCard:(BUYGiftCard *)giftCard;
- (void)removeGiftCardWithIdentifier:(NSNumber *)identifier; - (void)removeGiftCardWithIdentifier:(NSNumber *)identifier;
...@@ -61,3 +61,5 @@ ...@@ -61,3 +61,5 @@
- (BUYCheckout *)checkoutwithCartToken:(NSString *)token; - (BUYCheckout *)checkoutwithCartToken:(NSString *)token;
@end @end
NS_ASSUME_NONNULL_END
...@@ -118,12 +118,12 @@ ...@@ -118,12 +118,12 @@
- (NSArray<BUYGiftCard *> *)giftCardsArray - (NSArray<BUYGiftCard *> *)giftCardsArray
{ {
return self.giftCards.array; return self.giftCards.array ?: @[];
} }
- (NSArray<BUYCartLineItem *> *)lineItemsArray - (NSArray<BUYCartLineItem *> *)lineItemsArray
{ {
return self.lineItems.array; return self.lineItems.array ?: @[];
} }
#pragma mark - Update - #pragma mark - Update -
......
...@@ -24,10 +24,14 @@ ...@@ -24,10 +24,14 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYCheckoutAttribute.h> #import "_BUYCheckoutAttribute.h"
NS_ASSUME_NONNULL_BEGIN
/** /**
* A BUYCheckoutAttribute represents a checkout attributes key and value * A BUYCheckoutAttribute represents a checkout attributes key and value
*/ */
@interface BUYCheckoutAttribute : _BUYCheckoutAttribute @interface BUYCheckoutAttribute : _BUYCheckoutAttribute
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,12 +24,17 @@ ...@@ -24,12 +24,17 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYDiscount.h> #import "_BUYDiscount.h"
#import <Buy/BUYModelManager.h> #import "BUYModelManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYDiscount : _BUYDiscount {} @interface BUYDiscount : _BUYDiscount {}
@end @end
@interface BUYModelManager (BUYDiscountCreating) @interface BUYModelManager (BUYDiscountCreating)
- (BUYDiscount *)discountWithCode:(NSString *)code;
- (BUYDiscount *)discountWithCode:(nullable NSString *)code;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,9 @@ ...@@ -24,8 +24,9 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYGiftCard.h> #import "_BUYGiftCard.h"
#import <Buy/BUYModelManager.h> #import "BUYModelManager.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYGiftCard : _BUYGiftCard {} @interface BUYGiftCard : _BUYGiftCard {}
...@@ -36,3 +37,5 @@ ...@@ -36,3 +37,5 @@
- (BUYGiftCard *)giftCardWithCode:(NSString *)code; - (BUYGiftCard *)giftCardWithCode:(NSString *)code;
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYMaskedCreditCard.h> #import "_BUYMaskedCreditCard.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYMaskedCreditCard : _BUYMaskedCreditCard {} @interface BUYMaskedCreditCard : _BUYMaskedCreditCard {}
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYShippingRate.h> #import "_BUYShippingRate.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYShippingRate : _BUYShippingRate {} @interface BUYShippingRate : _BUYShippingRate {}
@end @end
NS_ASSUME_NONNULL_END
...@@ -24,8 +24,11 @@ ...@@ -24,8 +24,11 @@
// THE SOFTWARE. // THE SOFTWARE.
// //
#import <Buy/_BUYTaxLine.h> #import "_BUYTaxLine.h"
NS_ASSUME_NONNULL_BEGIN
@interface BUYTaxLine : _BUYTaxLine {} @interface BUYTaxLine : _BUYTaxLine {}
@end @end
NS_ASSUME_NONNULL_END
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