-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPICall.h
55 lines (44 loc) · 1.97 KB
/
APICall.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
//
// APICall.h
// AvocadoTest1
//
// Created by Jake on 12-01-18.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
@protocol APICallDelegate;
extern NSString* SERVER_HTTP_ERROR_DOMAIN;
@interface APICall : NSObject<NSURLConnectionDataDelegate> {
@private
BOOL completed;
NSInteger attemptCounter;
NSMutableURLRequest* request;
NSHTTPURLResponse* response;
NSError* error;
NSMutableData* data;
void (^successblock)(APICall*);
void (^errorblock)(APICall*, NSError*);
}
+(id)sendGETRequestForLocation:(NSString*)location withDelegate:(id<APICallDelegate>)delegate;
+(id)sendDELETERequestForLocation:(NSString*)location withDelegate:(id<APICallDelegate>)delegate;
+(id)sendPOSTRequestForLocation:(NSString*)location withBodyData:(NSData*)data withDelegate:(id<APICallDelegate>)delegate;
+(id)sendPOSTRequestForLocation:(NSString*)location withFormData:(NSDictionary*)form andDelegate:(id<APICallDelegate>)delegate;
+(id)sendGETRequestForLocation:(NSString*)location
success:(void(^)(id))success
failure:(void(^)(id, NSError*))failure;
+(id)sendDELETERequestForLocation:(NSString*)location
success:(void(^)(id))success
failure:(void(^)(id, NSError*))failure;
+(id)sendPOSTRequestForLocation:(NSString*)location
withBodyData:(NSData*)data
success:(void (^)(id))success
failure:(void(^)(id, NSError*))failure;
+(id)sendPOSTRequestForLocation:(NSString*)location
withFormData:(NSDictionary*)form
success:(void (^)(id))success
failure:(void(^)(id, NSError*))failure;
@property(readonly)BOOL completed;
@property(retain,readonly)NSError* error;
@property(retain,readonly)NSData* rawData;
@property(retain,readonly)NSHTTPURLResponse* response;
@property(retain,readonly)NSURLRequest* request;
@end