zudello-integration-sdk 1.0.4 → 1.0.5
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 +21 -21
- package/src/sdk/submodules/myobAcumatica/Universal.js +138 -105
package/package.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
2
|
+
"name": "zudello-integration-sdk",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "Zudello Integrations SDK",
|
|
5
|
+
"main": "./src/index.js",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/zudello/integration-sdk.git"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@aws-sdk/client-s3": "^3.658.0",
|
|
15
|
+
"axios": "^1.6.7",
|
|
16
|
+
"dotenv": "^16.4.5",
|
|
17
|
+
"lodash": "^4.17.21",
|
|
18
|
+
"moment-timezone": "^0.5.45",
|
|
19
|
+
"perf_hooks": "^0.0.1",
|
|
20
|
+
"standard": "^17.1.0"
|
|
21
|
+
},
|
|
22
|
+
"license": "MIT"
|
|
23
23
|
}
|
|
@@ -1,109 +1,142 @@
|
|
|
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
|
-
|
|
106
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of MYOBAccumatica 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
|
+
* @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
|
+
"GET",
|
|
29
|
+
`${this.module.apiURL}/zintegrations/action/5f752f97-03f9-4893-8245-7d03cf217e37`,
|
|
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: $top, $skip, $filter, $extend.
|
|
56
|
+
* @returns {object} Universal List Response.
|
|
57
|
+
*/
|
|
58
|
+
async list({ url, method, qs = {} }) {
|
|
59
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, method });
|
|
60
|
+
|
|
61
|
+
if (!validateIsEmpty.valid) {
|
|
62
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!qs.$skip) {
|
|
66
|
+
qs.$skip = 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!qs.$top) {
|
|
70
|
+
qs.$top = 100;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return await this.request({ url, method, qs });
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Universal Auto Pagination Listing By URL and Method.
|
|
78
|
+
* @param {string} url URL of listed data.
|
|
79
|
+
* @param {string} method Method of listed data.
|
|
80
|
+
* @param {object} qs Some available filters inside: $top, $skip, $filter, $extend.
|
|
81
|
+
* @returns {object} Auto Pagination responses.
|
|
82
|
+
*/
|
|
83
|
+
async *autoPaginationList({ url, method, qs = {} }) {
|
|
84
|
+
if (!qs.$skip) {
|
|
85
|
+
qs.$skip = 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!qs.$top) {
|
|
89
|
+
qs.$top = 100;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
let response = await this.list({ url, method, qs });
|
|
93
|
+
let currentPageCount = response?.data?.length;
|
|
94
|
+
let currentOffset = qs.$skip;
|
|
95
|
+
|
|
96
|
+
yield response;
|
|
97
|
+
|
|
98
|
+
if (currentPageCount && currentPageCount === qs.$top) {
|
|
99
|
+
while (currentPageCount === qs.$top) {
|
|
100
|
+
currentOffset = currentOffset + qs.$top;
|
|
101
|
+
|
|
102
|
+
qs.$skip = currentOffset;
|
|
103
|
+
|
|
104
|
+
response = await this.list({ url, method, qs });
|
|
105
|
+
currentPageCount = response?.data?.length;
|
|
106
|
+
|
|
107
|
+
yield response;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Attachment Request By URL and Method.
|
|
114
|
+
* @param {string} url URL of request.
|
|
115
|
+
* @param {string} attachment URL of the attachment.
|
|
116
|
+
* @returns {object} Universal Request Response.
|
|
117
|
+
*/
|
|
118
|
+
async attach({ url, method, qs = {}, body = {} }) {
|
|
119
|
+
const validateIsEmpty = this.module.validator.isEmpty({ url, attachment });
|
|
120
|
+
|
|
121
|
+
if (!validateIsEmpty.valid) {
|
|
122
|
+
return this.module.responseHandler.error(validateIsEmpty.errors);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return await this.module.makeRequest(
|
|
126
|
+
"GET",
|
|
127
|
+
`${this.module.apiURL}/zintegrations/action/086840ce-942c-44ee-b2dd-ca66e5dd7b02`,
|
|
128
|
+
{
|
|
129
|
+
mappable_parameters: {
|
|
130
|
+
url: {
|
|
131
|
+
value: url,
|
|
132
|
+
},
|
|
133
|
+
attachment: {
|
|
134
|
+
value: attachment,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
107
140
|
}
|
|
108
141
|
|
|
109
|
-
module.exports = UniversalModule
|
|
142
|
+
module.exports = UniversalModule;
|