Accela SDK for iOS  V3.0
/Users/alan/Accela/AccelaMobile/AccelaMobile/AccelaMobile.h
00001 
00033 #import <Foundation/Foundation.h>
00034 
00035 #import "AMLogger.h"
00036 #import "AMRequest.h"
00037 #import "AMUtility.h"
00038 #import "AMLoginView.h"
00039 #import "AMRequestURL.h"
00040 #import "AMError.h"
00041 
00042 //Default host
00043 #define AM_DEFAULT_OAUTH_HOST @"https://auth.accela.com"
00044 #define AM_DEFAULT_API_HOST @"https://apis.accela.com"
00045 
00046 //Time for request timeout: seconds
00047 #define AM_TIMEOUT 60
00048 
00049 @protocol AMSessionDelegate;
00050 @protocol AMProgressDelegate;
00051 @protocol AMLoginDialogDelegate;
00052 
00053 extern NSString *AccelaMobileVersion;
00054 
00055 typedef enum
00056 {
00057     ENVIRONMENT_PROD = 1,
00058     ENVIRONMENT_TEST
00059 }ENVIRONMENT_TYPE;
00060 
00061 @interface AMParameter : NSObject {
00062     NSString *operationKey;
00063     NSMutableDictionary *body;
00064     NSMutableDictionary *criteria;
00065     NSMutableArray *elements;
00066 }
00067 
00073 - (id)initWithKey: (NSString *) key;
00074 
00082 - (NSData*)toData;
00083 
00089 @property (nonatomic,retain) NSString *operationKey;
00090 
00096 @property (nonatomic,retain) NSMutableDictionary *body;
00097 
00103 @property (nonatomic,retain) NSMutableDictionary *criteria;
00104 
00110 @property (nonatomic,retain) NSMutableArray *elements;
00111 
00112 @end
00113 
00118 @interface AccelaMobile : NSObject<AMRequestDelegate>
00119 {
00120     id<AMSessionDelegate> _sessionDelegate;
00121         
00122         NSString *_appId;
00123         
00124         NSDictionary *_userProfile;
00125 }
00126 
00132 @property(nonatomic, assign) id<AMSessionDelegate> sessionDelegate;
00133 
00139 @property (nonatomic, retain) NSString *amClientId;
00140 
00146 @property (nonatomic, retain) NSString *amClientSecret;
00147 
00153 @property (nonatomic,readonly) NSString *amAuthHost;
00154 
00160 @property (nonatomic,readonly) NSString *amApiHost;
00161 
00162 
00168 @property (nonatomic, retain) NSDictionary *userProfile;
00169 
00176 @property (nonatomic, retain) NSDictionary *httpHeaders;
00177 
00183 @property(nonatomic,setter = setEnvType:) ENVIRONMENT_TYPE amEnvironmentType;
00184 
00190 @property (nonatomic, setter = setAmIsRemember:, getter = getAmIsRemember) BOOL amIsRemember;
00191 
00203 - (id)initWithAppId: (NSString *)appId withAppSecret:(NSString *)appSecret;
00204 
00220 - (id)initWithAppId: (NSString *)appId withAppSecret:(NSString *)appSecret withAuthHost:(NSString *)authHost withApiHost:(NSString *)apiHost;
00221 
00236 - (id)initWithAppId: (NSString *)appId withAppSecret:(NSString *)appSecret andDelegate:(id<AMSessionDelegate>)delegate;
00237 
00255 - (id)initWithAppId: (NSString *)appId withAppSecret:(NSString *)appSecret andDelegate:(id<AMSessionDelegate>)delegate withAuthHost:(NSString *)authHost withApiHost:(NSString *)apiHost;
00256 
00272 - (void)authorize:(NSArray *) permissions;
00273 
00290 - (void)authorize:(NSArray *) permissions withAgency:(NSString *) agency;
00291 
00303 -(BOOL) handleOpenURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation;
00304 
00310 - (void)handleDidBecomeActive;
00311 
00326 - (void)authenticate: (NSString *)agency user: (NSString *)user password: (NSString *)password loginDialogDelegate: (id<AMLoginDialogDelegate>) loginDialogDelegate NS_DEPRECATED_IOS(2_0, 5_0);
00327 
00337 - (void) authorizeAgencyApp:(NSArray *)permissions NS_DEPRECATED_IOS(2_0, 5_0);
00338 
00339 
00355 - (void)authorize2:(NSArray *) permissions;
00356 
00357 
00358 
00375 - (void)authorize2:(NSArray *) permissions withAgency:(NSString *) agency;
00376 
00377 
00385 - (BOOL)isSessionValid;
00386 
00392 - (void)logout;
00393 
00407 - (id)fetchWithPath: (NSString *)servicePath urlParams: (NSDictionary *)params error: (AMErrorBlock)errorBlock;
00408 
00429 - (id)fetchWithPath: (NSString *)servicePath
00430                   urlParams: (NSMutableDictionary *)params
00431                  httpMethod: (HTTP_METHOD)httpMethod
00432                            data: (NSData *)data
00433                           error: (AMErrorBlock)errorBlock;
00434 
00450 - (AMRequest*)requestWithPath: (NSString *)servicePath
00451                                     urlParams: (NSDictionary *)params
00452                           requestDelegate: (id<AMRequestDelegate>)requestDelegate;
00453 
00469 - (AMRequest*)requestWithPath: (NSString *)servicePath
00470                                     urlParams: (NSDictionary *)params
00471                                    httpMethod: (HTTP_METHOD)httpMethod
00472                                                  data: (NSData *)data
00473                           requestDelegate: (id<AMRequestDelegate>)requestDelegate;
00474 
00491 -(AMRequest*)requestWithPath:(NSString *) servicePath
00492                                    urlParams:(NSDictionary *)params
00493                                   httpMethod:(HTTP_METHOD) httpMethod
00494                                                 data:(NSString *) data
00495                                  attachments:(NSDictionary *) attachments
00496                          requestDelegate:(id<AMRequestDelegate>) requestDelegate;
00497 
00513 - (AMRequest*)uploadAttachment: (NSString *)servicePath
00514                                          urlParams: (NSDictionary *)params
00515                                         attachment: (NSDictionary *)fileInformation
00516                            requestDelegate: (id<AMRequestDelegate>)requestDelegate;
00517 
00533 - (AMRequest*)downloadAttachment: (NSString *)servicePath
00534                                            urlParams: (NSDictionary *)params
00535                                            localPath: (NSString *)localFile
00536                          requestDelegate: (id<AMRequestDelegate>)requestDelegate;
00537 
00543 +(AccelaMobile *) defaultInstance;
00544 
00545 @end
00546 
00554 @protocol AMSessionDelegate<NSObject>
00555 
00556 @optional
00557 
00565 -(void)amDidLogin:(int) grantType;
00566 
00572 -(void)amDidCancelLogin;
00573 
00579 -(void)amDidLoginFailure:(AMError *)error;
00580 
00588 -(BOOL)amDidSessionInvalid:(AMError *)error;
00589 
00595 -(void)amDidLogout;
00596 
00597 @end
00598 
00599 
00600 
00601 
00609 @protocol AMLoginDialogDelegate <NSObject>
00610 
00611 @optional
00612 
00621 - (void)amDialogLogin;
00622 
00630 - (void)amDialogNotLogin: (BOOL)cancelled;
00631 
00639 - (void)amDialogLoginFailure:(AMError *)error;
00640 
00641 @end
 All Classes Functions Properties