This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
GOVDataRequest.h
executable file
·64 lines (48 loc) · 2.1 KB
/
GOVDataRequest.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
56
57
58
59
60
61
62
63
64
//
// GOVDataRequest.h
// Version 1.0
//
// Created by the U.S. Deparment of Labor
// Code available in the public domain
//
#import <Foundation/Foundation.h>
//#import "ASIHTTPRequest.h"
#import "GOVDataContext.h"
extern NSString* const URL_API_V1;
extern NSString* const URL_API_V2;
//Declare delegate for callback. Full declaration below interface.
@protocol GOVDataRequestDelegate;
@interface GOVDataRequest : NSObject {
__weak id<GOVDataRequestDelegate>delegate;
//We need to keep track of the requests
//we need to cancel them before dealloc or app will crash when the results return.
NSMutableArray *activeRequests;
GOVDataContext *context;
}
//Context object to provide keys and URL
@property(nonatomic,retain)GOVDataContext *context;
//Delegate for callback methods
@property(nonatomic,weak)id<GOVDataRequestDelegate>delegate;
//The main method of the GOVData SDK.
//Triggers entire chain of events to calls HTTP methods:
//Building request
//Building request header
//Making request
//Parsing JSON results
//Calling callback method to return parsed results in an NSDictionary *
-(void)callAPIMethod:(NSString *)method withArguments:(NSDictionary *)arguments andTimeOut:(int)timeOut;
//Init method
-(id)initWithContext:(GOVDataContext *)apicontext;
@end
//Delegate for callbacks
//This is where the results and errors are sent to the calling object.
@protocol GOVDataRequestDelegate <NSObject>
//Returns results to delegate
-(void)govDataRequest:(GOVDataRequest *)request didCompleteWithResults:(NSArray *)resultsArray andResponseTime:(float)timeInMS;
//Returns unmassaged dictionary results to delegate
-(void)govDataRequest:(GOVDataRequest *)request didCompleteWithDictionaryResults:(NSDictionary *)resultsDictionary andResponseTime:(float)timeInMS;
//Returns unmassaged string results to delegate (all else fails to parse)
-(void)govDataRequest:(GOVDataRequest *)request didCompleteWithUnParsedResults:(NSString *)resultsString andResponseTime:(float)timeInMS;
//Returns error to delegate
-(void)govDataRequest:(GOVDataRequest *)request didCompleteWithError:(NSString *)error;
@end