zudello-integration-sdk 1.0.25 → 1.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.js +10 -0
- package/src/sdk/EDI.js +31 -0
- package/src/sdk/GP.js +39 -0
- package/src/sdk/SAPB1.js +49 -0
- package/src/sdk/X3.js +31 -0
- package/src/sdk/submodules/edi/Universal.js +56 -0
- package/src/sdk/submodules/gp/Universal.js +70 -0
- package/src/sdk/submodules/gp/purchase/Credit.js +37 -0
- package/src/sdk/submodules/gp/purchase/Expense.js +37 -0
- package/src/sdk/submodules/gp/purchase/Invoice.js +37 -0
- package/src/sdk/submodules/nexvia/Universal.js +145 -104
- package/src/sdk/submodules/sap-b1/Universal.js +70 -0
- package/src/sdk/submodules/sap-b1/purchase/Credit.js +37 -0
- package/src/sdk/submodules/sap-b1/purchase/GoodReceipt.js +37 -0
- package/src/sdk/submodules/sap-b1/purchase/Invoice.js +37 -0
- package/src/sdk/submodules/sap-b1/purchase/Order.js +37 -0
- package/src/sdk/submodules/sap-b1/sale/Credit.js +37 -0
- package/src/sdk/submodules/sap-b1/sale/Invoice.js +37 -0
- package/src/sdk/submodules/sap-b1/sale/Order.js +37 -0
- package/src/sdk/submodules/x3/Universal.js +109 -0
- package/src/utils/config.js +4 -0
- package/src/utils/formHelper.js +0 -4
- package/src/utils/responseHandler.js +23 -23
- package/src/utils/responseHelper.js +58 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -15,6 +15,10 @@ const MYOBAcumaticaSDK = require("./sdk/MYOBAcumatica");
|
|
|
15
15
|
const SybizSDK = require("./sdk/Sybiz");
|
|
16
16
|
const XeroSDK = require("./sdk/Xero");
|
|
17
17
|
const JobReadySDK = require("./sdk/JobReady");
|
|
18
|
+
const X3SDK = require("./sdk/X3");
|
|
19
|
+
const SAPB1SDK = require("./sdk/SAPB1");
|
|
20
|
+
const GPSDK = require("./sdk/GP");
|
|
21
|
+
const EDISDK = require("./sdk/EDI");
|
|
18
22
|
|
|
19
23
|
const Logger = require("./utils/logger");
|
|
20
24
|
const Metadata = require("./utils/metadata");
|
|
@@ -25,6 +29,7 @@ const MiscHelper = require("./utils/miscHelper");
|
|
|
25
29
|
const ModelHelper = require("./utils/modelHelper");
|
|
26
30
|
const DatasetHelper = require("./utils/datasetHelper");
|
|
27
31
|
const FormHelper = require("./utils/formHelper");
|
|
32
|
+
const ResponseHelper = require("./utils/responseHelper");
|
|
28
33
|
const {
|
|
29
34
|
getFileContent,
|
|
30
35
|
uploadFile,
|
|
@@ -51,6 +56,10 @@ module.exports = {
|
|
|
51
56
|
ZenotiSDK,
|
|
52
57
|
DearSDK,
|
|
53
58
|
NexviaSDK,
|
|
59
|
+
GPSDK,
|
|
60
|
+
SAPB1SDK,
|
|
61
|
+
EDISDK,
|
|
62
|
+
X3SDK,
|
|
54
63
|
FoSDK,
|
|
55
64
|
RetailExpressSDK,
|
|
56
65
|
MYOBAcumaticaSDK,
|
|
@@ -66,5 +75,6 @@ module.exports = {
|
|
|
66
75
|
ModelHelper,
|
|
67
76
|
DatasetHelper,
|
|
68
77
|
FormHelper,
|
|
78
|
+
ResponseHelper,
|
|
69
79
|
S3Client,
|
|
70
80
|
};
|
package/src/sdk/EDI.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const UniversalModule = require("./submodules/edi/Universal");
|
|
5
|
+
|
|
6
|
+
class EDISDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: "edi",
|
|
20
|
+
integrationName: "EDI",
|
|
21
|
+
loggerClass,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = EDISDK;
|
package/src/sdk/GP.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const UniversalModule = require("./submodules/gp/Universal");
|
|
5
|
+
const InvoiceModule = require("./submodules/gp/purchase/Invoice");
|
|
6
|
+
const ExpenseModule = require("./submodules/gp/purchase/Expense");
|
|
7
|
+
const CreditModule = require("./submodules/gp/purchase/Credit");
|
|
8
|
+
|
|
9
|
+
class GPSDK extends BaseSDK {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor.
|
|
12
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
13
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
14
|
+
*/
|
|
15
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
16
|
+
super({
|
|
17
|
+
auth,
|
|
18
|
+
connectionUUID,
|
|
19
|
+
organizationUUID,
|
|
20
|
+
apiURL,
|
|
21
|
+
apiVersion,
|
|
22
|
+
appUUIDKey: "gp",
|
|
23
|
+
integrationName: "GP",
|
|
24
|
+
loggerClass,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create submodule instances.
|
|
29
|
+
*/
|
|
30
|
+
this.universal = new UniversalModule(this);
|
|
31
|
+
this.purchase = {
|
|
32
|
+
invoice: new InvoiceModule(this),
|
|
33
|
+
expense: new ExpenseModule(this),
|
|
34
|
+
credit: new CreditModule(this),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
module.exports = GPSDK;
|
package/src/sdk/SAPB1.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const UniversalModule = require("./submodules/sap-b1/Universal");
|
|
5
|
+
const PurchaseInvoiceModule = require("./submodules/sap-b1/purchase/Invoice");
|
|
6
|
+
const PurchaseOrderModule = require("./submodules/sap-b1/purchase/Order");
|
|
7
|
+
const PurchaseCreditModule = require("./submodules/sap-b1/purchase/Credit");
|
|
8
|
+
const PurchaseReceiptModule = require("./submodules/sap-b1/purchase/GoodReceipt");
|
|
9
|
+
const SaleInvoiceModule = require("./submodules/sap-b1/sale/Invoice");
|
|
10
|
+
const SaleOrderModule = require("./submodules/sap-b1/sale/Order");
|
|
11
|
+
const SaleCreditModule = require("./submodules/sap-b1/sale/Credit");
|
|
12
|
+
|
|
13
|
+
class SAPB1SDK extends BaseSDK {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor.
|
|
16
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
17
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
18
|
+
*/
|
|
19
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
20
|
+
super({
|
|
21
|
+
auth,
|
|
22
|
+
connectionUUID,
|
|
23
|
+
organizationUUID,
|
|
24
|
+
apiURL,
|
|
25
|
+
apiVersion,
|
|
26
|
+
appUUIDKey: "sapb1",
|
|
27
|
+
integrationName: "SAPB1",
|
|
28
|
+
loggerClass,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create submodule instances.
|
|
33
|
+
*/
|
|
34
|
+
this.universal = new UniversalModule(this);
|
|
35
|
+
this.purchase = {
|
|
36
|
+
order: new PurchaseOrderModule(this),
|
|
37
|
+
invoice: new PurchaseInvoiceModule(this),
|
|
38
|
+
credit: new PurchaseCreditModule(this),
|
|
39
|
+
receipt: new PurchaseReceiptModule(this),
|
|
40
|
+
};
|
|
41
|
+
this.sale = {
|
|
42
|
+
order: new SaleOrderModule(this),
|
|
43
|
+
invoice: new SaleInvoiceModule(this),
|
|
44
|
+
credit: new SaleCreditModule(this),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = SAPB1SDK;
|
package/src/sdk/X3.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const UniversalModule = require("./submodules/x3/Universal");
|
|
5
|
+
|
|
6
|
+
class X3SDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
10
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
11
|
+
*/
|
|
12
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
13
|
+
super({
|
|
14
|
+
auth,
|
|
15
|
+
connectionUUID,
|
|
16
|
+
organizationUUID,
|
|
17
|
+
apiURL,
|
|
18
|
+
apiVersion,
|
|
19
|
+
appUUIDKey: "x3",
|
|
20
|
+
integrationName: "X3",
|
|
21
|
+
loggerClass,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = X3SDK;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of EDI class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: offset, limit.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
|
+
* @returns {object} Universal Request Response.
|
|
20
|
+
*/
|
|
21
|
+
async request({ url, method, qs = {}, body = {} }) {
|
|
22
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
|
+
|
|
24
|
+
if (!validateIsEmpty.valid) {
|
|
25
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await this.module.makeRequest(
|
|
29
|
+
"POST",
|
|
30
|
+
`${this.module.apiURL}/zintegrations/action/54b14eeb-cbb7-4bfe-9c62-575006e32070`,
|
|
31
|
+
{
|
|
32
|
+
mappable_parameters: {
|
|
33
|
+
url: {
|
|
34
|
+
value: url,
|
|
35
|
+
},
|
|
36
|
+
method: {
|
|
37
|
+
value: method,
|
|
38
|
+
},
|
|
39
|
+
qs: {
|
|
40
|
+
isMap: true,
|
|
41
|
+
value: JSON.stringify(qs),
|
|
42
|
+
},
|
|
43
|
+
body: {
|
|
44
|
+
isMap: true,
|
|
45
|
+
value: JSON.stringify(body),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
_debug: true,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
module.exports = UniversalModule;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: offset, limit.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
|
+
* @returns {object} Universal Request Response.
|
|
20
|
+
*/
|
|
21
|
+
async request({ command = "fetch_sql", qs = {}, body = {} }) {
|
|
22
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
|
+
|
|
24
|
+
if (!validateIsEmpty.valid) {
|
|
25
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await this.module.makeRequest(
|
|
29
|
+
"POST",
|
|
30
|
+
`${this.module.apiURL}/zintegrations/action/cbf8fd38-c7fa-4204-9f35-9e07a9d99e42`,
|
|
31
|
+
{
|
|
32
|
+
mappable_parameters: {
|
|
33
|
+
command: {
|
|
34
|
+
value: command,
|
|
35
|
+
},
|
|
36
|
+
qs: {
|
|
37
|
+
isMap: true,
|
|
38
|
+
value: JSON.stringify(qs),
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
isMap: true,
|
|
42
|
+
value: JSON.stringify(body),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
_debug: true,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Universal List By URL.
|
|
54
|
+
* @param {number} offset Offset of listed data.
|
|
55
|
+
* @param {number} limit Limit of listed data.
|
|
56
|
+
* @param {string} query Query of listed data.
|
|
57
|
+
* @returns {object} Universal List Response.
|
|
58
|
+
*/
|
|
59
|
+
async list({ offset = 0, limit = 100, query = "" }) {
|
|
60
|
+
return await this.request({
|
|
61
|
+
body: {
|
|
62
|
+
query,
|
|
63
|
+
offset,
|
|
64
|
+
limit,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = UniversalModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class CreditModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of GP class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/265f24e2-84dc-48d4-8c36-568bbee0a540`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = CreditModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class ExpenseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of GP class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/bb2c2aff-05c2-4aa8-a27e-41b0f90114b2`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = ExpenseModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class InvoiceModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of GP class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/564940a2-ccd4-48c2-8c3b-1346045bd8dc`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = InvoiceModule;
|
|
@@ -1,108 +1,149 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
class UniversalModule {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of Nexvia class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: page, limit.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @returns {object} Universal Request Response.
|
|
19
|
+
*/
|
|
20
|
+
async request({ url, method, qs = {}, body = {} }) {
|
|
21
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
22
|
+
|
|
23
|
+
if (!validateIsEmpty.valid) {
|
|
24
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return await this.module.makeRequest(
|
|
28
|
+
"POST",
|
|
29
|
+
`${this.module.apiURL}/zintegrations/action/33b775b3-0ef4-4ed7-bc16-5a3396f26a7a`,
|
|
30
|
+
{
|
|
31
|
+
mappable_parameters: {
|
|
32
|
+
url: {
|
|
33
|
+
value: url,
|
|
34
|
+
},
|
|
35
|
+
method: {
|
|
36
|
+
value: method,
|
|
37
|
+
},
|
|
38
|
+
qs: {
|
|
39
|
+
isMap: true,
|
|
40
|
+
value: JSON.stringify(qs),
|
|
41
|
+
},
|
|
42
|
+
body: {
|
|
43
|
+
isMap: true,
|
|
44
|
+
value: JSON.stringify(body),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Universal List By URL and Method.
|
|
53
|
+
* @param {string} url URL of listed data.
|
|
54
|
+
* @param {string} method Method of listed data.
|
|
55
|
+
* @param {object} qs Some available filters inside: page, limit.
|
|
56
|
+
* @param {object} body Some available data inside.
|
|
57
|
+
* @returns {object} Universal List Response.
|
|
58
|
+
*/
|
|
59
|
+
async list({ url, method, qs = {}, body = {} }) {
|
|
60
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
61
|
+
|
|
62
|
+
if (!validateIsEmpty.valid) {
|
|
63
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!qs.page) {
|
|
67
|
+
qs.page = 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!qs.limit) {
|
|
71
|
+
qs.limit = 100;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return await this.request({ url, method, qs, body });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
79
|
+
* @param {string} url URL of listed data.
|
|
80
|
+
* @param {string} method Method of listed data.
|
|
81
|
+
* @param {object} qs Some available filters inside: page, limit.
|
|
82
|
+
* @param {object} body Some available data inside.
|
|
83
|
+
* @returns {object} Auto Pagination responses.
|
|
84
|
+
*/
|
|
85
|
+
async *autoPaginationList({ url, method, qs = {}, body = {} }) {
|
|
86
|
+
if (!qs.page) {
|
|
87
|
+
qs.page = 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!qs.limit) {
|
|
91
|
+
qs.limit = 100;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let response = await this.list({ url, method, qs, body });
|
|
95
|
+
let currentPageCount = response?.data?.length;
|
|
96
|
+
|
|
97
|
+
yield response;
|
|
98
|
+
|
|
99
|
+
if (currentPageCount && currentPageCount === qs.limit) {
|
|
100
|
+
while (currentPageCount === qs.limit) {
|
|
101
|
+
qs.page = qs.page + 1;
|
|
102
|
+
|
|
103
|
+
response = await this.list({ url, method, qs, body });
|
|
104
|
+
currentPageCount = response?.data?.length;
|
|
105
|
+
|
|
106
|
+
yield response;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Attachment Request By URL and Method.
|
|
113
|
+
* @param {string} url URL of request.
|
|
114
|
+
* @param {string} attachment URL of the attachment.
|
|
115
|
+
* @returns {object} Universal Request Response.
|
|
116
|
+
*/
|
|
117
|
+
async attach({ url, method, qs = {}, body = {} }) {
|
|
118
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, attachment });
|
|
119
|
+
|
|
120
|
+
if (!validateIsEmpty.valid) {
|
|
121
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return await this.module.makeRequest(
|
|
125
|
+
"POST",
|
|
126
|
+
`${this.module.apiURL}/zintegrations/action/62697e94-2963-4d3f-8729-036897b92878`,
|
|
127
|
+
{
|
|
128
|
+
mappable_parameters: {
|
|
129
|
+
url: {
|
|
130
|
+
value: url,
|
|
131
|
+
},
|
|
132
|
+
method: {
|
|
133
|
+
value: method,
|
|
134
|
+
},
|
|
135
|
+
qs: {
|
|
136
|
+
isMap: true,
|
|
137
|
+
value: JSON.stringify(qs),
|
|
138
|
+
},
|
|
139
|
+
body: {
|
|
140
|
+
isMap: true,
|
|
141
|
+
value: JSON.stringify(body),
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|
|
106
147
|
}
|
|
107
148
|
|
|
108
|
-
module.exports = UniversalModule
|
|
149
|
+
module.exports = UniversalModule;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: offset, limit.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
|
+
* @returns {object} Universal Request Response.
|
|
20
|
+
*/
|
|
21
|
+
async request({ command = "fetch_sql", qs = {}, body = {} }) {
|
|
22
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
|
+
|
|
24
|
+
if (!validateIsEmpty.valid) {
|
|
25
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await this.module.makeRequest(
|
|
29
|
+
"POST",
|
|
30
|
+
`${this.module.apiURL}/zintegrations/action/33067090-da86-4a7e-8ba1-b07107dc5175`,
|
|
31
|
+
{
|
|
32
|
+
mappable_parameters: {
|
|
33
|
+
command: {
|
|
34
|
+
value: command,
|
|
35
|
+
},
|
|
36
|
+
qs: {
|
|
37
|
+
isMap: true,
|
|
38
|
+
value: JSON.stringify(qs),
|
|
39
|
+
},
|
|
40
|
+
body: {
|
|
41
|
+
isMap: true,
|
|
42
|
+
value: JSON.stringify(body),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
_debug: true,
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Universal List By URL.
|
|
54
|
+
* @param {number} offset Offset of listed data.
|
|
55
|
+
* @param {number} limit Limit of listed data.
|
|
56
|
+
* @param {string} query Query of listed data.
|
|
57
|
+
* @returns {object} Universal List Response.
|
|
58
|
+
*/
|
|
59
|
+
async list({ offset = 0, limit = 100, query = "" }) {
|
|
60
|
+
return await this.request({
|
|
61
|
+
body: {
|
|
62
|
+
query,
|
|
63
|
+
offset,
|
|
64
|
+
limit,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = UniversalModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class CreditModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/ec88e5d9-bf85-4592-ab93-e22c83b9e90c`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = CreditModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class ExpenseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/a6bb0b50-4a5c-4a65-8536-e39f807a262f`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = ExpenseModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class InvoiceModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/564940a2-ccd4-48c2-8c3b-1346045bd8dc`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = InvoiceModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class ExpenseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/ab03bd7f-cc94-48ac-8253-20ca117bcec8`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = ExpenseModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class CreditModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/0bdfd9b3-8faf-4d05-a8c7-e6bc48853a80`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = CreditModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class InvoiceModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/fac3d59c-a2d6-4fb2-8ce2-f6128fa94b28`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = InvoiceModule;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class ExpenseModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of SAP B1 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async create({ data }) {
|
|
13
|
+
const validateIsEmpty = this.module.validator.isEmpty({ body });
|
|
14
|
+
|
|
15
|
+
if (!validateIsEmpty.valid) {
|
|
16
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return await this.module.makeRequest(
|
|
20
|
+
"POST",
|
|
21
|
+
`${this.module.apiURL}/zintegrations/action/e1055c72-8f5f-4b51-9cd0-aa439030e4cc`,
|
|
22
|
+
{
|
|
23
|
+
mappable_parameters: {
|
|
24
|
+
body: {
|
|
25
|
+
isMap: true,
|
|
26
|
+
value: JSON.stringify(body),
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
_debug: true,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = ExpenseModule;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of X3 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Universal Request By URL and Method.
|
|
14
|
+
* @param {string} url URL of request.
|
|
15
|
+
* @param {string} method Method of request.
|
|
16
|
+
* @param {object} qs Some available filters inside: offset, limit.
|
|
17
|
+
* @param {object} body Some available data inside.
|
|
18
|
+
* @param {boolean} appendLimit Append limit & offset to URL.
|
|
19
|
+
* @returns {object} Universal Request Response.
|
|
20
|
+
*/
|
|
21
|
+
async request({ url, method, qs = {}, body = {}, appendLimit = false }) {
|
|
22
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
23
|
+
|
|
24
|
+
if (!validateIsEmpty.valid) {
|
|
25
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return await this.module.makeRequest(
|
|
29
|
+
"POST",
|
|
30
|
+
`${this.module.apiURL}/zintegrations/action/ec895735-fab1-4212-8968-0b40d9a71240`,
|
|
31
|
+
{
|
|
32
|
+
mappable_parameters: {
|
|
33
|
+
url: {
|
|
34
|
+
value: url,
|
|
35
|
+
},
|
|
36
|
+
method: {
|
|
37
|
+
value: method,
|
|
38
|
+
},
|
|
39
|
+
qs: {
|
|
40
|
+
isMap: true,
|
|
41
|
+
value: JSON.stringify(qs),
|
|
42
|
+
},
|
|
43
|
+
body: {
|
|
44
|
+
isMap: true,
|
|
45
|
+
value: JSON.stringify(body),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
_debug: true,
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Universal List By URL.
|
|
57
|
+
* @param {number} offset Offset of listed data.
|
|
58
|
+
* @param {number} limit Limit of listed data.
|
|
59
|
+
* @param {string} query Query of listed data.
|
|
60
|
+
* @returns {object} Universal List Response.
|
|
61
|
+
*/
|
|
62
|
+
async list({ after = "", limit = 100, query = "", variables = {} }) {
|
|
63
|
+
return await this.request({
|
|
64
|
+
method: "POST",
|
|
65
|
+
body: {
|
|
66
|
+
query,
|
|
67
|
+
variables: {
|
|
68
|
+
after,
|
|
69
|
+
first: limit,
|
|
70
|
+
...variables,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Universal Auto Pagination Listing.
|
|
78
|
+
* @param {number} offset Offset of listed data.
|
|
79
|
+
* @param {number} limit Limit of listed data.
|
|
80
|
+
* @param {string} query Query of listed data.
|
|
81
|
+
* @returns {object} Auto Pagination responses.
|
|
82
|
+
*/
|
|
83
|
+
async *autoPaginationList({
|
|
84
|
+
after = "",
|
|
85
|
+
limit = 100,
|
|
86
|
+
query = "",
|
|
87
|
+
variables = {},
|
|
88
|
+
pageInfoPath = "",
|
|
89
|
+
}) {
|
|
90
|
+
let response = await this.list({ after, limit, query, variables });
|
|
91
|
+
|
|
92
|
+
yield response;
|
|
93
|
+
|
|
94
|
+
pageInfo = _.get(response, pageInfoPath);
|
|
95
|
+
if (pageInfo.hasNextPage) {
|
|
96
|
+
while (pageInfo.hasNextPage) {
|
|
97
|
+
after = pageInfo.endCursor;
|
|
98
|
+
|
|
99
|
+
response = await this.list({ after, limit, query, variables });
|
|
100
|
+
|
|
101
|
+
yield response;
|
|
102
|
+
|
|
103
|
+
pageInfo = _.get(response, pageInfoPath);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
module.exports = UniversalModule;
|
package/src/utils/config.js
CHANGED
|
@@ -15,5 +15,9 @@ module.exports = {
|
|
|
15
15
|
sybiz: "ead57add-301e-4b29-881b-1bc331c101a5",
|
|
16
16
|
xero: "71648f29-7867-40d8-ac68-651b53cb3c49",
|
|
17
17
|
jobready: "14d16371-3e56-40c8-9efa-8578a8f334fc",
|
|
18
|
+
x3: "1e74dfc4-0067-4295-880c-bbdf425ef9e0",
|
|
19
|
+
sapb1: "de1ee5bd-d3ec-41cf-83f9-dcd2f51fcccd",
|
|
20
|
+
gp: "c1fb133b-73f6-4b85-9362-59c7c2d9017f",
|
|
21
|
+
edi: "6b3a284f-ca06-435c-bdf1-ad59c577a6a7",
|
|
18
22
|
},
|
|
19
23
|
};
|
package/src/utils/formHelper.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
class ResponseHandler {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Handle success response.
|
|
6
|
+
* @param {any} data Data to return.
|
|
7
|
+
* @returns {object} Response Data.
|
|
8
|
+
*/
|
|
9
|
+
success(data) {
|
|
10
|
+
return { success: true, data };
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Handle error response.
|
|
15
|
+
* @param {array} errors Errors to return.
|
|
16
|
+
* @returns {object} Response Data.
|
|
17
|
+
*/
|
|
18
|
+
error(errors) {
|
|
19
|
+
return {
|
|
20
|
+
success: false,
|
|
21
|
+
error: {
|
|
22
|
+
messages: errors,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
module.exports = ResponseHandler
|
|
28
|
+
module.exports = ResponseHandler;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
|
|
5
|
+
class ResponseHelper {
|
|
6
|
+
constructor(apiInstance, apiUrl, logger, teamUUID, data) {
|
|
7
|
+
this.apiInstance = apiInstance
|
|
8
|
+
this.apiUrl = apiUrl
|
|
9
|
+
|
|
10
|
+
this.logger = logger
|
|
11
|
+
this.teamUUID = teamUUID
|
|
12
|
+
|
|
13
|
+
this.responseData = data
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async load(uuid, failCallback) {
|
|
17
|
+
failCallback = failCallback || ((data) => this.defaultFailCallback(data))
|
|
18
|
+
|
|
19
|
+
this.logger.info('Response UUID', uuid)
|
|
20
|
+
|
|
21
|
+
return await this.get(uuid, failCallback)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async get(uuid, failCallback) {
|
|
25
|
+
failCallback = failCallback || ((data) => this.defaultFailCallback(data))
|
|
26
|
+
|
|
27
|
+
if (!uuid) {
|
|
28
|
+
return failCallback({ uuid })
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const fetchedResponse = await this.apiInstance.get(`${this.apiUrl}/response/${uuid}`, {}, {
|
|
32
|
+
'x-team': this.teamUUID
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
this.logger.debug('Fetched Response', fetchedResponse)
|
|
36
|
+
|
|
37
|
+
if (fetchedResponse && fetchedResponse.data) {
|
|
38
|
+
const data = fetchedResponse.data?.data || null
|
|
39
|
+
|
|
40
|
+
if (data) {
|
|
41
|
+
return new ResponseHelper(this.apiInstance, this.apiUrl, this.logger, this.teamUUID, data)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return failCallback({ uuid })
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
data() {
|
|
49
|
+
return this.responseData
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
defaultFailCallback(data) {
|
|
53
|
+
this.logger.error('Unable to find Response', data)
|
|
54
|
+
throw new Error('Unable to find Response')
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = ResponseHelper
|