Accela SDK for iOS
V3.0
|
00001 // 00002 // AMRequest.h 00003 // AccelaMobile 00004 // 00005 // Created by Alan on 1/17/12. 00006 // Copyright (c) 2012 Accela Inc. All rights reserved. 00007 // 00008 00009 #import <Foundation/Foundation.h> 00010 #import <UIKit/UIKit.h> 00011 #import "AMError.h" 00012 00013 #define AMNotificationAuthenticateSuccess @"AMNotificationAuthenticateSuccess" 00014 #define AMNotificationSessionInvalid @"AMNotificationSessionInvalid" 00015 #define AMNotificationSendErrorReport @"AMNotificationSendErrorReport" 00016 00020 typedef enum 00021 { 00022 GET = 0, 00023 POST = 1, 00024 PUT = 2, 00025 DELETE = 3 00026 00027 } HTTP_METHOD; 00028 00029 00033 typedef void (^AMDataBlock)(id *data); 00034 00035 00036 extern BOOL authenticateWaiting; 00037 00038 @protocol AMProgressDelegate; 00039 00040 @protocol AMRequestDelegate; 00041 00042 @interface AMRequest : NSObject 00043 00049 @property (nonatomic, retain) id<AMRequestDelegate> amRequestDelegate; 00050 00051 00057 @property (nonatomic, retain) NSString *amServiceURL; 00058 00059 00065 @property (nonatomic, retain) NSDictionary *amParams; 00066 00067 00073 @property (nonatomic) HTTP_METHOD amHttpMethod; 00074 00075 00081 @property (nonatomic) long amTimeOutSeconds; 00082 00083 00089 @property (nonatomic, copy) AMErrorBlock amErrorBlock; 00090 00091 00097 @property (nonatomic, copy) AMDataBlock amCompletionBlock; 00098 00099 00105 @property (nonatomic, retain) NSString *amDownloadDestinationPath; 00106 00107 00113 @property (nonatomic, retain) NSString *amUploadDestinationPath; 00114 00115 00121 @property (nonatomic, assign, setter = setAmOwnerView:) UIView *amOwnerView; 00122 00123 00129 @property (nonatomic, assign) NSDictionary *userProfile; 00130 00136 @property (nonatomic) NSInteger tag; 00137 00138 00150 - (id)initWithPath: (NSString *)servicePath urlParams: (NSDictionary *)params httpMethod: (HTTP_METHOD)httpMethod; 00151 00159 - (BOOL)isLoading; 00160 00166 - (void)cancelRequest; 00167 00178 - (id)fetchWithData: (NSData *)data error: (AMErrorBlock)errorBlock; 00179 00192 - (AMRequest *)sendRequestWithData: (NSData *)data requestDelegate: (id<AMRequestDelegate>)requestDelegate; 00193 00207 - (AMRequest *)sendRequestWithData: (NSString *)data attachments:(NSDictionary *) attachments requestDelegate: (id<AMRequestDelegate>)requestDelegate; 00208 00209 00222 - (AMRequest *)uploadAttachment: (NSDictionary *)fileInformation requestDelegate: (id<AMRequestDelegate>)requestDelegate; 00223 00224 00237 - (AMRequest *)downloadAttachment: (NSString *) localFile requestDelegate: (id<AMRequestDelegate>)requestDelegate; 00238 00239 00249 - (void) setProgressLabelText:(NSString *) labelText; 00250 00255 -(void) waitUntilFinished; 00256 00257 00258 @end 00259 00267 @protocol AMRequestDelegate <NSObject> 00268 00269 @optional 00270 00276 - (void)amRequestStarted: (AMRequest *)request; 00277 00283 - (void)amRequest: (AMRequest *)request didReceiveResponse: (NSDictionary *)httpHeaders; 00284 00290 - (void)amRequest: (AMRequest *)request didFailWithError: (AMError *)error; 00291 00301 - (void)amRequest: (AMRequest *)request didLoad: (id)result; 00302 00310 - (void)amRequest: (AMRequest *)request receivedBytes: (long long)bytes total: (long long)total; 00311 00317 - (void)amRequest: (AMRequest *)request sendBytes: (long long)bytes; 00318 00319 @end 00320