|
1 | 1 | declare module '@foxcomm/api-js' { |
2 | | - declare type StringDict = {[name: string]: string}; |
| 2 | + declare type StringDict = { [name: string]: string }; |
3 | 3 |
|
4 | 4 | declare type AbortablePromise = Promise<*> & { |
5 | | - abort(): void; |
| 5 | + abort(): void, |
6 | 6 | }; |
7 | 7 |
|
8 | 8 | declare type AgentLike = AbortablePromise & { |
9 | | - get(url: string): AgentLike; |
10 | | - post(url: string): AgentLike; |
11 | | - patch(url: string): AgentLike; |
12 | | - delete(url: string): AgentLike; |
| 9 | + get(url: string): AgentLike, |
| 10 | + post(url: string): AgentLike, |
| 11 | + patch(url: string): AgentLike, |
| 12 | + delete(url: string): AgentLike, |
13 | 13 |
|
14 | | - set(headers: StringDict): AgentLike; |
15 | | - withCredentials(): AgentLike; |
| 14 | + set(headers: StringDict): AgentLike, |
| 15 | + withCredentials(): AgentLike, |
16 | 16 | }; |
17 | 17 |
|
18 | 18 | declare type RequestOptions = { |
19 | 19 | headers?: StringDict, |
20 | 20 | credentials?: string, |
21 | | - agent?: AgentLike; |
| 21 | + agent?: AgentLike, |
22 | 22 | }; |
23 | 23 |
|
24 | 24 | // @TODO: add subclasses |
25 | 25 | declare class ApiClass { |
26 | | - addresses: mixed; |
27 | | - auth: mixed; |
28 | | - creditCards: mixed; |
29 | | - storeCredits: mixed; |
30 | | - cart: mixed; |
31 | | - account: mixed; |
32 | | - orders: mixed; |
33 | | - reviews: mixed; |
34 | | - analytics: mixed; |
35 | | - crossSell: mixed; |
36 | | - |
37 | | - addAuth(jwt: string): ApiClass; |
38 | | - removeAuth(): ApiClass; |
| 26 | + addresses: mixed, |
| 27 | + auth: mixed, |
| 28 | + creditCards: mixed, |
| 29 | + storeCredits: mixed, |
| 30 | + cart: mixed, |
| 31 | + account: mixed, |
| 32 | + orders: mixed, |
| 33 | + reviews: mixed, |
| 34 | + analytics: mixed, |
| 35 | + crossSell: mixed, |
| 36 | + |
| 37 | + addAuth(jwt: string): ApiClass, |
| 38 | + removeAuth(): ApiClass, |
39 | 39 |
|
40 | 40 | // Returns customer id from parsed jwt string |
41 | 41 | // You can define jwt string via `addAuth` method, if there is no jwt strings method returns null. |
42 | | - getCustomerId(): ?number; |
43 | | - |
44 | | - setHeaders(headers: StringDict): ApiClass; |
45 | | - addHeaders(headers: StringDict): ApiClass; |
46 | | - uri(path: string): string; |
47 | | - queryStringToObject(qs: string): StringDict; |
48 | | - |
49 | | - request(method: string, uri: string, data: ?Object, options: ?RequestOptions): AbortablePromise; |
50 | | - get(uri: string, data: ?Object, options: ?Object): AbortablePromise; |
51 | | - post(uri: string, data: ?Object, options: ?Object): AbortablePromise; |
52 | | - patch(uri: string, data: ?Object, options: ?Object): AbortablePromise; |
53 | | - delete(uri: string, data: ?Object, options: ?Object): AbortablePromise; |
| 42 | + getCustomerId(): ?number, |
| 43 | + |
| 44 | + setHeaders(headers: StringDict): ApiClass, |
| 45 | + addHeaders(headers: StringDict): ApiClass, |
| 46 | + uri(path: string): string, |
| 47 | + queryStringToObject(qs: string): StringDict, |
| 48 | + |
| 49 | + request(method: string, uri: string, data: ?Object, options: ?RequestOptions): AbortablePromise, |
| 50 | + get(uri: string, data: ?Object, options: ?Object): AbortablePromise, |
| 51 | + post(uri: string, data: ?Object, options: ?Object): AbortablePromise, |
| 52 | + patch(uri: string, data: ?Object, options: ?Object): AbortablePromise, |
| 53 | + delete(uri: string, data: ?Object, options: ?Object): AbortablePromise, |
54 | 54 | } |
55 | 55 |
|
56 | 56 | declare function parseError(err: mixed): Array<string>; |
|
0 commit comments