forked from troupe/restler-q
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
148 lines (125 loc) · 4.12 KB
/
index.d.ts
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
// Type definitions for restler-q
// Adapted from restler definitions by Cyril Schumacher <https://github.com/cyrilschumacher>
/// <reference types="node"/>
declare module "@gradecam/restler-q" {
import * as http from "http";
import * as Q from "q";
interface RestlerMethods<T> {
del(url: string, options?: Object): Q.Promise<T>;
get(url: string, options?: RestlerOptions): Q.Promise<T>;
head(url: string, options?: RestlerOptions): Q.Promise<T>;
/** Send json data via GET method. */
json(url: string, data?: any, options?: RestlerOptions, method?: string): Q.Promise<T>;
patch(url: string, options?: RestlerOptions): Q.Promise<T>;
patchJson(url: string, data?: any, options?: RestlerOptions): Q.Promise<T>;
post(url: string, options?: RestlerOptions): Q.Promise<T>;
postJson(url: string, data?: any, options?: RestlerOptions): Q.Promise<T>;
put(url: string, options?: RestlerOptions): Q.Promise<T>;
putJson(url: string, data?: any, options?: RestlerOptions): Q.Promise<T>;
service(url: string, options?: RestlerOptions): Q.Promise<T>;
}
interface RestlerStatic extends RestlerMethods<any> {
spread: RestlerMethods<[any, http.IncomingMessage]>;
}
/**
* Interface for the header.
* @interface
*/
interface RestlerOptionsHeader {
[headerName: string]: string;
}
/**
* Interface for restler options.
* @interface
*/
interface RestlerOptions {
/**
* OAuth Bearer Token.
* @type {string}
*/
accessToken?: string;
/**
* HTTP Agent instance to use. If not defined globalAgent will be used. If false opts out of connection pooling with an Agent, defaults request to Connection: close.
* @type {any}
*/
agent?: any;
/**
* A http.Client instance if you want to reuse or implement some kind of connection pooling.
* @type {any}
*/
client?: any;
/**
* Data to be added to the body of the request.
* @type {any}
*/
data?: any;
/**
* Encoding of the response body
* @type {string}
*/
decoding?: string;
/**
* Encoding of the request body.
* @type {string}
*/
encoding?: string;
/**
* If set will recursively follow redirects.
* @type {boolean}
*/
followRedirects?: boolean;
/**
* A hash of HTTP headers to be sent.
* @type {RestlerOptionsHeader}
*/
headers?: RestlerOptionsHeader;
/**
* Request method
* @type {string}
*/
method?: string;
/**
* If set the data passed will be formatted as <code>multipart/form-encoded</code>.
* @type {boolean}
*/
multipart?: boolean;
/**
* A function that will be called on the returned data. Use any of predefined <code>restler.parsers</code>.
* @type {any}
*/
parser?: any;
/**
* Basic auth password.
* @type {string}
*/
password?: string;
/**
* Query string variables as a javascript object, will override the querystring in the URL.
* @type {any}
*/
query?: any;
/**
* If true, the server certificate is verified against the list of supplied CAs.
* An 'error' event is emitted if verification fails. Verification happens at the connection level, before the HTTP request is sent.
* @type {boolean}
*/
rejectUnauthorized?: boolean;
/**
* Emit the timeout event when the response does not return within the said value (in ms).
* @type {number}
*/
timeout?: number;
/**
* Basic auth username.
* @type {string}
*/
username?: string;
/**
* Options for xml2js.
* @type {any}
*/
xml2js?: any;
}
let restler: RestlerStatic;
export = restler;
}