zudello-integration-sdk 1.0.15 → 1.0.16
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 +61 -59
- package/src/sdk/Xero.js +31 -0
- package/src/sdk/submodules/xero/Universal.js +135 -0
- package/src/utils/config.js +17 -16
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const Auth = require(
|
|
4
|
-
const ZudelloSDK = require(
|
|
5
|
-
const NetsuiteSDK = require(
|
|
6
|
-
const NetsuiteSoapSDK = require(
|
|
7
|
-
const IntacctSDK = require(
|
|
8
|
-
const BusinessCentralSDK = require(
|
|
9
|
-
const ZenotiSDK = require(
|
|
10
|
-
const DearSDK = require(
|
|
11
|
-
const NexviaSDK = require(
|
|
12
|
-
const FoSDK = require(
|
|
13
|
-
const RetailExpressSDK = require(
|
|
14
|
-
const MYOBAcumaticaSDK = require(
|
|
15
|
-
const SybizSDK = require(
|
|
16
|
-
const
|
|
3
|
+
const Auth = require("./sdk/Auth");
|
|
4
|
+
const ZudelloSDK = require("./sdk/Zudello");
|
|
5
|
+
const NetsuiteSDK = require("./sdk/Netsuite");
|
|
6
|
+
const NetsuiteSoapSDK = require("./sdk/NetsuiteSOAP");
|
|
7
|
+
const IntacctSDK = require("./sdk/Intacct");
|
|
8
|
+
const BusinessCentralSDK = require("./sdk/BusinessCentral");
|
|
9
|
+
const ZenotiSDK = require("./sdk/Zenoti");
|
|
10
|
+
const DearSDK = require("./sdk/Dear");
|
|
11
|
+
const NexviaSDK = require("./sdk/Nexvia");
|
|
12
|
+
const FoSDK = require("./sdk/Fo");
|
|
13
|
+
const RetailExpressSDK = require("./sdk/RetailExpress");
|
|
14
|
+
const MYOBAcumaticaSDK = require("./sdk/MYOBAcumatica");
|
|
15
|
+
const SybizSDK = require("./sdk/Sybiz");
|
|
16
|
+
const XeroSDK = require("./sdk/Xero");
|
|
17
|
+
const JobReadySDK = require("./sdk/JobReady");
|
|
17
18
|
|
|
18
|
-
const Logger = require(
|
|
19
|
-
const Metadata = require(
|
|
20
|
-
const Tags = require(
|
|
21
|
-
const Trigger = require(
|
|
22
|
-
const Properties = require(
|
|
23
|
-
const MiscHelper = require(
|
|
24
|
-
const ModelHelper = require(
|
|
25
|
-
const DatasetHelper = require(
|
|
19
|
+
const Logger = require("./utils/logger");
|
|
20
|
+
const Metadata = require("./utils/metadata");
|
|
21
|
+
const Tags = require("./utils/tags");
|
|
22
|
+
const Trigger = require("./utils/trigger");
|
|
23
|
+
const Properties = require("./utils/properties");
|
|
24
|
+
const MiscHelper = require("./utils/miscHelper");
|
|
25
|
+
const ModelHelper = require("./utils/modelHelper");
|
|
26
|
+
const DatasetHelper = require("./utils/datasetHelper");
|
|
26
27
|
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
} = require(
|
|
28
|
+
getFileContent,
|
|
29
|
+
uploadFile,
|
|
30
|
+
listFiles,
|
|
31
|
+
deleteFile,
|
|
32
|
+
deleteFiles,
|
|
33
|
+
} = require("./utils/s3Client");
|
|
33
34
|
|
|
34
35
|
const S3Client = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
getFileContent,
|
|
37
|
+
uploadFile,
|
|
38
|
+
listFiles,
|
|
39
|
+
deleteFile,
|
|
40
|
+
deleteFiles,
|
|
41
|
+
};
|
|
41
42
|
|
|
42
43
|
module.exports = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
Auth,
|
|
45
|
+
ZudelloSDK,
|
|
46
|
+
NetsuiteSDK,
|
|
47
|
+
NetsuiteSoapSDK,
|
|
48
|
+
IntacctSDK,
|
|
49
|
+
BusinessCentralSDK,
|
|
50
|
+
ZenotiSDK,
|
|
51
|
+
DearSDK,
|
|
52
|
+
NexviaSDK,
|
|
53
|
+
FoSDK,
|
|
54
|
+
RetailExpressSDK,
|
|
55
|
+
MYOBAcumaticaSDK,
|
|
56
|
+
SybizSDK,
|
|
57
|
+
XeroSDK,
|
|
58
|
+
JobReadySDK,
|
|
59
|
+
Logger,
|
|
60
|
+
Metadata,
|
|
61
|
+
Tags,
|
|
62
|
+
Trigger,
|
|
63
|
+
Properties,
|
|
64
|
+
MiscHelper,
|
|
65
|
+
ModelHelper,
|
|
66
|
+
DatasetHelper,
|
|
67
|
+
S3Client,
|
|
68
|
+
};
|
package/src/sdk/Xero.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require("./Base");
|
|
4
|
+
const UniversalModule = require("./submodules/xero/Universal");
|
|
5
|
+
|
|
6
|
+
class Xero 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: "xero",
|
|
20
|
+
integrationName: "xero",
|
|
21
|
+
loggerClass,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = Xero;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of Xero 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} header Headers to pass to the block
|
|
17
|
+
* @param {object} qs Some available filters inside: offset, limit.
|
|
18
|
+
* @param {object} body Some available data inside.
|
|
19
|
+
* @returns {object} Universal Request Response.
|
|
20
|
+
*/
|
|
21
|
+
async request({ url, method, header = {}, 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/9939030a-2670-4b80-a4fb-6ca030d26043`,
|
|
31
|
+
{
|
|
32
|
+
mappable_parameters: {
|
|
33
|
+
url: {
|
|
34
|
+
value: url,
|
|
35
|
+
},
|
|
36
|
+
method: {
|
|
37
|
+
value: method,
|
|
38
|
+
},
|
|
39
|
+
header: {
|
|
40
|
+
value: JSON.stringify(header),
|
|
41
|
+
},
|
|
42
|
+
qs: {
|
|
43
|
+
isMap: true,
|
|
44
|
+
value: JSON.stringify(qs),
|
|
45
|
+
},
|
|
46
|
+
body: {
|
|
47
|
+
isMap: true,
|
|
48
|
+
value: JSON.stringify(body),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Universal List By URL and Method.
|
|
57
|
+
* @param {string} url URL of listed data.
|
|
58
|
+
* @param {string} method Method of listed data.
|
|
59
|
+
* @param {object} header Headers to pass to the block
|
|
60
|
+
* @param {object} qs Some available filters inside: Page, Limit.
|
|
61
|
+
* @param {object} body Some available data inside.
|
|
62
|
+
* @returns {object} Universal List Response.
|
|
63
|
+
*/
|
|
64
|
+
async list({ url, method, header = {}, qs = {}, body = {} }) {
|
|
65
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
66
|
+
|
|
67
|
+
if (!validateIsEmpty.valid) {
|
|
68
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (!qs.page) {
|
|
72
|
+
qs.page = 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return await this.request({ url, method, header, qs, body });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
80
|
+
* @param {string} url URL of listed data.
|
|
81
|
+
* @param {string} method Method of listed data.
|
|
82
|
+
* @param {object} header Headers to pass to the block
|
|
83
|
+
* @param {object} qs Some available filters inside: Page, Limit.
|
|
84
|
+
* @param {object} body Some available data inside.
|
|
85
|
+
* @returns {object} Auto Pagination responses.
|
|
86
|
+
*/
|
|
87
|
+
async *autoPaginationList({ url, method, header = {}, qs = {}, body = {} }) {
|
|
88
|
+
if (!qs.page) {
|
|
89
|
+
qs.page = 1;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let response = await this.list({ url, method, header, qs, body });
|
|
93
|
+
let currentPageCount = response?.data?.length;
|
|
94
|
+
|
|
95
|
+
yield response;
|
|
96
|
+
|
|
97
|
+
if (currentPageCount && currentPageCount === qs.limit) {
|
|
98
|
+
while (currentPageCount === qs.limit) {
|
|
99
|
+
qs.page = qs.page + 1;
|
|
100
|
+
|
|
101
|
+
response = await this.list({ url, method, header, qs, body });
|
|
102
|
+
currentPageCount = response?.data?.length;
|
|
103
|
+
|
|
104
|
+
yield response;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Upload Attachment
|
|
111
|
+
* @param {object} header Headers to pass to the block
|
|
112
|
+
* @param {object} qs Some available filters inside: Page, Limit.
|
|
113
|
+
* @param {object} body Some available data inside.
|
|
114
|
+
* @returns {object} Universal List Response.
|
|
115
|
+
*/
|
|
116
|
+
async addAttachment({ header = {}, qs = {}, body = {} }) {
|
|
117
|
+
return await this.module.makeRequest(
|
|
118
|
+
"POST",
|
|
119
|
+
`${this.module.apiURL}/zintegrations/action/2e52bb12-dcee-4011-848c-b1828182fbcf`,
|
|
120
|
+
{
|
|
121
|
+
mappable_parameters: {
|
|
122
|
+
header: {
|
|
123
|
+
value: JSON.stringify(header),
|
|
124
|
+
},
|
|
125
|
+
body: {
|
|
126
|
+
isMap: true,
|
|
127
|
+
value: JSON.stringify(body),
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
module.exports = UniversalModule;
|
package/src/utils/config.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
3
|
module.exports = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
4
|
+
appUUIDs: {
|
|
5
|
+
zudello: "c698c4a5-ee07-44cb-a0e0-a3a1d0e683ec",
|
|
6
|
+
netsuite: "010d0262-fa01-43eb-9e35-1b49e131c1ba",
|
|
7
|
+
intacct: "a8bbbc60-2409-49e8-adfb-72fc79658dd6",
|
|
8
|
+
bc: "ee6f62f5-9dda-48aa-bb8d-44c8b8455472",
|
|
9
|
+
zenoti: "967a0844-6a9d-4979-a298-427259eafad8",
|
|
10
|
+
dear: "0e456359-fe0d-4b01-9662-08bba1bdce63",
|
|
11
|
+
nexvia: "5f693545-3be0-4798-bb3b-3af0b7ee2e96",
|
|
12
|
+
fo: "524e1173-6d73-42ea-9d9c-0c728c6f24ea",
|
|
13
|
+
retailExpress: "49584664-65a5-4b76-ba62-a73f7b7b3885",
|
|
14
|
+
myobAcumatica: "8fd5015c-a200-4675-9e03-2047807c5693",
|
|
15
|
+
sybiz: "ead57add-301e-4b29-881b-1bc331c101a5",
|
|
16
|
+
xero: "71648f29-7867-40d8-ac68-651b53cb3c49",
|
|
17
|
+
jobready: "14d16371-3e56-40c8-9efa-8578a8f334fc",
|
|
18
|
+
},
|
|
19
|
+
};
|