zudello-integration-sdk 1.0.41 → 1.0.43
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/Zudello.js +3 -3
- package/src/sdk/ZudelloAuth.js +138 -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/Zudello.js
CHANGED
|
@@ -113,8 +113,8 @@ class ZudelloSDK extends BaseSDK {
|
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
async search({ model, select, filter, orderBy = ["-created_at"], offset = 0, limit = 100 }) {
|
|
117
|
-
const validateIsEmpty = this.validator.isEmpty({ model, select
|
|
116
|
+
async search({ model, select, filter = {}, orderBy = ["-created_at"], offset = 0, limit = 100 }) {
|
|
117
|
+
const validateIsEmpty = this.validator.isEmpty({ model, select });
|
|
118
118
|
|
|
119
119
|
if (!validateIsEmpty.valid) {
|
|
120
120
|
return this.responseHandler.error(validateIsEmpty.errors);
|
|
@@ -188,7 +188,7 @@ class ZudelloSDK extends BaseSDK {
|
|
|
188
188
|
simplified = false,
|
|
189
189
|
submit = false,
|
|
190
190
|
updateStatus = false,
|
|
191
|
-
enrich = false
|
|
191
|
+
enrich = false,
|
|
192
192
|
}) {
|
|
193
193
|
const validateIsEmpty = this.validator.isEmpty({ model, data });
|
|
194
194
|
|
|
@@ -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
|