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
bf4af174
Commit
bf4af174
authored
Jun 08, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #227 from Shopify/task/status
Improve support in private methods
parents
fe599067
41a4a11d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
108 additions
and
55 deletions
+108
-55
project.pbxproj
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
+4
-0
Buy.h
Mobile Buy SDK/Mobile Buy SDK/Buy.h
+1
-0
BUYClient+Checkout.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
+1
-1
BUYClient+Internal.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Internal.h
+1
-1
BUYClient.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
+1
-39
BUYClientTypes.h
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClientTypes.h
+83
-0
BUYCheckoutOperation.h
... Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.h
+1
-0
BUYCheckoutOperation.m
... Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
+1
-1
BUYStatusOperation.h
...le Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.h
+4
-5
BUYStatusOperation.m
...le Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.m
+10
-8
Buy.h
Mobile Buy SDK/Mobile Buy SDK/Static Framework/Buy.h
+1
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK.xcodeproj/project.pbxproj
View file @
bf4af174
...
...
@@ -250,6 +250,7 @@
9A6C1D421D07485F00BFF4F9
/* BUYStatusOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6C1D401D07485F00BFF4F9
/* BUYStatusOperation.m */
;
};
9A6C1D451D0749FC00BFF4F9
/* BUYGroupOperation.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6C1D431D0749FC00BFF4F9
/* BUYGroupOperation.h */
;
};
9A6C1D461D0749FC00BFF4F9
/* BUYGroupOperation.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6C1D441D0749FC00BFF4F9
/* BUYGroupOperation.m */
;
};
9A6C1DC41D089E4700BFF4F9
/* BUYClientTypes.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A6C1DC31D089E4700BFF4F9
/* BUYClientTypes.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A7652C31CF487BD00220E4B
/* BUYOperationTests.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A7652C21CF487BD00220E4B
/* BUYOperationTests.m */
;
};
9A807E841CF74EBE00023160
/* BUYClient+Address.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A807E811CF74EBE00023160
/* BUYClient+Address.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
9A807E861CF74EBE00023160
/* BUYClient+Address.m in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9A807E821CF74EBE00023160
/* BUYClient+Address.m */
;
};
...
...
@@ -496,6 +497,7 @@
9A6C1D401D07485F00BFF4F9
/* BUYStatusOperation.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYStatusOperation.m
;
sourceTree
=
"<group>"
;
};
9A6C1D431D0749FC00BFF4F9
/* BUYGroupOperation.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYGroupOperation.h
;
sourceTree
=
"<group>"
;
};
9A6C1D441D0749FC00BFF4F9
/* BUYGroupOperation.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYGroupOperation.m
;
sourceTree
=
"<group>"
;
};
9A6C1DC31D089E4700BFF4F9
/* BUYClientTypes.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
BUYClientTypes.h
;
sourceTree
=
"<group>"
;
};
9A7652C21CF487BD00220E4B
/* BUYOperationTests.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
BUYOperationTests.m
;
sourceTree
=
"<group>"
;
};
9A807E811CF74EBE00023160
/* BUYClient+Address.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
"BUYClient+Address.h"
;
sourceTree
=
"<group>"
;
};
9A807E821CF74EBE00023160
/* BUYClient+Address.m */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.objc
;
path
=
"BUYClient+Address.m"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -1038,6 +1040,7 @@
isa
=
PBXGroup
;
children
=
(
8498DCB01CDD1B4A00BD12A8
/* BUYClient+Internal.h */
,
9A6C1DC31D089E4700BFF4F9
/* BUYClientTypes.h */
,
F7FDA17019C93F6F00AF4E93
/* BUYClient.h */
,
F7FDA17119C93F6F00AF4E93
/* BUYClient.m */
,
9A0B0C641CEA703E0037D68F
/* BUYClient+Routing.h */
,
...
...
@@ -1147,6 +1150,7 @@
9A585C0B1CE6440B001F20F0
/* BUYOperation.h in Headers */
,
9A0B0C791CEB5BBD0037D68F
/* BUYAuthenticatedResponse.h in Headers */
,
849810971CB7E07900CFAB58
/* BUYFlatCollectionTransformer.h in Headers */
,
9A6C1DC41D089E4700BFF4F9
/* BUYClientTypes.h in Headers */
,
901931641BC5B9BC00D1134E
/* BUYCartLineItem.h in Headers */
,
8498DCAE1CDD1B2F00BD12A8
/* BUYError+BUYAdditions.h in Headers */
,
901931661BC5B9BC00D1134E
/* BUYCheckout.h in Headers */
,
...
...
Mobile Buy SDK/Mobile Buy SDK/Buy.h
View file @
bf4af174
...
...
@@ -62,6 +62,7 @@ FOUNDATION_EXPORT const unsigned char BuyVersionString[];
#import <Buy/BUYPaymentProvider.h>
#import <Buy/BUYWebCheckoutPaymentProvider.h>
#import <Buy/BUYClientTypes.h>
#import <Buy/BUYClient.h>
#import <Buy/BUYClient+Address.h>
#import <Buy/BUYClient+Customers.h>
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
View file @
bf4af174
...
...
@@ -153,7 +153,7 @@
}];
}
-
(
NSOperation
*
)
pollCompletionStatusAndGetCheckoutWithToken
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUY
DataCheckoutBlock
)
block
-
(
NSOperation
*
)
pollCompletionStatusAndGetCheckoutWithToken
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUY
CheckoutStatusOperationCompletion
)
block
{
BUYStatusOperation
*
operation
=
[
BUYStatusOperation
operationWithClient
:
self
checkoutToken
:
token
completion
:
block
];
if
(
start
)
{
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Internal.h
View file @
bf4af174
...
...
@@ -37,7 +37,7 @@ typedef void (^BUYClientRequestJSONCompletion)(NSDictionary *json, NSHTTPURLResp
@property
(
nonatomic
,
strong
)
NSOperationQueue
*
requestQueue
;
-
(
NSOperation
*
)
pollCompletionStatusAndGetCheckoutWithToken
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUY
DataCheckoutBlock
)
block
;
-
(
NSOperation
*
)
pollCompletionStatusAndGetCheckoutWithToken
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUY
CheckoutStatusOperationCompletion
)
block
;
-
(
NSOperation
*
)
getRequestForURL
:(
NSURL
*
)
url
completionHandler
:(
BUYClientRequestJSONCompletion
)
completionHandler
;
-
(
NSOperation
*
)
deleteRequestForURL
:(
NSURL
*
)
url
completionHandler
:(
BUYClientRequestJSONCompletion
)
completionHandler
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient.h
View file @
bf4af174
...
...
@@ -25,51 +25,13 @@
//
@import
Foundation
;
#import "BUYClientTypes.h"
@class
BUYModelManager
;
@class
BUYOperation
;
@class
BUYRequestOperation
;
/**
* A BUYStatus is associated with the completion of an enqueued job on Shopify.
* BUYStatus is equal is HTTP status codes returned from the server
*/
typedef
NS_ENUM
(
NSUInteger
,
BUYStatus
)
{
/**
* The job is complete
*/
BUYStatusComplete
=
200
,
/**
* The job is still processing
*/
BUYStatusProcessing
=
202
,
/**
* The job is not found, please check the identifier
*/
BUYStatusNotFound
=
404
,
/**
* The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
*/
BUYStatusPreconditionFailed
=
412
,
/**
* The request failed, refer to an NSError for details
*/
BUYStatusFailed
=
424
,
/**
* The status is unknown
*/
BUYStatusUnknown
};
/**
* Return block containing a BUYCheckout, a BUYStatus and/or an NSError
*
* @param status A BUYStatus specifying the requested job's completion status
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataStatusBlock
)(
BUYStatus
status
,
NSError
*
_Nullable
error
);
/**
The BUYDataClient provides all requests needed to perform request on the Shopify Checkout API.
Use this class to perform tasks such as getting a shop, products for a shop, creating a Checkout on Shopify
and completing Checkouts.
...
...
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClientTypes.h
0 → 100644
View file @
bf4af174
//
// BUYClientTypes.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2015 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
@
class
BUYCheckout
;
/**
* A BUYStatus is associated with the completion of an enqueued job on Shopify.
* BUYStatus is equal is HTTP status codes returned from the server
*/
typedef
NS_ENUM
(
NSUInteger
,
BUYStatus
)
{
/**
* The job is complete
*/
BUYStatusComplete
=
200
,
/**
* The job is still processing
*/
BUYStatusProcessing
=
202
,
/**
* The job is not found, please check the identifier
*/
BUYStatusNotFound
=
404
,
/**
* The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
*/
BUYStatusPreconditionFailed
=
412
,
/**
* The request failed, refer to an NSError for details
*/
BUYStatusFailed
=
424
,
/**
* The status is unknown
*/
BUYStatusUnknown
};
/**
* Return block containing a BUYStatus and/or an NSError
*
* @param status A BUYStatus specifying the requested job's completion status
* @param error Optional NSError
*/
typedef
void
(
^
BUYDataStatusBlock
)(
BUYStatus
status
,
NSError
*
_Nullable
error
);
/**
* Return block containing a BUYCheckout and an NSError
*
* @param checkout A BUYCheckout object
* @param error Optional NSError
*/
typedef
void
(
^
BUYCheckoutOperationCompletion
)(
BUYCheckout
*
_Nullable
checkout
,
NSError
*
_Nullable
error
);
/**
* Return block containing a BUYStatus, a BUYCheckout and/or an NSError
*
* @param status A BUYStatus specifying the requested job's completion status
* @param checkout A BUYCheckout object
* @param error Optional NSError
*/
typedef
void
(
^
BUYCheckoutStatusOperationCompletion
)(
BUYStatus
status
,
BUYCheckout
*
_Nullable
checkout
,
NSError
*
_Nullable
error
);
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.h
View file @
bf4af174
...
...
@@ -26,6 +26,7 @@
#import <Buy/BUYGroupOperation.h>
#import <Buy/BUYStatusOperation.h>
#import <Buy/BUYClientTypes.h>
NS_ASSUME_NONNULL_BEGIN
@class
BUYClient
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.m
View file @
bf4af174
...
...
@@ -112,7 +112,7 @@
-
(
NSOperation
*
)
createStatusOperation
{
return
[
self
.
client
pollCompletionStatusAndGetCheckoutWithToken
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUYCheckout
*
checkout
,
NSError
*
error
)
{
return
[
self
.
client
pollCompletionStatusAndGetCheckoutWithToken
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUY
Status
status
,
BUY
Checkout
*
checkout
,
NSError
*
error
)
{
if
(
checkout
)
{
[
self
finishWithObject
:
checkout
];
}
else
{
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.h
View file @
bf4af174
...
...
@@ -25,17 +25,16 @@
//
#import "BUYGroupOperation.h"
#import "BUYClient.h"
#import "BUYClientTypes.h"
NS_ASSUME_NONNULL_BEGIN
@class
BUYCheckout
;
@class
BUYClient
;
typedef
void
(
^
BUYCheckoutOperationCompletion
)(
BUYCheckout
*
_Nullable
checkout
,
NSError
*
_Nullable
error
);
@interface
BUYStatusOperation
:
BUYGroupOperation
+
(
instancetype
)
operationWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckoutOperationCompletion
)
completion
;
-
(
instancetype
)
initWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckoutOperationCompletion
)
completion
;
+
(
instancetype
)
operationWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckout
Status
OperationCompletion
)
completion
;
-
(
instancetype
)
initWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckout
Status
OperationCompletion
)
completion
;
@end
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.m
View file @
bf4af174
...
...
@@ -33,7 +33,9 @@
@property
(
strong
,
nonatomic
,
readonly
)
BUYClient
*
client
;
@property
(
strong
,
nonatomic
,
readonly
)
NSString
*
checkoutToken
;
@property
(
strong
,
nonatomic
,
readonly
)
BUYCheckoutOperationCompletion
completion
;
@property
(
strong
,
nonatomic
,
readonly
)
BUYCheckoutStatusOperationCompletion
completion
;
-
(
void
)
finishWithError
:(
NSError
*
)
error
NS_UNAVAILABLE
;
@end
...
...
@@ -41,12 +43,12 @@
#pragma mark - Init -
+
(
instancetype
)
operationWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckoutOperationCompletion
)
completion
+
(
instancetype
)
operationWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckout
Status
OperationCompletion
)
completion
{
return
[[[
self
class
]
alloc
]
initWithClient
:
client
checkoutToken
:
checkoutToken
completion
:
completion
];
}
-
(
instancetype
)
initWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckoutOperationCompletion
)
completion
-
(
instancetype
)
initWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
completion
:(
BUYCheckout
Status
OperationCompletion
)
completion
{
self
=
[
super
initWithRequestQueue
:
client
.
requestQueue
operations
:
nil
];
if
(
self
)
{
...
...
@@ -82,17 +84,17 @@
if
(
self
.
cancelled
)
{
return
;
}
self
.
completion
(
object
,
nil
);
self
.
completion
(
BUYStatusComplete
,
object
,
nil
);
}
-
(
void
)
finishWith
E
rror
:
(
NSError
*
)
error
-
(
void
)
finishWith
Status
:
(
BUYStatus
)
status
e
rror
:
(
NSError
*
)
error
{
[
super
finishWithError
:
error
];
if
(
self
.
cancelled
)
{
return
;
}
self
.
completion
(
nil
,
error
);
self
.
completion
(
status
,
nil
,
error
);
}
#pragma mark - Operations -
...
...
@@ -101,7 +103,7 @@
{
BUYRequestOperation
*
operation
=
(
BUYRequestOperation
*
)[
self
.
client
getCompletionStatusOfCheckoutWithToken
:
self
.
checkoutToken
start
:
NO
completion
:^
(
BUYStatus
status
,
NSError
*
error
)
{
if
(
status
!=
BUYStatusComplete
)
{
[
self
finishWith
E
rror
:
error
];
[
self
finishWith
Status
:
status
e
rror
:
error
];
}
}];
operation
.
pollingHandler
=
^
BOOL
(
NSDictionary
*
json
,
NSHTTPURLResponse
*
response
,
NSError
*
error
)
{
...
...
@@ -117,7 +119,7 @@
if
(
checkout
)
{
[
self
finishWithObject
:
checkout
];
}
else
{
[
self
finishWith
Error
:
error
];
[
self
finishWith
Status
:
BUYStatusComplete
error
:
error
];
// Assumed because the polling operation has to success for us to get here
}
}];
}
...
...
Mobile Buy SDK/Mobile Buy SDK/Static Framework/Buy.h
View file @
bf4af174
...
...
@@ -58,6 +58,7 @@
#import "BUYPaymentProvider.h"
#import "BUYWebCheckoutPaymentProvider.h"
#import "BUYClientTypes.h"
#import "BUYClient.h"
#import "BUYClient+Address.h"
#import "BUYClient+Customers.h"
...
...
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