zudello-integration-sdk 1.0.51 → 1.0.53
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 +2 -2
- package/src/index.js +2 -0
- package/src/sdk/Zudello.js +204 -204
- package/src/sdk/ZudelloStore.js +60 -0
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
const Auth = require('./sdk/Auth')
|
|
4
4
|
const ZudelloSDK = require('./sdk/Zudello')
|
|
5
5
|
const ZudelloAuthSDK = require('./sdk/ZudelloAuth')
|
|
6
|
+
const ZudelloStoreSDK = require('./sdk/ZudelloStore')
|
|
6
7
|
const NetsuiteSDK = require('./sdk/Netsuite')
|
|
7
8
|
const NetsuiteSoapSDK = require('./sdk/NetsuiteSOAP')
|
|
8
9
|
const IntacctSDK = require('./sdk/Intacct')
|
|
@@ -67,6 +68,7 @@ module.exports = {
|
|
|
67
68
|
EDIBucket,
|
|
68
69
|
ZudelloSDK,
|
|
69
70
|
ZudelloAuthSDK,
|
|
71
|
+
ZudelloStoreSDK,
|
|
70
72
|
NetsuiteSDK,
|
|
71
73
|
NetsuiteSoapSDK,
|
|
72
74
|
IntacctSDK,
|
package/src/sdk/Zudello.js
CHANGED
|
@@ -45,210 +45,210 @@ const UniversalModule = require("./submodules/zudello/Universal");
|
|
|
45
45
|
const { default: axios } = require("axios");
|
|
46
46
|
|
|
47
47
|
class ZudelloSDK extends BaseSDK {
|
|
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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Constructor.
|
|
50
|
+
* @param {class} auth Auth class object with authorized api instance.
|
|
51
|
+
* @param {string} connectionUUID The UUID of the Connection we're working on.
|
|
52
|
+
*/
|
|
53
|
+
constructor(auth, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
54
|
+
super({
|
|
55
|
+
auth,
|
|
56
|
+
organizationUUID,
|
|
57
|
+
apiURL,
|
|
58
|
+
apiVersion,
|
|
59
|
+
isExternal: false,
|
|
60
|
+
integrationName: "Zudello",
|
|
61
|
+
loggerClass,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.staticFieldsForUpdate = {
|
|
65
|
+
enrich: false,
|
|
66
|
+
extractedEvent: false,
|
|
67
|
+
update: true,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Create submodule instances.
|
|
72
|
+
*/
|
|
73
|
+
this.account = new AccountModule(this);
|
|
74
|
+
this.accountGroup = new AccountGroupModule(this);
|
|
75
|
+
this.accountingPeriod = new AccountingPeriodModule(this);
|
|
76
|
+
this.amortizationSchedule = new AmortizationScheduleModule(this);
|
|
77
|
+
this.batch = new BatchModule(this);
|
|
78
|
+
this.bin = new BinModule(this);
|
|
79
|
+
this.costCentre = new CostCentreModule(this);
|
|
80
|
+
this.costType = new CostTypeModule(this);
|
|
81
|
+
this.customer = new CustomerModule(this);
|
|
82
|
+
this.customerCategory = new CustomerCategoryModule(this);
|
|
83
|
+
this.customerGroup = new CustomerGroupModule(this);
|
|
84
|
+
this.currency = new CurrencyModule(this);
|
|
85
|
+
this.department = new DepartmentModule(this);
|
|
86
|
+
this.employee = new EmployeeModule(this);
|
|
87
|
+
this.expenseCategory = new ExpenseCategoryModule(this);
|
|
88
|
+
this.subsidiary = new SubsidiaryModule(this);
|
|
89
|
+
this.location = new LocationModule(this);
|
|
90
|
+
this.mileageRate = new MileageRateModule(this);
|
|
91
|
+
this.item = new ItemModule(this);
|
|
92
|
+
this.itemCategory = new ItemCategoryModule(this);
|
|
93
|
+
this.itemGroup = new ItemGroupModule(this);
|
|
94
|
+
this.purchaseOrder = new PurchaseOrderModule(this);
|
|
95
|
+
this.paymentTerm = new PaymentTermModule(this);
|
|
96
|
+
this.paymentMethod = new PaymentMethodModule(this);
|
|
97
|
+
this.project = new ProjectModule(this);
|
|
98
|
+
this.projectGroup = new ProjectGroupModule(this);
|
|
99
|
+
this.projectTask = new ProjectTaskModule(this);
|
|
100
|
+
this.projectType = new ProjectTypeModule(this);
|
|
101
|
+
this.supplierCategory = new SupplierCategoryModule(this);
|
|
102
|
+
this.supplierGroup = new SupplierGroupModule(this);
|
|
103
|
+
this.teamAddress = new TeamAddressModule(this);
|
|
104
|
+
this.warehouse = new WarehouseModule(this);
|
|
105
|
+
this.uom = new UomModule(this);
|
|
106
|
+
this.zone = new ZoneModule(this);
|
|
107
|
+
this.supplier = new SupplierModule(this);
|
|
108
|
+
this.fixedAsset = new FixedAssetModule(this);
|
|
109
|
+
this.universal = new UniversalModule(this);
|
|
110
|
+
this.tax = {
|
|
111
|
+
rate: new TaxRateModule(this),
|
|
112
|
+
solution: new TaxSolutionModule(this),
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async search({ model, select, filter = {}, orderBy = ["-created_at"], offset = 0, limit = 100 }) {
|
|
117
|
+
const validateIsEmpty = this.validator.isEmpty({ model, select });
|
|
118
|
+
|
|
119
|
+
if (!validateIsEmpty.valid) {
|
|
120
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return await this.makeRequest(
|
|
124
|
+
"POST",
|
|
125
|
+
`${this.apiURL}/team-data/${this.apiVersion}/resources/search`,
|
|
126
|
+
{
|
|
127
|
+
model,
|
|
128
|
+
offset,
|
|
129
|
+
limit,
|
|
130
|
+
select,
|
|
131
|
+
order_by: orderBy,
|
|
132
|
+
filter,
|
|
133
|
+
exclude: {},
|
|
134
|
+
annotate: {},
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async fetch({ model, uuid, fetchDetails = true, simplified = true }) {
|
|
140
|
+
const validateIsEmpty = this.validator.isEmpty({ model, uuid });
|
|
141
|
+
|
|
142
|
+
if (!validateIsEmpty.valid) {
|
|
143
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return await this.makeRequest("GET", `${this.apiURL}/team-data/${this.apiVersion}/resources`, {
|
|
147
|
+
model,
|
|
148
|
+
uuid,
|
|
149
|
+
fetch_details: fetchDetails,
|
|
150
|
+
simplified,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async getFileAttachment({ uuid, type }) {
|
|
155
|
+
const validateIsEmpty = this.validator.isEmpty({ uuid, type });
|
|
156
|
+
|
|
157
|
+
if (!validateIsEmpty.valid) {
|
|
158
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return await this.makeRequest(
|
|
162
|
+
"GET",
|
|
163
|
+
`${this.apiURL}/team-data/${this.apiVersion}/files/download/Transaction/${uuid}/${type}`,
|
|
164
|
+
{},
|
|
165
|
+
{},
|
|
166
|
+
true
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async getFileContent({ uuid, type }) {
|
|
171
|
+
const validateIsEmpty = this.validator.isEmpty({ uuid, type });
|
|
172
|
+
|
|
173
|
+
if (!validateIsEmpty.valid) {
|
|
174
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const response = await this.getFileAttachment({ uuid, type });
|
|
178
|
+
|
|
179
|
+
return await axios.get(response.data);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async update({
|
|
183
|
+
model,
|
|
184
|
+
module = null,
|
|
185
|
+
submodule = null,
|
|
186
|
+
data,
|
|
187
|
+
clearNulls = true,
|
|
188
|
+
simplified = false,
|
|
189
|
+
submit = false,
|
|
190
|
+
updateStatus = false,
|
|
191
|
+
enrich = false,
|
|
192
|
+
}) {
|
|
193
|
+
const validateIsEmpty = this.validator.isEmpty({ model, data });
|
|
194
|
+
|
|
195
|
+
if (!validateIsEmpty.valid) {
|
|
196
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
data = this.mapUpdateOrCreateData({
|
|
200
|
+
data: [data],
|
|
201
|
+
staticFields: {
|
|
202
|
+
...this.staticFieldsForUpdate,
|
|
203
|
+
enrich,
|
|
204
|
+
model,
|
|
205
|
+
module,
|
|
206
|
+
submodule,
|
|
207
|
+
},
|
|
208
|
+
submit,
|
|
209
|
+
updateStatus,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
return await this.updateOrCreate({ data, clearNulls, simplified });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async updateOrCreate({ data, clearNulls = true, simplified = false }) {
|
|
216
|
+
const validateIsEmpty = this.validator.isEmpty({ data });
|
|
217
|
+
|
|
218
|
+
if (!validateIsEmpty.valid) {
|
|
219
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return await this.makeRequest(
|
|
223
|
+
"POST",
|
|
224
|
+
`${this.apiURL}/team-data/${this.apiVersion}/resources/update_or_create`,
|
|
225
|
+
{
|
|
226
|
+
simplified,
|
|
227
|
+
clear_nulls: clearNulls,
|
|
228
|
+
data,
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
mapUpdateOrCreateData({ data = [], staticFields = {}, submit = false, updateStatus = false }) {
|
|
234
|
+
return _.map(data, (item) => {
|
|
235
|
+
return {
|
|
236
|
+
data: {
|
|
237
|
+
module: staticFields.module,
|
|
238
|
+
submodule: staticFields.submodule,
|
|
239
|
+
document_type: staticFields.documentType,
|
|
240
|
+
...item,
|
|
241
|
+
},
|
|
242
|
+
model: staticFields.model,
|
|
243
|
+
submit: submit,
|
|
244
|
+
enrich: staticFields.enrich,
|
|
245
|
+
extracted_event: staticFields.extractedEvent,
|
|
246
|
+
update_status: updateStatus,
|
|
247
|
+
update: staticFields.update,
|
|
248
|
+
create: staticFields.create,
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
module.exports = ZudelloSDK;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash')
|
|
4
|
+
const BaseSDK = require('./Base')
|
|
5
|
+
|
|
6
|
+
class ZudelloStoreSDK extends BaseSDK {
|
|
7
|
+
constructor(auth, organizationUUID, apiURL, apiVersion, loggerClass = null) {
|
|
8
|
+
super({
|
|
9
|
+
auth,
|
|
10
|
+
organizationUUID,
|
|
11
|
+
apiURL,
|
|
12
|
+
apiVersion,
|
|
13
|
+
isExternal: false,
|
|
14
|
+
integrationName: 'ZudelloStore',
|
|
15
|
+
loggerClass,
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
this.staticFieldsForUpdate = {
|
|
19
|
+
enrich: false,
|
|
20
|
+
extractedEvent: false,
|
|
21
|
+
update: true,
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async fetch({ uuid, resource_type = null }) {
|
|
26
|
+
const validateIsEmpty = this.validator.isEmpty({ uuid });
|
|
27
|
+
|
|
28
|
+
if (!validateIsEmpty.valid) {
|
|
29
|
+
return this.responseHandler.error(validateIsEmpty.errors);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return await this.makeRequest(
|
|
33
|
+
"GET",
|
|
34
|
+
`${this.apiURL}/general-store/api/${this.apiVersion}/resources/${uuid}${resource_type ? `?resource_type=${resource_type}` : ""}`,
|
|
35
|
+
{}
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
mapUpdateOrCreateData({ data = [], staticFields = {}, submit = false, updateStatus = false }) {
|
|
40
|
+
return _.map(data, (item) => {
|
|
41
|
+
return {
|
|
42
|
+
data: {
|
|
43
|
+
module: staticFields.module,
|
|
44
|
+
submodule: staticFields.submodule,
|
|
45
|
+
document_type: staticFields.documentType,
|
|
46
|
+
...item,
|
|
47
|
+
},
|
|
48
|
+
model: staticFields.model,
|
|
49
|
+
submit: submit,
|
|
50
|
+
enrich: staticFields.enrich,
|
|
51
|
+
extracted_event: staticFields.extractedEvent,
|
|
52
|
+
update_status: updateStatus,
|
|
53
|
+
update: staticFields.update,
|
|
54
|
+
create: staticFields.create,
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = ZudelloStoreSDK;
|