Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
97372d4d
Commit
97372d4d
authored
8 years ago
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch from NSAssert to BUYAssert
parent
ff54d47c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
23 deletions
+28
-23
NSEntityDescription+BUYAdditions.m
...bile Buy SDK/Additions/NSEntityDescription+BUYAdditions.m
+3
-2
NSString+BUYAdditions.m
... Buy SDK/Mobile Buy SDK/Additions/NSString+BUYAdditions.m
+2
-1
BUYClient.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
+17
-17
BUYAccountCredentials.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.m
+2
-1
BUYApplePayToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePayToken.m
+2
-1
BUYCreditCardToken.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCardToken.m
+2
-1
No files found.
Mobile Buy SDK/Mobile Buy SDK/Additions/NSEntityDescription+BUYAdditions.m
View file @
97372d4d
...
...
@@ -24,6 +24,7 @@
// THE SOFTWARE.
//
#import "BUYAssert.h"
#import "NSEntityDescription+BUYAdditions.h"
#import "BUYModelManagerProtocol.h"
...
...
@@ -127,7 +128,7 @@
-
(
NSDictionary
*
)
buy_JSONForObject
:
(
NSObject
<
BUYObject
>
*
)
object
{
NS
Assert
([
self
isEqual
:[
object
entity
]],
@"%@ entity cannot decode %@ objects"
,
self
.
name
,
[
object
entity
].
name
);
BUY
Assert
([
self
isEqual
:[
object
entity
]],
@"%@ entity cannot decode %@ objects"
,
self
.
name
,
[
object
entity
].
name
);
// The encoding map is a block which converts property names into JSON keys.
BUYStringMap
encodingMap
=
self
.
JSONKeyEncodingMap
;
...
...
@@ -158,7 +159,7 @@
-
(
void
)
buy_updateObject
:
(
NSObject
<
BUYObject
>
*
)
object
withJSON
:
(
NSDictionary
*
)
JSON
{
NS
Assert
([
self
isEqual
:[
object
entity
]],
@"%@ entity cannot decode %@ objects"
,
self
.
name
,
[
object
entity
].
name
);
BUY
Assert
([
self
isEqual
:[
object
entity
]],
@"%@ entity cannot decode %@ objects"
,
self
.
name
,
[
object
entity
].
name
);
NSDictionary
*
properties
=
self
.
propertiesByName
;
// The decoding map is a block which converts the key in the JSON into a property name.
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Additions/NSString+BUYAdditions.m
View file @
97372d4d
...
...
@@ -24,6 +24,7 @@
// THE SOFTWARE.
//
#import "BUYAssert.h"
#import "NSString+BUYAdditions.h"
#import "NSArray+BUYAdditions.h"
#import "NSRegularExpression+BUYAdditions.h"
...
...
@@ -140,7 +141,7 @@ static NSSet *acronyms;
-
(
NSString
*
)
buy_reversedString
{
NS
Assert
([
self
canBeConvertedToEncoding
:
NSUTF8StringEncoding
],
@"Unable to reverse string; requires a string that can be encoded in UTF8"
);
BUY
Assert
([
self
canBeConvertedToEncoding
:
NSUTF8StringEncoding
],
@"Unable to reverse string; requires a string that can be encoded in UTF8"
);
const
char
*
str
=
[
self
UTF8String
];
unsigned
long
len
=
strlen
(
str
);
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.m
View file @
97372d4d
...
...
@@ -81,15 +81,15 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
@implementation
BUYClient
-
(
instancetype
)
init
{
NS
Assert
(
NO
,
@"BUYClient must be initialized using the designated initializer."
);
BUY
Assert
(
NO
,
@"BUYClient must be initialized using the designated initializer."
);
return
nil
;
}
-
(
instancetype
)
initWithShopDomain
:
(
NSString
*
)
shopDomain
apiKey
:
(
NSString
*
)
apiKey
appId
:
(
NSString
*
)
appId
{
NS
Assert
(
shopDomain
.
length
>
0
,
@"Bad shop domain. Please ensure you initialize with a shop domain."
);
NS
Assert
(
apiKey
.
length
>
0
,
@"Bad API key. Please ensure you initialize with a valid API key."
);
NS
Assert
(
appId
.
length
>
0
,
@"Bad app ID. Please ensure you initialize with a valid App ID."
);
BUY
Assert
(
shopDomain
.
length
>
0
,
@"Bad shop domain. Please ensure you initialize with a shop domain."
);
BUY
Assert
(
apiKey
.
length
>
0
,
@"Bad API key. Please ensure you initialize with a valid API key."
);
BUY
Assert
(
appId
.
length
>
0
,
@"Bad app ID. Please ensure you initialize with a valid App ID."
);
self
=
[
super
init
];
if
(
self
)
{
...
...
@@ -161,7 +161,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getProductById
:
(
NSString
*
)
productId
completion
:
(
BUYDataProductBlock
)
block
;
{
NS
Assert
(
productId
,
@"Failed to get product by ID. Product ID must not be nil."
);
BUY
Assert
(
productId
,
@"Failed to get product by ID. Product ID must not be nil."
);
return
[
self
getProductsByIds
:@[
productId
]
completion
:
^
(
NSArray
*
products
,
NSError
*
error
)
{
if
(
products
.
count
>
0
)
{
...
...
@@ -177,7 +177,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getProductsByIds
:
(
NSArray
*
)
productIds
completion
:
(
BUYDataProductsBlock
)
block
{
NS
Assert
(
productIds
,
@"Failed to get product by IDs. Product IDs array must not be nil."
);
BUY
Assert
(
productIds
,
@"Failed to get product by IDs. Product IDs array must not be nil."
);
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathProductPublications
queryItems
:@{
...
...
@@ -228,7 +228,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
getProductsPage
:
(
NSUInteger
)
page
inCollection
:
(
NSNumber
*
)
collectionId
sortOrder
:
(
BUYCollectionSort
)
sortOrder
completion
:
(
BUYDataProductListBlock
)
block
{
NS
Assert
(
collectionId
,
@"Failed to get products page. Invalid collectionID."
);
BUY
Assert
(
collectionId
,
@"Failed to get products page. Invalid collectionID."
);
NSURLComponents
*
components
=
[
self
URLComponentsForChannelsAppendingPath
:
kBUYClientPathProductPublications
queryItems
:@{
...
...
@@ -325,7 +325,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
createCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
{
NS
Assert
(
checkout
,
@"Failed to create checkout. Invalid checkout object."
);
BUY
Assert
(
checkout
,
@"Failed to create checkout. Invalid checkout object."
);
// Inject channel and marketing attributions
[
self
configureCheckout
:
checkout
];
...
...
@@ -336,7 +336,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
createCheckoutWithCartToken
:
(
NSString
*
)
cartToken
completion
:
(
BUYDataCheckoutBlock
)
block
{
NS
Assert
(
cartToken
,
@"Failed to create checkout. Invalid cart token"
);
BUY
Assert
(
cartToken
,
@"Failed to create checkout. Invalid cart token"
);
BUYCheckout
*
checkout
=
[
self
.
modelManager
checkoutwithCartToken
:
cartToken
];
[
self
configureCheckout
:
checkout
];
...
...
@@ -357,7 +357,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
applyGiftCardWithCode
:
(
NSString
*
)
giftCardCode
toCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
{
BUYAssertCheckout
(
checkout
);
NS
Assert
(
giftCardCode
.
length
>
0
,
@"Failed to apply gift card code. Invalid gift card code."
);
BUY
Assert
(
giftCardCode
.
length
>
0
,
@"Failed to apply gift card code. Invalid gift card code."
);
BUYGiftCard
*
giftCard
=
[
self
.
modelManager
giftCardWithCode
:
giftCardCode
];
NSURLComponents
*
components
=
[
self
URLComponentsForCheckoutsAppendingPath
:
@"gift_cards"
...
...
@@ -375,7 +375,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
removeGiftCard
:
(
BUYGiftCard
*
)
giftCard
fromCheckout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCheckoutBlock
)
block
{
BUYAssertCheckout
(
checkout
);
NS
Assert
(
giftCard
.
identifier
,
@"Failed to remove gift card. Gift card must have a valid identifier."
);
BUY
Assert
(
giftCard
.
identifier
,
@"Failed to remove gift card. Gift card must have a valid identifier."
);
NSURLComponents
*
components
=
[
self
URLComponentsForCheckoutsAppendingPath
:[
NSString
stringWithFormat
:
@"gift_cards/%@"
,
giftCard
.
identifier
]
checkoutToken
:
checkout
.
token
...
...
@@ -442,7 +442,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
BOOL
isFree
=
(
checkout
.
paymentDue
&&
checkout
.
paymentDue
.
floatValue
==
0
);
NS
Assert
(
data
||
isFree
,
@"Failed to complete checkout. Checkout must have a payment token or have a payment value equal to $0.00"
);
BUY
Assert
(
data
||
isFree
,
@"Failed to complete checkout. Checkout must have a payment token or have a payment value equal to $0.00"
);
return
[
self
checkoutCompletionRequestWithCheckout
:
checkout
body
:
data
completion
:
block
];
}
...
...
@@ -476,7 +476,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
}
}
NS
Assert
(
token
,
@"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it."
);
BUY
Assert
(
token
,
@"Failed to get completion status of checkout. Checkout URL must have a valid token associated with it."
);
return
[
self
getCompletionStatusOfCheckoutToken
:
token
completion
:
block
];
}
...
...
@@ -514,7 +514,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
storeCreditCard
:
(
BUYCreditCard
*
)
creditCard
checkout
:
(
BUYCheckout
*
)
checkout
completion
:
(
BUYDataCreditCardBlock
)
completion
{
BUYAssertCheckout
(
checkout
);
NS
Assert
(
creditCard
,
@"Failed to store credit card. No credit card provided."
);
BUY
Assert
(
creditCard
,
@"Failed to store credit card. No credit card provided."
);
NSMutableDictionary
*
json
=
[[
NSMutableDictionary
alloc
]
init
];
json
[
@"token"
]
=
checkout
.
token
;
...
...
@@ -525,7 +525,7 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:@{
@"checkout"
:
json
}
options
:
0
error
:
nil
];
NS
Assert
(
data
,
@"Failed to store credit card. Unable to serialize JSON payload. Possibly invalid credit card object."
);
BUY
Assert
(
data
,
@"Failed to store credit card. Unable to serialize JSON payload. Possibly invalid credit card object."
);
return
[
self
postPaymentRequestWithCheckout
:
checkout
body
:
data
completion
:
completion
];
}
...
...
@@ -568,10 +568,10 @@ NSString *const BUYClientCustomerAccessToken = @"X-Shopify-Customer-Access-Token
-
(
NSURLSessionDataTask
*
)
requestForURL
:
(
NSURL
*
)
url
method
:
(
NSString
*
)
method
object
:
(
id
<
BUYSerializable
>
)
object
completionHandler
:
(
void
(
^
)(
NSDictionary
*
json
,
NSURLResponse
*
response
,
NSError
*
error
))
completionHandler
{
NS
Assert
(
object
,
@"Failed to perform request. id<BUYSerializable> must not be nil."
);
BUY
Assert
(
object
,
@"Failed to perform request. id<BUYSerializable> must not be nil."
);
NSData
*
data
=
[
NSJSONSerialization
dataWithJSONObject
:[
object
jsonDictionaryForCheckout
]
options
:
0
error
:
nil
];
NS
Assert
(
data
,
@"Failed to perform request. Could not serialize object. Possibly invalid object."
);
BUY
Assert
(
data
,
@"Failed to perform request. Could not serialize object. Possibly invalid object."
);
return
[
self
requestForURL
:
url
method
:
method
body
:
data
completionHandler
:
completionHandler
];
}
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.m
View file @
97372d4d
...
...
@@ -25,6 +25,7 @@
//
#import "BUYAccountCredentials.h"
#import "BUYAssert.h"
static
NSString
*
const
BUYAccountFirstNameKey
=
@"first_name"
;
static
NSString
*
const
BUYAccountLastNameKey
=
@"last_name"
;
...
...
@@ -142,7 +143,7 @@ static NSString * const BUYAccountPasswordConfirmationKey = @"password_confirmat
{
self
=
[
super
init
];
if
(
self
)
{
NS
Assert
(
value
,
@"Cannot initialize BUYAccountCredentialItem with nil value."
);
BUY
Assert
(
value
,
@"Cannot initialize BUYAccountCredentialItem with nil value."
);
_key
=
key
;
_value
=
value
;
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Models/BUYApplePayToken.m
View file @
97372d4d
...
...
@@ -28,6 +28,7 @@
#import <PassKit/PassKit.h>
#endif
#import "BUYAssert.h"
#import "BUYApplePayToken.h"
@implementation
BUYApplePayToken
...
...
@@ -38,7 +39,7 @@
{
self
=
[
super
init
];
if
(
self
)
{
NS
Assert
(
paymentToken
.
paymentData
.
length
>
0
,
@"Failed to initialize BUYApplePayToken. Invalid or nil paymentToken."
);
BUY
Assert
(
paymentToken
.
paymentData
.
length
>
0
,
@"Failed to initialize BUYApplePayToken. Invalid or nil paymentToken."
);
_paymentToken
=
paymentToken
;
}
return
self
;
...
...
This diff is collapsed.
Click to expand it.
Mobile Buy SDK/Mobile Buy SDK/Models/BUYCreditCardToken.m
View file @
97372d4d
...
...
@@ -24,6 +24,7 @@
// THE SOFTWARE.
//
#import "BUYAssert.h"
#import "BUYCreditCardToken.h"
@implementation
BUYCreditCardToken
...
...
@@ -34,7 +35,7 @@
{
self
=
[
super
init
];
if
(
self
)
{
NS
Assert
(
paymentSessionID
.
length
>
0
,
@"Failed to initialize BUYCreditCardToken. Invalid or nil payment session ID."
);
BUY
Assert
(
paymentSessionID
.
length
>
0
,
@"Failed to initialize BUYCreditCardToken. Invalid or nil payment session ID."
);
_paymentSessionID
=
paymentSessionID
;
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment