forked from DivanteLtd/magento1-vsbridge-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
42 lines (36 loc) · 1.2 KB
/
index.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
32
33
34
35
36
37
38
39
40
41
42
const RestClient = require('./lib/rest_client').RestClient;
const user = require('./lib/user');
const cart = require('./lib/cart');
const order = require('./lib/order');
const stock = require('./lib/stock');
const contact = require('./lib/contact');
const wishlist = require('./lib/wishlist');
const stockAlert = require('./lib/stock_alert');
const newsletter = require('./lib/newsletter');
const address = require('./lib/address');
const MAGENTO_API_VERSION = 'V1';
module.exports.Magento1Client = function (options) {
let instance = {
addMethods (key, module) {
let client = RestClient(options);
if (module) {
if (this[key])
this[key] = Object.assign(this[key], module(client));
else
this[key] = module(client);
}
}
};
options.version = MAGENTO_API_VERSION;
let client = RestClient(options);
instance.user = user(client);
instance.cart = cart(client);
instance.order = order(client);
instance.stock = stock(client);
instance.contact = contact(client);
instance.wishlist = wishlist(client);
instance.stockAlert = stockAlert(client);
instance.newsletter = newsletter(client);
instance.address = address(client);
return instance;
};