|
18 | 18 |
|
19 | 19 | #pragma mark - definitions |
20 | 20 |
|
21 | | -extern NSString * const kHTTPMethodGET; |
22 | | -extern NSString * const kHTTPMethodPOST; |
| 21 | +/** |
| 22 | + * HTTP Request methods |
| 23 | + */ |
| 24 | +extern NSString* const kHTTPMethodGET; |
| 25 | +extern NSString* const kHTTPMethodPOST; |
| 26 | + |
| 27 | +/** |
| 28 | + * Content-type strings |
| 29 | + */ |
| 30 | +extern NSString* const kContentTypeAutomatic; |
| 31 | +extern NSString* const kContentTypeJSON; |
| 32 | +extern NSString* const kContentTypeWWWEncoded; |
23 | 33 |
|
24 | 34 | /** |
25 | 35 | * A block type to handle incoming JSONModel instance and an error. |
@@ -81,6 +91,14 @@ typedef void (^JSONObjectBlock)(NSDictionary* json, JSONModelError* err); |
81 | 91 | */ |
82 | 92 | +(void)setControlsNetworkIndicator:(BOOL)doesControlIndicator; |
83 | 93 |
|
| 94 | +/** |
| 95 | + * A method to set the default conent type of the request body |
| 96 | + * By default the content type is set to kContentTypeAutomatic |
| 97 | + * which checks the body request and decides between "application/json" |
| 98 | + * and "application/x-www-form-urlencoded" |
| 99 | + */ |
| 100 | ++(void)setRequestContentType:(NSString*)contentTypeString; |
| 101 | + |
84 | 102 | ///////////////////////////////////////////////////////////////////////////////////////////// |
85 | 103 | #pragma mark - GET synchronious JSON calls |
86 | 104 |
|
@@ -123,6 +141,15 @@ typedef void (^JSONObjectBlock)(NSDictionary* json, JSONModelError* err); |
123 | 141 | */ |
124 | 142 | +(id)postJSONFromURLWithString:(NSString*)urlString bodyString:(NSString*)bodyString error:(NSError**)err; |
125 | 143 |
|
| 144 | +/** |
| 145 | + * Makes POST request to the given URL address and fetches a JSON response. Sends the bodyString param as the POST request body. |
| 146 | + * @param urlString the URL as a string |
| 147 | + * @param bodyData the body of the POST request as an NSData object |
| 148 | + * @param err a pointer to an NSError object, to pass back an error if needed |
| 149 | + * @return JSON compliant object or nil |
| 150 | + */ |
| 151 | ++(id)postJSONFromURLWithString:(NSString*)urlString bodyData:(NSData*)bodyData error:(NSError**)err; |
| 152 | + |
126 | 153 | ///////////////////////////////////////////////////////////////////////////////////////////// |
127 | 154 | #pragma mark - GET asynchronious JSON calls |
128 | 155 |
|
@@ -165,4 +192,14 @@ typedef void (^JSONObjectBlock)(NSDictionary* json, JSONModelError* err); |
165 | 192 | */ |
166 | 193 | +(void)postJSONFromURLWithString:(NSString*)urlString bodyString:(NSString*)bodyString completion:(JSONObjectBlock)completeBlock; |
167 | 194 |
|
| 195 | +/** |
| 196 | + * Makes POST request to the given URL address and fetches a JSON response. Sends the bodyString param as the POST request body. |
| 197 | + * @param urlString the URL as a string |
| 198 | + * @param bodyData the body of the POST request as an NSData object |
| 199 | + * @param completeBlock JSONObjectBlock to execute upon completion |
| 200 | + * @return JSON compliant object or nil |
| 201 | + */ |
| 202 | ++(void)postJSONFromURLWithString:(NSString*)urlString bodyData:(NSData*)bodyData completion:(JSONObjectBlock)completeBlock; |
| 203 | + |
| 204 | + |
168 | 205 | @end |