Repository navigation
Expand file tree
/
Copy pathIRWebAPIKit.h
More file actions
175 lines (75 loc) · 4.26 KB
/
Copy pathIRWebAPIKit.h
File metadata and controls
175 lines (75 loc) · 4.26 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
//
// IRWebAPIKit.h
// IRWebAPIKit
//
// Created by Evadne Wu on 11/19/10.
// Copyright 2010 Iridia Productions. All rights reserved.
//
#if 0
#define IRWebAPIKitLog( s, ... ) NSLog( @"<%s : (%d)> %@",__FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define IRWebAPIKitLog( s, ... )
#endif
#ifndef __IRWebAPITransformer__
#define __IRWebAPITransformer__
#import <Foundation/Foundation.h>
@class IRWebAPIEngine;
@class IRWebAPIContext;
@class IRWebAPIAuthenticator;
@class IRWebAPIInterface;
#pragma mark Blocks
typedef NSDictionary * (^IRWebAPIResponseParser) (NSData *inData);
// The parser makes a dictionary from a NSData.
typedef NSDictionary * (^IRWebAPITransformer) (NSDictionary *inOriginalContext);
// The transformer returns a transformed context dictionary.
typedef BOOL (^IRWebAPIResposeValidator) (NSDictionary *inResponseOrNil);
// The validator returns a BOOL regarding to the parsed and transformed response.
typedef void (^IRWebAPICallback) (NSDictionary *inResponseOrNil, NSDictionary *inResponseContext, BOOL *outNotifyDelegate, BOOL *outShouldRetry);
// The callback takes an engine and a response, then optionally tells the engine whether to notify its delegate or retry.
// inResponseContext contains lower-level objects, like NSURLResponse.
// *&outNotifyDelegate defaults to YES
// *&outShouldRetry defaults to NO
typedef void (^IRWebAPIAuthenticatorCallback) (IRWebAPIAuthenticator *inAuthenticator, BOOL isAuthenticated, BOOL *inShouldRetry);
// The authenticator callback takes an authenticator, and its authentication status.
// If necessary, the block works with the authenticator and can tell it to retry authenticating.
typedef void (^IRWebAPIInterfaceCallback) (NSDictionary *inResponseOrNil, BOOL *outNotifyDelegate, BOOL *outShouldRetry);
// The callback takes the response, then optionally tells the interface whether to notify its delegate or retry.
typedef void (^IRWebAPIEngineExecutionBlock) (void);
// Internal.
#pragma mark IRWebAPITransformer Context Dictionary Keys
#define kIRWebAPIEngineRequestHTTPBaseURL @"IRWebAPIEngineRequestHTTPBaseURL"
// Expected to be a NSURL, and well it should be there
#define kIRWebAPIEngineRequestHTTPHeaderFields @"IRWebAPIEngineHTTPHeaderFields"
// Expected to be a dictionary
#define kIRWebAPIEngineRequestHTTPPOSTParameters @"IRWebAPIEngineRequestHTTPPOSTParameters"
// Expected to be a dictionary, that contains NSString / NSData objects. Everything is in utf-8 or octet.
// If not blank, IRWebAPIEngine makes the HTTP body from the parameters.
// Notice that to use POST parameters, a new transformer block that grabs the correct stuff under this key from the context and adds it to the
#define kIRWebAPIEngineRequestHTTPBody @"IRWebAPIEngineHTTPBody"
// Expected to be NSData, or [NSNull null] for custom HTTP body handling.
// If used with IRWebAPIEngineRequestHTTPPOSTParameters, an exception will be thrown.
#define kIRWebAPIEngineRequestHTTPQueryParameters @"IRWebAPIEngineHTTPQueryParameters"
// Expected to be a dictionary
#define kIRWebAPIEngineRequestHTTPMethod @"IRWebAPIEngineRequestHTTPMethod"
// Expected to be POST, GET, whatever. Must be POST if IRWebAPIEngineHTTPPOSTParameters is defined.
#define kIRWebAPIEngineParser @"IRWebAPIEngineParser"
// Expected to be a IRWebAPIResponseParser. Exposed to allow custom response parsing for “some methods”.
#pragma mark IRWebAPIEngine Response Context Dictionary Keys
#define kIRWebAPIEngineResponseContextURLResponseName @"kIRWebAPIEngineResponseContextURLResponseName"
// We send a response context to IRWebAPICallback blocks; this key gets the original response which contains useful information e.g. the return code.
#import "IRWebAPIResponseParser.h"
#import "IRWebAPIKitEntityDefines.h"
#import "IRWebAPIHelpers.h"
#import "IRWebAPIEngine.h"
#import "IRWebAPIContext.h"
#import "IRWebAPIAuthenticator.h"
#import "IRWebAPICredentials.h"
#import "IRWebAPIInterface.h"
#import "IRWebAPIInterfaceAuthenticating.h"
#import "IRWebAPIInterfaceXOAuthAuthenticating.h"
#import "IRWebAPIInterfaceURLShortening.h"
#import "IRWebAPIGoogleReaderAuthenticator.h"
#import "IRWebAPIXOAuthAuthenticator.h"
#import "IRWebAPITwitterInterface.h"
#import "IRWebAPIGoogleReaderInterface.h"
#endif