Skip to content

Commit 793eb96

Browse files
Add _setDefaults
1 parent 0e7e9ad commit 793eb96

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@imagination-media/magento-api-rest",
3-
"version": "3.0.5",
3+
"version": "3.0.6",
44
"description": "Magento API wrapper",
55
"main": "lib/index.js",
66
"files": ["lib"],

src/index.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,7 @@ class MagentoApi {
1212
* Constructor
1313
* @param params object
1414
*/
15-
constructor(params:{
16-
url: string,
17-
consumerKey: string,
18-
consumerSecret: string,
19-
accessToken: string,
20-
tokenSecret: string,
21-
magentoVersion?: string|null|undefined,
22-
}) {
15+
constructor(params: MagentoApiParams) {
2316
this.url = params.url;
2417
this.consumerKey = params.consumerKey;
2518
this.consumerSecret = params.consumerSecret;
@@ -120,11 +113,33 @@ class MagentoApi {
120113
console.error(error);
121114
}
122115
}
116+
117+
/**
118+
* Set the default values for the Magento API
119+
* @param params object
120+
*/
121+
_setDefaults (params: MagentoApiParams) {
122+
this.url = params.url;
123+
this.consumerKey = params.consumerKey;
124+
this.consumerSecret = params.consumerSecret;
125+
this.accessToken = params.accessToken;
126+
this.tokenSecret = params.tokenSecret;
127+
this.magentoVersion = params.magentoVersion;
128+
}
123129
}
124130

125131
interface Header {
126132
'Content-Type': string,
127133
'Authorization': string
128134
}
129135

136+
interface MagentoApiParams {
137+
url: string,
138+
consumerKey: string,
139+
consumerSecret: string,
140+
accessToken: string,
141+
tokenSecret: string,
142+
magentoVersion?: string|null|undefined,
143+
}
144+
130145
export default MagentoApi;

0 commit comments

Comments
 (0)