-
Notifications
You must be signed in to change notification settings - Fork 0
/
OTRestRequest.h
102 lines (82 loc) · 2.51 KB
/
OTRestRequest.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
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
//
// OTRestRequest.h
// OTRestFramework
//
// Created by Jeremy Ellison on 7/27/09.
// Copyright 2009 Two Toasters. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "DocumentRoot.h"
#import "OTRestRequestSerializable.h"
@interface OTRestRequest : NSObject {
NSURL* _URL;
NSMutableURLRequest* _URLRequest;
NSDictionary* _additionalHTTPHeaders;
NSObject<OTRestRequestSerializable>* _params;
id _delegate;
SEL _callback;
id _userData;
NSString* _username;
NSString* _password;
}
/**
* used for http auth chalange
*/
@property(nonatomic, retain) NSString* username;
@property(nonatomic, retain) NSString* password;
@property(nonatomic, readonly) NSURL* URL;
/**
* The NSMutableURLRequest being sent for the Restful request
*/
@property(nonatomic, readonly) NSMutableURLRequest* URLRequest;
/**
* The HTTP Method used for this request
*/
@property(nonatomic, readonly) NSString* HTTPMethod;
/**
* The delegate to inform when the request is completed
*/
@property(nonatomic, retain) id delegate;
/**
* The selector to invoke when the request is completed
*/
@property(nonatomic, assign) SEL callback;
/**
* An opaque pointer to associate user defined data with the request.
*/
@property(nonatomic, assign) id userData;
/**
* A Dictionary of additional HTTP Headers to send with the request
*/
@property(nonatomic, retain) NSDictionary* additionalHTTPHeaders;
/**
* A serializable collection of parameters sent as the HTTP Body of the request
*/
@property(nonatomic, readonly) NSObject<OTRestRequestSerializable>* params;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/**
* Return a REST request that is ready for dispatching
*/
+ (OTRestRequest*)requestWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback;
/**
* Initialize a REST request and prepare it for dispatching
*/
- (id)initWithURL:(NSURL*)URL delegate:(id)delegate callback:(SEL)callback;
/**
* GET the resource and invoke the callback with the response payload
*/
- (void)get;
/**
* POST a collection of params to the resource and invoke the callback with the response payload
*/
- (void)postParams:(NSObject<OTRestRequestSerializable>*)params;
/**
* PUT a collection of params to the resource and invoke the callback with the response payload
*/
- (void)putParams:(NSObject<OTRestRequestSerializable>*)params;
/**
* DELETE the resource and invoke the callback with the response payload
*/
- (void)delete;
@end