-
Notifications
You must be signed in to change notification settings - Fork 0
/
SMResponseBlocks.h
166 lines (123 loc) · 6.08 KB
/
SMResponseBlocks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*
* Copyright 2012-2013 StackMob
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@class SMRequestOptions;
@class SMGeoPoint;
@class AFHTTPRequestOperation;
/**
A success block that returns nothing.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMSuccessBlock)();
/**
The block parameters expected for a success response which returns an `NSDictionary`.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMResultSuccessBlock)(NSDictionary *result);
/**
The block parameters expected for a success response which returns an `NSArray`.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMResultsSuccessBlock)(NSArray *results);
/**
The block parameters expected for any failure response.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMFailureBlock)(NSError *error);
/**
The block parameters expected for a success response which returns an `SMGeoPoint`.
@since Available in iOS SDK 1.3.0 and later.
*/
typedef void (^SMGeoPointSuccessBlock)(SMGeoPoint *geoPoint);
/**
The block parameters expected for a success response that needs the raw request, response, and response body.
@note Parameter 'id JSON' was changed to 'id responseBody' in v2.0.0.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMFullResponseSuccessBlock)(NSURLRequest *request, NSHTTPURLResponse *response, id responseBody);
/**
The block parameters expected for a failure response that needs the raw request, response, and response body.
@note Parameter 'id JSON' was changed to 'id responseBody' in v2.0.0.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMFullResponseFailureBlock)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseBody);
/**
The block parameters expected for a success response from a call to the Datastore which returns the full object and schema.
@param theObject An updated dictionary representation of the requested object.
@param schema The schema to which the object belongs.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMDataStoreSuccessBlock)(NSDictionary* theObject, NSString *schema);
/**
The block parameters expected for a success response from a call to the Datastore which returns the object ID and schema.
@param theObjectId The object id used in this operation.
@param schema The schema to which the object belongs.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMDataStoreObjectIdSuccessBlock)(NSString* theObjectId, NSString *schema);
/**
The block parameters expected for a failure response from a call to the Datastore which returns the error, full object and schema.
@param theError An error object describing the failure.
@param theObject The dictionary representation of the object sent as part of the failed operation.
@param schema The schema to which the object belongs.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMDataStoreFailureBlock)(NSError *theError, NSDictionary* theObject, NSString *schema);
/**
The block parameters expected for a failure response from a call to the Datastore which returns the error, object ID and schema.
@param theError An error object describing the failure.
@param theObjectId The object id sent as part of the failed operation.
@param schema The schema to which the object belongs.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMDataStoreObjectIdFailureBlock)(NSError *theError, NSString* theObjectId, NSString *schema);
/**
The block parameters expected for a success response from query count call.
@param count The number of objects returned by the query.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMCountSuccessBlock)(NSNumber *count);
/**
When executing custom code requests, you can optionally define your own retry blocks in the event of a 503 `SMServiceUnavailable` response. To do this pass a `SMFailureRetryBlock` instance to <SMRequestOptions> method `addSMErrorServiceUnavailableRetryBlock:`.
@param request The original request in `NSURLRequest` form.
@param response The response from the server.
@param error The error, if any.
@param responseBody the body of the response.
@param options The SMRequestOption instance passed to the request.
@param successBlock The block to invoke on success.
@param failureBlock The block to invoke on failure.
@since Available in iOS SDK 1.0.0 and later.
*/
typedef void (^SMFailureRetryBlock)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id responseBody, SMRequestOptions *options, SMFullResponseSuccessBlock successBlock, SMFullResponseFailureBlock failureBlock);
/**
Used internally for requests that fail during a core data save.
@param theRequest The original request in `NSURLRequest` form.
@param theError The error, if any.
@param theObject The original object being saved.
@param theOptions The SMRequestOption instance passed to the request.
@param originalSuccessBlock The block passed to original request.
@since Available in iOS SDK 1.2.0 and later.
*/
typedef void (^SMCoreDataSaveFailureBlock)(NSURLRequest *theRequest, NSError *theError, NSDictionary *theObject, SMRequestOptions *theOptions, SMResultSuccessBlock originalSuccessBlock);
/**
Used interally for custom code requests.
@since Available in iOS SDK 2.0.0 and later.
*/
typedef void (^AFHTTPOperationSuccessBlock)(AFHTTPRequestOperation *operation, id responseObject);
/**
Used interally for custom code requests.
@since Available in iOS SDK 2.0.0 and later.
*/
typedef void (^AFHTTPOperationFailureBlock)(AFHTTPRequestOperation *operation, NSError *error);