Repository navigation
Expand file tree
/
Copy pathIRWebAPIKit.h
More file actions
132 lines (62 loc) · 3.59 KB
/
Copy pathIRWebAPIKit.h
File metadata and controls
132 lines (62 loc) · 3.59 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
//
// IRWebAPIKit.h
// IRWebAPIKit
//
// Created by Evadne Wu on 11/19/10.
// Copyright 2010 Iridia Productions. All rights reserved.
//
#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) (IRWebAPIEngine *inEngine, NSDictionary *inResponseOrNil);
// The validator returns a BOOL regarding to the parsed and transformed response.
typedef void (^IRWebAPICallback) (IRWebAPIEngine *inEngine, NSDictionary *inResponseOrNil, BOOL *outNotifyDelegate, BOOL *outShouldRetry);
// The callback takes an engine and a response, then optionally tells the engine whether to notify its delegate or retry.
// *&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”.
#import "IRWebAPIResponseParser.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"