zudello-integration-sdk 1.0.42 → 1.0.44
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/NetsuiteSOAP.js +85 -79
- package/src/sdk/ZudelloAuth.js +138 -0
- package/src/sdk/submodules/netsuite-soap/Attachment.js +38 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const Auth = require('./sdk/Auth')
|
|
4
4
|
const ZudelloSDK = require('./sdk/Zudello')
|
|
5
|
+
const ZudelloAuthSDK = require('./sdk/ZudelloAuth')
|
|
5
6
|
const NetsuiteSDK = require('./sdk/Netsuite')
|
|
6
7
|
const NetsuiteSoapSDK = require('./sdk/NetsuiteSOAP')
|
|
7
8
|
const IntacctSDK = require('./sdk/Intacct')
|
|
@@ -55,6 +56,7 @@ const S3Client = {
|
|
|
55
56
|
module.exports = {
|
|
56
57
|
Auth,
|
|
57
58
|
ZudelloSDK,
|
|
59
|
+
ZudelloAuthSDK,
|
|
58
60
|
NetsuiteSDK,
|
|
59
61
|
NetsuiteSoapSDK,
|
|
60
62
|
IntacctSDK,
|
package/src/sdk/NetsuiteSOAP.js
CHANGED
|
@@ -1,93 +1,99 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
const _ = require(
|
|
3
|
+
const _ = require("lodash");
|
|
4
4
|
|
|
5
|
-
const BaseSDK = require(
|
|
6
|
-
const VendorBillModule = require(
|
|
7
|
-
const VendorCreditModule = require(
|
|
8
|
-
const UniversalModule = require(
|
|
9
|
-
const UniversalTransactionModule = require(
|
|
10
|
-
const PurchaseOrderModule = require(
|
|
11
|
-
const ReceiptModule = require(
|
|
5
|
+
const BaseSDK = require("./Base");
|
|
6
|
+
const VendorBillModule = require("./submodules/netsuite-soap/VendorBill");
|
|
7
|
+
const VendorCreditModule = require("./submodules/netsuite-soap/VendorCredit");
|
|
8
|
+
const UniversalModule = require("./submodules/netsuite-soap/Universal");
|
|
9
|
+
const UniversalTransactionModule = require("./submodules/netsuite-soap/UniversalTransaction");
|
|
10
|
+
const PurchaseOrderModule = require("./submodules/netsuite-soap/PurchaseOrder");
|
|
11
|
+
const ReceiptModule = require("./submodules/netsuite-soap/Receipt");
|
|
12
|
+
const AttachmentModule = require("./submodules/netsuite-soap/Attachment");
|
|
12
13
|
|
|
13
14
|
class NetsuiteSoapSDK extends BaseSDK {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Constructor.
|
|
17
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
18
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
19
|
+
*/
|
|
20
|
+
constructor(auth, connectionUUID, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
21
|
+
super({
|
|
22
|
+
auth,
|
|
23
|
+
connectionUUID,
|
|
24
|
+
organizationUUID,
|
|
25
|
+
apiURL,
|
|
26
|
+
apiVersion,
|
|
27
|
+
appUUIDKey: "netsuite",
|
|
28
|
+
integrationName: "NetsuiteSOAP",
|
|
29
|
+
loggerClass,
|
|
30
|
+
});
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
this.transformToTypes = ["vendorBill", "itemReceipt"];
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Create submodule instances.
|
|
36
|
+
*/
|
|
37
|
+
this.vendorBill = new VendorBillModule(this);
|
|
38
|
+
this.vendorCredit = new VendorCreditModule(this);
|
|
39
|
+
this.universal = new UniversalModule(this);
|
|
40
|
+
this.universalTransaction = new UniversalTransactionModule(this);
|
|
41
|
+
this.purchaseOrder = new PurchaseOrderModule(this);
|
|
42
|
+
this.receipt = new ReceiptModule(this);
|
|
43
|
+
this.attach = new AttachmentModule(this);
|
|
44
|
+
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Transaction transform FROM.
|
|
48
|
+
* @param {array} transformFrom.
|
|
49
|
+
* @param {string} transformTo.
|
|
50
|
+
* @returns {object} Transformed Response.
|
|
51
|
+
*/
|
|
52
|
+
async transform({ transformFrom, transformTo }) {
|
|
53
|
+
const validateIncludes = this.validator.includes(this.transformToTypes, transformTo);
|
|
52
54
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
if (!validateIncludes.valid) {
|
|
56
|
+
return this.responseHandler.error(validateIncludes.errors);
|
|
57
|
+
}
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
const validateIsEmpty = this.validator.isEmpty({ transformFrom });
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
if (!validateIsEmpty.valid) {
|
|
62
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
63
|
+
}
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
return await this.makeRequest(
|
|
66
|
+
"GET",
|
|
67
|
+
`${this.apiURL}/zintegrations/action/d751e693-6bbb-4c93-aff4-6561bba29f03`,
|
|
68
|
+
{
|
|
69
|
+
mappable_parameters: {
|
|
70
|
+
transformFrom: {
|
|
71
|
+
value: transformFrom,
|
|
72
|
+
},
|
|
73
|
+
transformTo: {
|
|
74
|
+
value: transformTo,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
_debug: true,
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
82
|
+
parseFilters(entries) {
|
|
83
|
+
return _.map(entries, (entry) => {
|
|
84
|
+
return {
|
|
85
|
+
field: {
|
|
86
|
+
value: entry.field,
|
|
87
|
+
},
|
|
88
|
+
operator: {
|
|
89
|
+
value: entry.operator,
|
|
90
|
+
},
|
|
91
|
+
value: {
|
|
92
|
+
value: entry.value,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
}
|
|
91
97
|
}
|
|
92
98
|
|
|
93
|
-
module.exports = NetsuiteSoapSDK
|
|
99
|
+
module.exports = NetsuiteSoapSDK;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
const BaseSDK = require('./Base')
|
|
5
|
+
|
|
6
|
+
class ZudelloAuthSDK extends BaseSDK {
|
|
7
|
+
/**
|
|
8
|
+
* Constructor.
|
|
9
|
+
*/
|
|
10
|
+
constructor(auth, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
11
|
+
super({
|
|
12
|
+
auth,
|
|
13
|
+
organizationUUID,
|
|
14
|
+
apiURL,
|
|
15
|
+
apiVersion,
|
|
16
|
+
isExternal: false,
|
|
17
|
+
integrationName: 'ZudelloAuth',
|
|
18
|
+
loggerClass,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
this.staticFieldsForUpdate = {
|
|
22
|
+
enrich: false,
|
|
23
|
+
extractedEvent: false,
|
|
24
|
+
update: true,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async search({ model, select, filter = {}, orderBy = ['-created_at'], offset = 0, limit = 100 }) {
|
|
29
|
+
const validateIsEmpty = this.validator.isEmpty({ model, select })
|
|
30
|
+
|
|
31
|
+
if (!validateIsEmpty.valid) {
|
|
32
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return await this.makeRequest(
|
|
36
|
+
'POST',
|
|
37
|
+
`${this.apiURL}/authentication/${this.apiVersion}/resources/search`,
|
|
38
|
+
{
|
|
39
|
+
model,
|
|
40
|
+
offset,
|
|
41
|
+
limit,
|
|
42
|
+
select,
|
|
43
|
+
order_by: orderBy,
|
|
44
|
+
filter,
|
|
45
|
+
exclude: {},
|
|
46
|
+
annotate: {},
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async fetch({ model, uuid, fetchDetails = true, simplified = true }) {
|
|
52
|
+
const validateIsEmpty = this.validator.isEmpty({ model, uuid })
|
|
53
|
+
|
|
54
|
+
if (!validateIsEmpty.valid) {
|
|
55
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return await this.makeRequest('GET', `${this.apiURL}/authentication/${this.apiVersion}/resources`, {
|
|
59
|
+
model,
|
|
60
|
+
uuid,
|
|
61
|
+
fetch_details: fetchDetails,
|
|
62
|
+
simplified,
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async update({
|
|
67
|
+
model,
|
|
68
|
+
module = null,
|
|
69
|
+
submodule = null,
|
|
70
|
+
data,
|
|
71
|
+
clearNulls = true,
|
|
72
|
+
simplified = false,
|
|
73
|
+
submit = false,
|
|
74
|
+
updateStatus = false,
|
|
75
|
+
enrich = false,
|
|
76
|
+
}) {
|
|
77
|
+
const validateIsEmpty = this.validator.isEmpty({ model, data })
|
|
78
|
+
|
|
79
|
+
if (!validateIsEmpty.valid) {
|
|
80
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
data = this.mapUpdateOrCreateData({
|
|
84
|
+
data: [data],
|
|
85
|
+
staticFields: {
|
|
86
|
+
...this.staticFieldsForUpdate,
|
|
87
|
+
enrich,
|
|
88
|
+
model,
|
|
89
|
+
module,
|
|
90
|
+
submodule,
|
|
91
|
+
},
|
|
92
|
+
submit,
|
|
93
|
+
updateStatus,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
return await this.updateOrCreate({ data, clearNulls, simplified })
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async updateOrCreate({ data, clearNulls = true, simplified = false }) {
|
|
100
|
+
const validateIsEmpty = this.validator.isEmpty({ data })
|
|
101
|
+
|
|
102
|
+
if (!validateIsEmpty.valid) {
|
|
103
|
+
return this.responseHandler.error(validateIsEmpty.errors)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return await this.makeRequest(
|
|
107
|
+
'POST',
|
|
108
|
+
`${this.apiURL}/authentication/${this.apiVersion}/resources/update_or_create`,
|
|
109
|
+
{
|
|
110
|
+
simplified,
|
|
111
|
+
clear_nulls: clearNulls,
|
|
112
|
+
data,
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
mapUpdateOrCreateData({ data = [], staticFields = {}, submit = false, updateStatus = false }) {
|
|
118
|
+
return _.map(data, (item) => {
|
|
119
|
+
return {
|
|
120
|
+
data: {
|
|
121
|
+
module: staticFields.module,
|
|
122
|
+
submodule: staticFields.submodule,
|
|
123
|
+
document_type: staticFields.documentType,
|
|
124
|
+
...item,
|
|
125
|
+
},
|
|
126
|
+
model: staticFields.model,
|
|
127
|
+
submit: submit,
|
|
128
|
+
enrich: staticFields.enrich,
|
|
129
|
+
extracted_event: staticFields.extractedEvent,
|
|
130
|
+
update_status: updateStatus,
|
|
131
|
+
update: staticFields.update,
|
|
132
|
+
create: staticFields.create,
|
|
133
|
+
}
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = ZudelloAuthSDK
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
class AttachmentModule {
|
|
4
|
+
/**
|
|
5
|
+
* Constructor.
|
|
6
|
+
* @param {class} parentModule Object of Netsuite class.
|
|
7
|
+
*/
|
|
8
|
+
constructor(parentModule) {
|
|
9
|
+
this.module = parentModule;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Create attachment.
|
|
14
|
+
* @param {object} body Body of attachment.
|
|
15
|
+
* @returns {object} Response.
|
|
16
|
+
*/
|
|
17
|
+
async create({ body }) {
|
|
18
|
+
return await this.module.makeRequest(
|
|
19
|
+
"POST",
|
|
20
|
+
`${this.module.apiURL}/zintegrations/action/621f658e-96e6-4e5a-b6c3-716cd5bbbcf8`,
|
|
21
|
+
{
|
|
22
|
+
mappable_parameters: {
|
|
23
|
+
debug: {
|
|
24
|
+
value: false,
|
|
25
|
+
},
|
|
26
|
+
body: {
|
|
27
|
+
value: body,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
_debug: true,
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = AttachmentModule;
|