Accela SDK for iOS  V3.2
 All Classes Functions Properties Pages
AMRequest.h
1 //
2 // AMRequest.h
3 // AccelaMobile
4 //
5 // Created by Alan on 1/17/12.
6 // Copyright (c) 2012 Accela Inc. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 #import <UIKit/UIKit.h>
11 #import "AMError.h"
12 
13 #define AMNotificationAuthenticateSuccess @"AMNotificationAuthenticateSuccess"
14 #define AMNotificationSessionInvalid @"AMNotificationSessionInvalid"
15 #define AMNotificationSendErrorReport @"AMNotificationSendErrorReport"
16 
20 typedef enum
21 {
22  GET = 0,
23  POST = 1,
24  PUT = 2,
25  DELETE = 3
26 
27 } HTTP_METHOD;
28 
29 
33 typedef void (^AMDataBlock)(id *data);
34 
35 
36 extern BOOL authenticateWaiting;
37 
38 @protocol AMProgressDelegate;
39 
40 @protocol AMRequestDelegate;
41 
42 @interface AMRequest : NSObject
43 
49 @property (nonatomic, retain) id<AMRequestDelegate> amRequestDelegate;
50 
51 
57 @property (nonatomic, retain) NSString *amServiceURL;
58 
59 
65 @property (nonatomic, retain) NSDictionary *amParams;
66 
67 
73 @property (nonatomic) HTTP_METHOD amHttpMethod;
74 
75 
81 @property (nonatomic) long amTimeOutSeconds;
82 
83 
89 @property (nonatomic, copy) AMErrorBlock amErrorBlock;
90 
91 
97 @property (nonatomic, copy) AMDataBlock amCompletionBlock;
98 
99 
105 @property (nonatomic, retain) NSString *amDownloadDestinationPath;
106 
107 
113 @property (nonatomic, retain) NSString *amUploadDestinationPath;
114 
115 
121 @property (nonatomic, assign, setter = setAmOwnerView:) UIView *amOwnerView;
122 
123 
129 @property (nonatomic, assign) NSDictionary *userProfile;
130 
136 @property (nonatomic) NSInteger tag;
137 
138 
150 - (id)initWithPath: (NSString *)servicePath urlParams: (NSDictionary *)params httpMethod: (HTTP_METHOD)httpMethod;
151 
159 - (BOOL)isLoading;
160 
166 - (void)cancelRequest;
167 
178 - (id)fetchWithData: (NSData *)data error: (AMErrorBlock)errorBlock;
179 
192 - (AMRequest *)sendRequestWithData: (NSData *)data requestDelegate: (id<AMRequestDelegate>)requestDelegate;
193 
207 - (AMRequest *)sendRequestWithData: (NSString *)data attachments:(NSDictionary *) attachments requestDelegate: (id<AMRequestDelegate>)requestDelegate;
208 
209 
222 - (AMRequest *)uploadAttachment: (NSDictionary *)fileInformation requestDelegate: (id<AMRequestDelegate>)requestDelegate;
223 
224 
237 - (AMRequest *)downloadAttachment: (NSString *) localFile requestDelegate: (id<AMRequestDelegate>)requestDelegate;
238 
239 
253 - (AMRequest*)downloadAttachment:(NSString *) postData localFile:(NSString *) localFile requestDelegate:(id<AMRequestDelegate>) requestDelegate;
254 
264 - (void) setProgressLabelText:(NSString *) labelText;
265 
270 -(void) waitUntilFinished;
271 
272 
273 @end
274 
282 @protocol AMRequestDelegate <NSObject>
283 
284 @optional
285 
291 - (void)amRequestStarted: (AMRequest *)request;
292 
298 - (void)amRequest: (AMRequest *)request didReceiveResponse: (NSDictionary *)httpHeaders;
299 
305 - (void)amRequest: (AMRequest *)request didFailWithError: (AMError *)error;
306 
316 - (void)amRequest: (AMRequest *)request didLoad: (id)result;
317 
325 - (void)amRequest: (AMRequest *)request receivedBytes: (long long)bytes total: (long long)total;
326 
332 - (void)amRequest: (AMRequest *)request sendBytes: (long long)bytes;
333 
334 @end
335 
AMErrorBlock amErrorBlock
Definition: AMRequest.h:89
NSDictionary * amParams
Definition: AMRequest.h:65
Definition: AMError.h:27
NSString * amUploadDestinationPath
Definition: AMRequest.h:113
UIView * amOwnerView
Definition: AMRequest.h:121
void waitUntilFinished()
Definition: AMRequest.h:42
HTTP_METHOD amHttpMethod
Definition: AMRequest.h:73
BOOL isLoading()
AMDataBlock amCompletionBlock
Definition: AMRequest.h:97
NSDictionary * userProfile
Definition: AMRequest.h:129
NSString * amDownloadDestinationPath
Definition: AMRequest.h:105
void cancelRequest()
long amTimeOutSeconds
Definition: AMRequest.h:81
NSString * amServiceURL
Definition: AMRequest.h:57
NSInteger tag
Definition: AMRequest.h:136
Definition: AMRequest.h:282
id< AMRequestDelegate > amRequestDelegate
Definition: AMRequest.h:49