Skip to content
This repository was archived by the owner on Aug 20, 2020. It is now read-only.

Commit d63f709

Browse files
authored
feat: Added type definitions (#93)
1 parent 0755041 commit d63f709

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

lib/client.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
declare module 'sendgrid-rest' {
2+
/**
3+
* request holds the request to an API Call
4+
* @field `test` use this to allow for http calls
5+
* @field `port` set the port for http calls
6+
*/
7+
export interface Request {
8+
host: string,
9+
method: string,
10+
path: string,
11+
headers: {[key: string]: any},
12+
body: object | string,
13+
queryParams: {[key: string]: any},
14+
test: boolean,
15+
port: string,
16+
}
17+
18+
/**
19+
* response holds the response from an API call, use this as an initializer
20+
* like so: JSON.parse(JSON.stringify(response))
21+
*/
22+
export interface Response {
23+
statusCode: string,
24+
body: object | string,
25+
headers: {[key: string]: any},
26+
}
27+
28+
/**
29+
* Client allows for quick and easy access any REST or REST-like API.
30+
*/
31+
export class Client {
32+
constructor(globalRequest: Request)
33+
/**
34+
* utility function to create an empty request object
35+
*/
36+
public emptyRequest(): Request
37+
/**
38+
* API is the main interface to the API.
39+
*/
40+
public API(endpointRequest: Request, callback: (response: Response) => void): void
41+
}
42+
43+
export var emptyRequest: Request
44+
export var request: Request
45+
}

0 commit comments

Comments
 (0)