zudello-integration-sdk 1.0.50 → 1.0.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudello-integration-sdk",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "description": "Zudello Integrations SDK",
5
5
  "main": "./src/index.js",
6
6
  "repository": {
@@ -22,4 +22,4 @@
22
22
  "standard": "^17.1.0"
23
23
  },
24
24
  "license": "MIT"
25
- }
25
+ }
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,
@@ -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
- * 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
- }
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/${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;
@@ -35,7 +35,7 @@ class PoDocumentModule {
35
35
  * @returns {object} Create PO Document Response.
36
36
  */
37
37
  async update ({ ...fields }) {
38
- return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/2355af76-4571-4090-8111-a38d750bd6ab`, {
38
+ return await this.module.makeRequest('POST', `${this.module.apiURL}/zintegrations/action/1b78eefa-074e-429b-9eb4-6940b29c1a97`, {
39
39
  mappable_parameters: {
40
40
  debug: {
41
41
  value: false