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
c4ffccce
Commit
c4ffccce
authored
Jun 08, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert BUYStatusOperation to return a BUYStatus.
parent
fe599067
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
13 deletions
+19
-13
BUYClient+Checkout.m
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
+3
-1
BUYCheckoutOperation.h
... Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.h
+2
-0
BUYStatusOperation.h
...le Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.h
+4
-4
BUYStatusOperation.m
...le Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.m
+10
-8
No files found.
Mobile Buy SDK/Mobile Buy SDK/Data/BUYClient+Checkout.m
View file @
c4ffccce
...
...
@@ -155,7 +155,9 @@
-
(
NSOperation
*
)
pollCompletionStatusAndGetCheckoutWithToken
:(
NSString
*
)
token
start
:(
BOOL
)
start
completion
:(
BUYDataCheckoutBlock
)
block
{
BUYStatusOperation
*
operation
=
[
BUYStatusOperation
operationWithClient
:
self
checkoutToken
:
token
completion
:
block
];
BUYStatusOperation
*
operation
=
[
BUYStatusOperation
operationWithClient
:
self
checkoutToken
:
token
completion
:^
(
BUYStatus
status
,
BUYCheckout
*
checkout
,
NSError
*
error
)
{
block
(
checkout
,
error
);
}];
if
(
start
)
{
[
self
startOperation
:
operation
];
}
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYCheckoutOperation.h
View file @
c4ffccce
...
...
@@ -33,6 +33,8 @@ NS_ASSUME_NONNULL_BEGIN
@protocol
BUYPaymentToken
;
typedef
void
(
^
BUYCheckoutOperationCompletion
)(
BUYCheckout
*
_Nullable
checkout
,
NSError
*
_Nullable
error
);
@interface
BUYCheckoutOperation
:
BUYGroupOperation
+
(
instancetype
)
operationWithClient
:(
BUYClient
*
)
client
checkoutToken
:(
NSString
*
)
checkoutToken
token
:(
id
<
BUYPaymentToken
>
)
token
completion
:(
BUYCheckoutOperationCompletion
)
completion
;
...
...
Mobile Buy SDK/Mobile Buy SDK/Operations/BUYStatusOperation.h
View file @
c4ffccce
...
...
@@ -25,17 +25,17 @@
//
#import "BUYGroupOperation.h"
#import "BUYClient.h"
NS_ASSUME_NONNULL_BEGIN
@class
BUYCheckout
;
@class
BUYClient
;
typedef
void
(
^
BUYCheckout
OperationCompletion
)(
BUYCheckout
*
_Nullable
checkout
,
NSError
*
_Nullable
error
);
typedef
void
(
^
BUYCheckout
StatusOperationCompletion
)(
BUYStatus
status
,
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 @
c4ffccce
...
...
@@ -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
}
}];
}
...
...
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