1 |
|
2 | var Zoho;
|
3 |
|
4 | Zoho = (function() {
|
5 | class Zoho {
|
6 | constructor(options = {}) {
|
7 | if (options.region != null) {
|
8 | this.region = options.region;
|
9 | }
|
10 | this.authDefaults = {
|
11 | host: `accounts.zoho.${this.region}`,
|
12 | port: 443,
|
13 | path: "/apiauthtoken/nb/create?SCOPE=ZohoCRM/crmapi"
|
14 | };
|
15 | if (options != null ? options.authToken : void 0) {
|
16 | this.authToken = options != null ? options.authToken : void 0;
|
17 | }
|
18 | return this;
|
19 | }
|
20 |
|
21 | getProduct(productName) {
|
22 | var Crm;
|
23 | Crm = require('./products/' + productName);
|
24 | return new Crm(this);
|
25 | }
|
26 |
|
27 | execute(product, module, call) {
|
28 | var args, moduleInstance, productInstance;
|
29 | args = Array.prototype.slice.call(arguments);
|
30 | productInstance = this.getProduct(product);
|
31 | moduleInstance = productInstance.getModule(module);
|
32 | return moduleInstance[call].apply(moduleInstance, args.slice(3));
|
33 | }
|
34 |
|
35 | };
|
36 |
|
37 | Zoho.prototype.authToken = null;
|
38 |
|
39 | Zoho.prototype.region = 'com';
|
40 |
|
41 | return Zoho;
|
42 |
|
43 | }).call(this);
|
44 |
|
45 | module.exports = Zoho;
|