-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathclient.js
31 lines (25 loc) · 798 Bytes
/
client.js
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
var url = require('url');
var internals = {};
internals.getOAuth = function (config) {
return {
consumer_key: config.consumerKey,
consumer_secret: config.consumerSecret,
token: config.token,
token_secret: config.tokenSecret
};
};
internals.create = function (config) {
if (!config.baseUrl) {
throw new Error('options.host required (example: www.mymagentosite.com)');
}
this.oauth = internals.getOAuth(config);
this.options = config;
this.makePath = internals.makePath.bind(this);
this.request = require('./request')(this);
this.products = require('./products')(this);
return this;
};
internals.makePath = function (section) {
return url.resolve(this.options.baseUrl, section);
};
module.exports = internals;