-
Notifications
You must be signed in to change notification settings - Fork 90
/
index.js
56 lines (49 loc) · 1.97 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var RestClient = require('./lib/rest_client').RestClient;
var categories = require('./lib/categories');
var attributes = require('./lib/attributes');
var products = require('./lib/products');
var productMedia = require('./lib/product_media');
var categoryProducts = require('./lib/category_products');
var configurableChildren = require('./lib/configurable_children');
var configurableOptions = require('./lib/configurable_options');
var taxRates = require('./lib/tax_rates');
var taxRules = require('./lib/tax_rules');
var stockItems = require('./lib/stock_items');
var customers = require('./lib/customers');
var directory = require('./lib/directory');
var cart = require('./lib/cart');
var orders = require('./lib/orders');
var reviews = require('./lib/reviews');
const MAGENTO_API_VERSION = 'V1';
module.exports.Magento2Client = function (options) {
var instance = {
addMethods (key, module) {
var 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;
var client = RestClient(options);
instance.attributes = attributes(client);
instance.categories = categories(client);
instance.products = products(client);
instance.productMedia = productMedia(client);
instance.categoryProducts = categoryProducts(client);
instance.configurableChildren = configurableChildren(client);
instance.configurableOptions = configurableOptions(client);
instance.stockItems = stockItems(client);
instance.taxRates = taxRates(client);
instance.taxRules = taxRules(client);
instance.customers = customers(client);
instance.cart = cart(client);
instance.orders = orders(client);
instance.directory = directory(client);
instance.reviews = reviews(client);
return instance;
}