-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.d.ts
159 lines (143 loc) · 3.43 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
149
150
151
152
153
154
155
156
157
158
159
import * as OAuth from 'oauth-1.0a'
export declare type MagentoRestApiVersion =
| 'V1'
| 'async/V1'
| 'async/bulk/V1'
export declare type MagentoRestApiMethod =
| 'get'
| 'post'
| 'put'
| 'delete'
export interface IMagentoRestApiOptions {
/* Your Store URL, example: http://magento.dev/ */
url: string
/* Your API consumer key */
consumerKey: string
/* Your API consumer secret */
consumerSecret: string
/* Your API Access Token */
accessToken: string
/* Your API Access Token Secret */
tokenSecret: string
/* Your API Endpoint */
type?: string
/* Your API SHA Version */
sha?: number
/* Define the request timeout */
timeout?: number
/* Define the custom Axios config, also override this library options */
axiosConfig?: any
}
/**
* Magento REST API wrapper
*
* @param {Object} opt
*/
export default class MagentoRestApi {
protected url: string
protected consumerKey: string
protected consumerSecret: string
protected accessToken: string
protected tokenSecret: string
protected endpointType: MagentoRestApiVersion
protected shaVersion: string
protected timeout: number
protected axiosConfig: any
/**
* Class constructor.
*
* @param {Object} opt
*/
constructor(opt: IMagentoRestApiOptions | MagentoRestApi)
/**
* Set default options
*
* @param {Object} opt
*/
private _setDefaults(opt: IMagentoRestApiOptions): void
/**
* Normalize query string for oAuth
*
* @param {String} url
* @param {Object} params
*
* @return {String}
*/
private _normalizeQueryString(url: string, params: any): string
/**
* @return {Object}
*/
private _getSHAType(): object
/**
* Get URL
*
* @param {String} endpoint
*
* @return {String}
*/
private _formURL(endpoint: string): string
/**
* Get OAuth
*
* @return {Object}
*/
private _getOAuth(): OAuth
/**
* Do requests
*
* @param {String} method
* @param {String} endpoint
* @param {Object} data
*
* @return {Object}
*/
private _formRequest(
method: MagentoRestApiMethod,
endpoint: string,
data: any
): Promise<any>
/**
* Search Translation for query strings
*
* @param {Object} params
*
* @return {Object}
*/
private _searchTranslate(params:any): any
/**
* GET requests
*
* @param {String} endpoint
* @param {Object} params
*
* @return {Object}
*/
public get(endpoint: string): Promise<any>
public get(endpoint: string, params: any): Promise<any>
/**
* POST requests
*
* @param {String} endpoint
* @param {Object} data
*
* @return {Object}
*/
public post(endpoint: string, data: any): Promise<any>
/**
* PUT requests
*
* @param {String} endpoint
* @param {Object} data
*
* @return {Object}
*/
public put(endpoint: string, data: any): Promise<any>
/**
* DELETE requests
*
* @param {String} endpoint
*
* @return {Object}
*/
public delete(endpoint: string): Promise<any>
}