1 |
|
2 | var BaseModule, _;
|
3 |
|
4 | _ = require('underscore');
|
5 |
|
6 | BaseModule = (function() {
|
7 | class BaseModule {
|
8 | constructor(product) {
|
9 | this.product = product;
|
10 | if (!this.product) {
|
11 | throw new Error('Requires product');
|
12 | }
|
13 | return;
|
14 | }
|
15 |
|
16 | getUrlParts() {
|
17 | return [this.scope, this.format, this.name];
|
18 | }
|
19 |
|
20 | buildUrl(query = {}, path = [], options = {}) {
|
21 | var method, url;
|
22 | method = 'POST';
|
23 | if (options != null ? options.method : void 0) {
|
24 | method = options.method.toUpperCase();
|
25 | }
|
26 | url = this.product.getBaseUrl();
|
27 | url.method = method;
|
28 | url.path = url.path.concat(this.getUrlParts());
|
29 | url.path = url.path.concat(path);
|
30 | url.pathname = "/" + url.path.join("/");
|
31 | _.extend(url.query, query);
|
32 | return url;
|
33 | }
|
34 |
|
35 | };
|
36 |
|
37 | BaseModule.prototype.name = "BaseModule";
|
38 |
|
39 | BaseModule.prototype.format = "xml";
|
40 |
|
41 | BaseModule.prototype.scope = "private";
|
42 |
|
43 | return BaseModule;
|
44 |
|
45 | }).call(this);
|
46 |
|
47 | module.exports = BaseModule;
|