zudello-integration-sdk 1.0.65 → 1.0.67
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 +2 -0
- package/src/sdk/Airwallex.js +31 -0
- package/src/sdk/submodules/airwallex/Universal.js +120 -0
- package/src/sdk/submodules/zudello/Journal.js +1 -1
- package/src/sdk/submodules/zudello/Payment.js +63 -0
- package/src/sdk/submodules/zudello/Refund.js +63 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -22,6 +22,7 @@ const JobReadySDK = require('./sdk/JobReady')
|
|
|
22
22
|
const JobReadyLiveSDK = require('./sdk/JobReadyLive')
|
|
23
23
|
const InspHireSDK = require('./sdk/InspHire')
|
|
24
24
|
const S4SDK = require('./sdk/S4')
|
|
25
|
+
const AirwallexSDK = require('./sdk/Airwallex')
|
|
25
26
|
const X3SDK = require('./sdk/X3')
|
|
26
27
|
const SAPB1SDK = require('./sdk/SAPB1')
|
|
27
28
|
const GPSDK = require('./sdk/GP')
|
|
@@ -99,6 +100,7 @@ module.exports = {
|
|
|
99
100
|
JobReadyLiveSDK,
|
|
100
101
|
InspHireSDK,
|
|
101
102
|
S4SDK,
|
|
103
|
+
AirwallexSDK,
|
|
102
104
|
Logger,
|
|
103
105
|
Metadata,
|
|
104
106
|
Message,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const BaseSDK = require('./Base')
|
|
4
|
+
const UniversalModule = require('./submodules/airwallex/Universal')
|
|
5
|
+
|
|
6
|
+
class AirwallexSDK 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: 'airwallex',
|
|
20
|
+
integrationName: 'Airwallex',
|
|
21
|
+
loggerClass
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Create submodule instances.
|
|
26
|
+
*/
|
|
27
|
+
this.universal = new UniversalModule(this)
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = AirwallexSDK
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class UniversalModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of Airwallex 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
|
+
"POST",
|
|
29
|
+
`${this.module.apiURL}/zintegrations/action/42819921-298d-4bb8-838d-1aff425aad83`,
|
|
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_num, page_size.
|
|
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_num && qs.page_num !== 0) {
|
|
67
|
+
qs.page_num = 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (!qs.page_size) {
|
|
71
|
+
qs.page_size = 200;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return await this.request({ url, method, qs, body });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Universal Auto Pagination Listing By URL and Method (Airwallex optimized).
|
|
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_num, page_size.
|
|
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_num && qs.page_num !== 0) {
|
|
87
|
+
qs.page_num = 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!qs.page_size) {
|
|
91
|
+
qs.page_size = 200;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
let response = await this.list({ url, method, qs, body });
|
|
95
|
+
|
|
96
|
+
yield response;
|
|
97
|
+
|
|
98
|
+
let hasMore =
|
|
99
|
+
response?.has_more ||
|
|
100
|
+
response?.data?.has_more ||
|
|
101
|
+
response?.response?.has_more ||
|
|
102
|
+
false;
|
|
103
|
+
|
|
104
|
+
while (hasMore) {
|
|
105
|
+
qs.page_num = qs.page_num + 1;
|
|
106
|
+
|
|
107
|
+
response = await this.list({ url, method, qs, body });
|
|
108
|
+
|
|
109
|
+
yield response;
|
|
110
|
+
|
|
111
|
+
hasMore =
|
|
112
|
+
response?.has_more ||
|
|
113
|
+
response?.data?.has_more ||
|
|
114
|
+
response?.response?.has_more ||
|
|
115
|
+
false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = UniversalModule;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class PaymentModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of ZudelloV3 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
|
|
11
|
+
this.staticFields = {
|
|
12
|
+
model: 'Transaction',
|
|
13
|
+
module: 'EXPENSES',
|
|
14
|
+
submodule: 'PAYMENT',
|
|
15
|
+
documentType: 'PAYMENT',
|
|
16
|
+
enrich: false,
|
|
17
|
+
extractedEvent: false,
|
|
18
|
+
update: true,
|
|
19
|
+
create: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async fetch ({ uuid, fetchDetails = true, simplified = true }) {
|
|
24
|
+
const validateIsEmpty = this.module.validator.isEmpty({ uuid })
|
|
25
|
+
|
|
26
|
+
if (!validateIsEmpty.valid) {
|
|
27
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.module.fetch({
|
|
31
|
+
model: this.staticFields.model,
|
|
32
|
+
uuid,
|
|
33
|
+
fetchDetails,
|
|
34
|
+
simplified
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async updateOrCreate ({ data, clearNulls = true, simplified = false, submit = false, updateStatus = false }) {
|
|
39
|
+
const validateIsEmpty = this.module.validator.isEmpty({ data })
|
|
40
|
+
|
|
41
|
+
if (!validateIsEmpty.valid) {
|
|
42
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.module.logger.log(`[UPDATE OR CREATE]: ZudelloV3 [model - ${this.staticFields.model}]`)
|
|
46
|
+
this.module.logger.log('[PAGE DATA]:')
|
|
47
|
+
this.module.logger.log(data)
|
|
48
|
+
|
|
49
|
+
data = this.module.mapUpdateOrCreateData({
|
|
50
|
+
data,
|
|
51
|
+
staticFields: this.staticFields,
|
|
52
|
+
submit,
|
|
53
|
+
updateStatus
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
this.module.logger.log('[MAPPED PAGE DATA]:')
|
|
57
|
+
this.module.logger.log(data)
|
|
58
|
+
|
|
59
|
+
return await this.module.updateOrCreate({ data, clearNulls, simplified })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = PaymentModule
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
class RefundModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of ZudelloV3 class.
|
|
7
|
+
*/
|
|
8
|
+
constructor (parentModule) {
|
|
9
|
+
this.module = parentModule
|
|
10
|
+
|
|
11
|
+
this.staticFields = {
|
|
12
|
+
model: 'Transaction',
|
|
13
|
+
module: 'EXPENSES',
|
|
14
|
+
submodule: 'REFUND',
|
|
15
|
+
documentType: 'REFUND',
|
|
16
|
+
enrich: false,
|
|
17
|
+
extractedEvent: false,
|
|
18
|
+
update: true,
|
|
19
|
+
create: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async fetch ({ uuid, fetchDetails = true, simplified = true }) {
|
|
24
|
+
const validateIsEmpty = this.module.validator.isEmpty({ uuid })
|
|
25
|
+
|
|
26
|
+
if (!validateIsEmpty.valid) {
|
|
27
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return await this.module.fetch({
|
|
31
|
+
model: this.staticFields.model,
|
|
32
|
+
uuid,
|
|
33
|
+
fetchDetails,
|
|
34
|
+
simplified
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async updateOrCreate ({ data, clearNulls = true, simplified = false, submit = false, updateStatus = false }) {
|
|
39
|
+
const validateIsEmpty = this.module.validator.isEmpty({ data })
|
|
40
|
+
|
|
41
|
+
if (!validateIsEmpty.valid) {
|
|
42
|
+
return this.module.responseHandler.error(validateIsEmpty.errors)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.module.logger.log(`[UPDATE OR CREATE]: ZudelloV3 [model - ${this.staticFields.model}]`)
|
|
46
|
+
this.module.logger.log('[PAGE DATA]:')
|
|
47
|
+
this.module.logger.log(data)
|
|
48
|
+
|
|
49
|
+
data = this.module.mapUpdateOrCreateData({
|
|
50
|
+
data,
|
|
51
|
+
staticFields: this.staticFields,
|
|
52
|
+
submit,
|
|
53
|
+
updateStatus
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
this.module.logger.log('[MAPPED PAGE DATA]:')
|
|
57
|
+
this.module.logger.log(data)
|
|
58
|
+
|
|
59
|
+
return await this.module.updateOrCreate({ data, clearNulls, simplified })
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = RefundModule
|