@konversi/konversi-client 1.1.5 → 1.1.6
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/README.md +47 -0
- package/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +53 -0
- package/dist/index.mjs +53 -0
- package/index.ts +52 -0
- package/package.json +1 -1
- package/test/createCustomObject.ts +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Konversi Client
|
|
2
|
+
|
|
3
|
+
## Automations Examples
|
|
4
|
+
|
|
5
|
+
### Basic Automation Example
|
|
6
|
+
```ts
|
|
7
|
+
import K from '@konversi/konversi-client';
|
|
8
|
+
|
|
9
|
+
export async function execute(input) {
|
|
10
|
+
console.log(input);
|
|
11
|
+
}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Base Objects CRUD
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import K, { Entity } from '@konversi/konversi-client';
|
|
18
|
+
|
|
19
|
+
async function execute(input) {
|
|
20
|
+
let result = await k.createObject(Entity.SALES_ORDER, {})
|
|
21
|
+
console.log(result);
|
|
22
|
+
|
|
23
|
+
result = await k.getAllObjects(Entity.SALES_ORDER)
|
|
24
|
+
console.log(result);
|
|
25
|
+
|
|
26
|
+
result = await k.updateObject(Entity.SALES_ORDER, result[0].id, { memo: 'New memo' })
|
|
27
|
+
console.log(result);
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Custom Objects CRUD
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import K, { Entity } from '@konversi/konversi-client';
|
|
35
|
+
|
|
36
|
+
async function execute(input) {
|
|
37
|
+
let createdObject = await K.createCustomObject('ticket', {numEntries: 100, amount: 500000, code: "TICKET-123456"})
|
|
38
|
+
console.log(`created object`, createdObject);
|
|
39
|
+
|
|
40
|
+
let allObjects = await K.getAllCustomObjects('ticket');
|
|
41
|
+
|
|
42
|
+
console.log(`all objects`, allObjects);
|
|
43
|
+
|
|
44
|
+
let updateResult = await K.updateCustomObject('ticket', createdObject.id, {numEntries: 200});
|
|
45
|
+
console.log(`updated object`, updateResult);
|
|
46
|
+
}
|
|
47
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -129,6 +129,11 @@ declare namespace crudEndpoints {
|
|
|
129
129
|
export { crudEndpoints_ACCOUNT as ACCOUNT, crudEndpoints_ATTENDANCE as ATTENDANCE, crudEndpoints_AUDIT_LOG as AUDIT_LOG, crudEndpoints_AUTOMATION_JOB as AUTOMATION_JOB, crudEndpoints_AUTOMATION_SCRIPT as AUTOMATION_SCRIPT, crudEndpoints_BILL_OF_MATERIALS as BILL_OF_MATERIALS, crudEndpoints_BOM_COMPONENT as BOM_COMPONENT, crudEndpoints_BOM_OPERATION as BOM_OPERATION, crudEndpoints_COMPANY_ALIAS as COMPANY_ALIAS, crudEndpoints_COMPANY_OPTION as COMPANY_OPTION, crudEndpoints_COMPANY_PERMISSION as COMPANY_PERMISSION, crudEndpoints_CUSTOMER as CUSTOMER, crudEndpoints_CUSTOM_DOCUMENT as CUSTOM_DOCUMENT, crudEndpoints_CUSTOM_ENTITY_FIELD as CUSTOM_ENTITY_FIELD, crudEndpoints_CUSTOM_ENTITY_OBJECT as CUSTOM_ENTITY_OBJECT, crudEndpoints_CUSTOM_ENTITY_SCHEMA as CUSTOM_ENTITY_SCHEMA, crudEndpoints_CUSTOM_FIELD as CUSTOM_FIELD, crudEndpoints_DELIVERY_JOB as DELIVERY_JOB, crudEndpoints_EMPLOYEE as EMPLOYEE, crudEndpoints_EXPENSE as EXPENSE, crudEndpoints_EXPENSE_LINE as EXPENSE_LINE, crudEndpoints_FIXED_ASSET as FIXED_ASSET, crudEndpoints_INCOMING_DELIVERY as INCOMING_DELIVERY, crudEndpoints_INCOMING_DELIVERY_LINE as INCOMING_DELIVERY_LINE, crudEndpoints_INCOMING_PAYMENT_METHOD as INCOMING_PAYMENT_METHOD, crudEndpoints_INCOMING_SHIPMENT as INCOMING_SHIPMENT, crudEndpoints_INTERNAL_DELIVERY as INTERNAL_DELIVERY, crudEndpoints_INTERNAL_DELIVERY_LINE as INTERNAL_DELIVERY_LINE, crudEndpoints_INVITATION as INVITATION, crudEndpoints_INVOICE as INVOICE, crudEndpoints_INVOICE_LINE as INVOICE_LINE, crudEndpoints_JOURNAL_ENTRY as JOURNAL_ENTRY, crudEndpoints_JOURNAL_ENTRY_LINE as JOURNAL_ENTRY_LINE, crudEndpoints_OUTGOING_DELIVERY as OUTGOING_DELIVERY, crudEndpoints_OUTGOING_DELIVERY_LINE as OUTGOING_DELIVERY_LINE, crudEndpoints_OUTGOING_SHIPMENT as OUTGOING_SHIPMENT, crudEndpoints_PAYMENT as PAYMENT, crudEndpoints_PRINT_JOB as PRINT_JOB, crudEndpoints_PRODUCT as PRODUCT, crudEndpoints_PRODUCTION_ORDER as PRODUCTION_ORDER, crudEndpoints_PRODUCTION_ORDER_LINE as PRODUCTION_ORDER_LINE, crudEndpoints_PRODUCT_GROUP as PRODUCT_GROUP, crudEndpoints_PRODUCT_ITEM as PRODUCT_ITEM, crudEndpoints_PURCHASE_ORDER as PURCHASE_ORDER, crudEndpoints_PURCHASE_ORDER_APPROVER as PURCHASE_ORDER_APPROVER, crudEndpoints_PURCHASE_ORDER_LINE as PURCHASE_ORDER_LINE, crudEndpoints_QUOTE as QUOTE, crudEndpoints_QUOTE_LINE as QUOTE_LINE, crudEndpoints_RENTAL_ORDER as RENTAL_ORDER, crudEndpoints_RENTAL_ORDER_LINE as RENTAL_ORDER_LINE, crudEndpoints_SALES_ORDER as SALES_ORDER, crudEndpoints_SALES_ORDER_APPROVER as SALES_ORDER_APPROVER, crudEndpoints_SALES_ORDER_LINE as SALES_ORDER_LINE, crudEndpoints_STOCK_ADJUSTMENT as STOCK_ADJUSTMENT, crudEndpoints_STORE as STORE, crudEndpoints_STORE_PRODUCT as STORE_PRODUCT, crudEndpoints_STORE_PRODUCT_GROUP as STORE_PRODUCT_GROUP, crudEndpoints_SUBSIDIARY as SUBSIDIARY, crudEndpoints_SUPPLIER as SUPPLIER, crudEndpoints_VEHICLE as VEHICLE, crudEndpoints_WAREHOUSE as WAREHOUSE, crudEndpoints_WORK_ORDER as WORK_ORDER };
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
declare function getAllCustomObjects(schemaName: string, queryParams?: any): Promise<any>;
|
|
133
|
+
declare function getCustomObjectById(schemaName: string, id: string): Promise<any>;
|
|
134
|
+
declare function updateCustomObject(schemaName: string, id: string, newData: any): Promise<any>;
|
|
135
|
+
declare function createCustomObject(schemaName: string, data: any): Promise<any>;
|
|
136
|
+
declare function deleteCustomObject(schemaName: string, id: string): Promise<any>;
|
|
132
137
|
declare function getAllObjects(entity: any, queryParams?: any): Promise<any>;
|
|
133
138
|
declare function getObjectById(entity: any, id: string): Promise<any>;
|
|
134
139
|
declare function updateObject(entity: any, id: string, newData: any): Promise<any>;
|
|
@@ -137,6 +142,11 @@ declare function deleteObject(entity: any, id: string): Promise<any>;
|
|
|
137
142
|
declare const konversiAPI: {
|
|
138
143
|
setToken: (token: string) => void;
|
|
139
144
|
setCompanyId: (companyId: string) => void;
|
|
145
|
+
getAllCustomObjects: typeof getAllCustomObjects;
|
|
146
|
+
getCustomObjectById: typeof getCustomObjectById;
|
|
147
|
+
updateCustomObject: typeof updateCustomObject;
|
|
148
|
+
deleteCustomObject: typeof deleteCustomObject;
|
|
149
|
+
createCustomObject: typeof createCustomObject;
|
|
140
150
|
getAllObjects: typeof getAllObjects;
|
|
141
151
|
getObjectById: typeof getObjectById;
|
|
142
152
|
updateObject: typeof updateObject;
|
package/dist/index.d.ts
CHANGED
|
@@ -129,6 +129,11 @@ declare namespace crudEndpoints {
|
|
|
129
129
|
export { crudEndpoints_ACCOUNT as ACCOUNT, crudEndpoints_ATTENDANCE as ATTENDANCE, crudEndpoints_AUDIT_LOG as AUDIT_LOG, crudEndpoints_AUTOMATION_JOB as AUTOMATION_JOB, crudEndpoints_AUTOMATION_SCRIPT as AUTOMATION_SCRIPT, crudEndpoints_BILL_OF_MATERIALS as BILL_OF_MATERIALS, crudEndpoints_BOM_COMPONENT as BOM_COMPONENT, crudEndpoints_BOM_OPERATION as BOM_OPERATION, crudEndpoints_COMPANY_ALIAS as COMPANY_ALIAS, crudEndpoints_COMPANY_OPTION as COMPANY_OPTION, crudEndpoints_COMPANY_PERMISSION as COMPANY_PERMISSION, crudEndpoints_CUSTOMER as CUSTOMER, crudEndpoints_CUSTOM_DOCUMENT as CUSTOM_DOCUMENT, crudEndpoints_CUSTOM_ENTITY_FIELD as CUSTOM_ENTITY_FIELD, crudEndpoints_CUSTOM_ENTITY_OBJECT as CUSTOM_ENTITY_OBJECT, crudEndpoints_CUSTOM_ENTITY_SCHEMA as CUSTOM_ENTITY_SCHEMA, crudEndpoints_CUSTOM_FIELD as CUSTOM_FIELD, crudEndpoints_DELIVERY_JOB as DELIVERY_JOB, crudEndpoints_EMPLOYEE as EMPLOYEE, crudEndpoints_EXPENSE as EXPENSE, crudEndpoints_EXPENSE_LINE as EXPENSE_LINE, crudEndpoints_FIXED_ASSET as FIXED_ASSET, crudEndpoints_INCOMING_DELIVERY as INCOMING_DELIVERY, crudEndpoints_INCOMING_DELIVERY_LINE as INCOMING_DELIVERY_LINE, crudEndpoints_INCOMING_PAYMENT_METHOD as INCOMING_PAYMENT_METHOD, crudEndpoints_INCOMING_SHIPMENT as INCOMING_SHIPMENT, crudEndpoints_INTERNAL_DELIVERY as INTERNAL_DELIVERY, crudEndpoints_INTERNAL_DELIVERY_LINE as INTERNAL_DELIVERY_LINE, crudEndpoints_INVITATION as INVITATION, crudEndpoints_INVOICE as INVOICE, crudEndpoints_INVOICE_LINE as INVOICE_LINE, crudEndpoints_JOURNAL_ENTRY as JOURNAL_ENTRY, crudEndpoints_JOURNAL_ENTRY_LINE as JOURNAL_ENTRY_LINE, crudEndpoints_OUTGOING_DELIVERY as OUTGOING_DELIVERY, crudEndpoints_OUTGOING_DELIVERY_LINE as OUTGOING_DELIVERY_LINE, crudEndpoints_OUTGOING_SHIPMENT as OUTGOING_SHIPMENT, crudEndpoints_PAYMENT as PAYMENT, crudEndpoints_PRINT_JOB as PRINT_JOB, crudEndpoints_PRODUCT as PRODUCT, crudEndpoints_PRODUCTION_ORDER as PRODUCTION_ORDER, crudEndpoints_PRODUCTION_ORDER_LINE as PRODUCTION_ORDER_LINE, crudEndpoints_PRODUCT_GROUP as PRODUCT_GROUP, crudEndpoints_PRODUCT_ITEM as PRODUCT_ITEM, crudEndpoints_PURCHASE_ORDER as PURCHASE_ORDER, crudEndpoints_PURCHASE_ORDER_APPROVER as PURCHASE_ORDER_APPROVER, crudEndpoints_PURCHASE_ORDER_LINE as PURCHASE_ORDER_LINE, crudEndpoints_QUOTE as QUOTE, crudEndpoints_QUOTE_LINE as QUOTE_LINE, crudEndpoints_RENTAL_ORDER as RENTAL_ORDER, crudEndpoints_RENTAL_ORDER_LINE as RENTAL_ORDER_LINE, crudEndpoints_SALES_ORDER as SALES_ORDER, crudEndpoints_SALES_ORDER_APPROVER as SALES_ORDER_APPROVER, crudEndpoints_SALES_ORDER_LINE as SALES_ORDER_LINE, crudEndpoints_STOCK_ADJUSTMENT as STOCK_ADJUSTMENT, crudEndpoints_STORE as STORE, crudEndpoints_STORE_PRODUCT as STORE_PRODUCT, crudEndpoints_STORE_PRODUCT_GROUP as STORE_PRODUCT_GROUP, crudEndpoints_SUBSIDIARY as SUBSIDIARY, crudEndpoints_SUPPLIER as SUPPLIER, crudEndpoints_VEHICLE as VEHICLE, crudEndpoints_WAREHOUSE as WAREHOUSE, crudEndpoints_WORK_ORDER as WORK_ORDER };
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
declare function getAllCustomObjects(schemaName: string, queryParams?: any): Promise<any>;
|
|
133
|
+
declare function getCustomObjectById(schemaName: string, id: string): Promise<any>;
|
|
134
|
+
declare function updateCustomObject(schemaName: string, id: string, newData: any): Promise<any>;
|
|
135
|
+
declare function createCustomObject(schemaName: string, data: any): Promise<any>;
|
|
136
|
+
declare function deleteCustomObject(schemaName: string, id: string): Promise<any>;
|
|
132
137
|
declare function getAllObjects(entity: any, queryParams?: any): Promise<any>;
|
|
133
138
|
declare function getObjectById(entity: any, id: string): Promise<any>;
|
|
134
139
|
declare function updateObject(entity: any, id: string, newData: any): Promise<any>;
|
|
@@ -137,6 +142,11 @@ declare function deleteObject(entity: any, id: string): Promise<any>;
|
|
|
137
142
|
declare const konversiAPI: {
|
|
138
143
|
setToken: (token: string) => void;
|
|
139
144
|
setCompanyId: (companyId: string) => void;
|
|
145
|
+
getAllCustomObjects: typeof getAllCustomObjects;
|
|
146
|
+
getCustomObjectById: typeof getCustomObjectById;
|
|
147
|
+
updateCustomObject: typeof updateCustomObject;
|
|
148
|
+
deleteCustomObject: typeof deleteCustomObject;
|
|
149
|
+
createCustomObject: typeof createCustomObject;
|
|
140
150
|
getAllObjects: typeof getAllObjects;
|
|
141
151
|
getObjectById: typeof getObjectById;
|
|
142
152
|
updateObject: typeof updateObject;
|
package/dist/index.js
CHANGED
|
@@ -201,6 +201,54 @@ var INCOMING_SHIPMENT = "shipment/incoming-shipment";
|
|
|
201
201
|
var OUTGOING_SHIPMENT = "shipment/outgoing-shipment";
|
|
202
202
|
|
|
203
203
|
// index.ts
|
|
204
|
+
function getAllCustomObjects(_0) {
|
|
205
|
+
return __async(this, arguments, function* (schemaName, queryParams = {}) {
|
|
206
|
+
const response = yield axiosAPI_default.request({
|
|
207
|
+
method: "get",
|
|
208
|
+
url: `custom-entity/${schemaName}`
|
|
209
|
+
});
|
|
210
|
+
return response.data;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function getCustomObjectById(schemaName, id) {
|
|
214
|
+
return __async(this, null, function* () {
|
|
215
|
+
const response = yield axiosAPI_default.request({
|
|
216
|
+
method: "get",
|
|
217
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
218
|
+
});
|
|
219
|
+
return response.data;
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function updateCustomObject(schemaName, id, newData) {
|
|
223
|
+
return __async(this, null, function* () {
|
|
224
|
+
const response = yield axiosAPI_default.request({
|
|
225
|
+
method: "put",
|
|
226
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
227
|
+
data: newData
|
|
228
|
+
});
|
|
229
|
+
return response.data;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function createCustomObject(schemaName, data) {
|
|
233
|
+
return __async(this, null, function* () {
|
|
234
|
+
const response = yield axiosAPI_default.request({
|
|
235
|
+
method: "post",
|
|
236
|
+
url: `custom-entity/${schemaName}`,
|
|
237
|
+
data
|
|
238
|
+
});
|
|
239
|
+
return response.data;
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function deleteCustomObject(schemaName, id) {
|
|
243
|
+
return __async(this, null, function* () {
|
|
244
|
+
const response = yield axiosAPI_default.request({
|
|
245
|
+
method: "delete",
|
|
246
|
+
maxBodyLength: Infinity,
|
|
247
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
248
|
+
});
|
|
249
|
+
return response.data;
|
|
250
|
+
});
|
|
251
|
+
}
|
|
204
252
|
function getAllObjects(_0) {
|
|
205
253
|
return __async(this, arguments, function* (entity, queryParams = {}) {
|
|
206
254
|
const response = yield axiosAPI_default.get(`${entity}`, {
|
|
@@ -237,6 +285,11 @@ var _a;
|
|
|
237
285
|
var konversiAPI = {
|
|
238
286
|
setToken: setAuthToken,
|
|
239
287
|
setCompanyId,
|
|
288
|
+
getAllCustomObjects,
|
|
289
|
+
getCustomObjectById,
|
|
290
|
+
updateCustomObject,
|
|
291
|
+
deleteCustomObject,
|
|
292
|
+
createCustomObject,
|
|
240
293
|
getAllObjects,
|
|
241
294
|
getObjectById,
|
|
242
295
|
updateObject,
|
package/dist/index.mjs
CHANGED
|
@@ -170,6 +170,54 @@ var INCOMING_SHIPMENT = "shipment/incoming-shipment";
|
|
|
170
170
|
var OUTGOING_SHIPMENT = "shipment/outgoing-shipment";
|
|
171
171
|
|
|
172
172
|
// index.ts
|
|
173
|
+
function getAllCustomObjects(_0) {
|
|
174
|
+
return __async(this, arguments, function* (schemaName, queryParams = {}) {
|
|
175
|
+
const response = yield axiosAPI_default.request({
|
|
176
|
+
method: "get",
|
|
177
|
+
url: `custom-entity/${schemaName}`
|
|
178
|
+
});
|
|
179
|
+
return response.data;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
function getCustomObjectById(schemaName, id) {
|
|
183
|
+
return __async(this, null, function* () {
|
|
184
|
+
const response = yield axiosAPI_default.request({
|
|
185
|
+
method: "get",
|
|
186
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
187
|
+
});
|
|
188
|
+
return response.data;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function updateCustomObject(schemaName, id, newData) {
|
|
192
|
+
return __async(this, null, function* () {
|
|
193
|
+
const response = yield axiosAPI_default.request({
|
|
194
|
+
method: "put",
|
|
195
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
196
|
+
data: newData
|
|
197
|
+
});
|
|
198
|
+
return response.data;
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function createCustomObject(schemaName, data) {
|
|
202
|
+
return __async(this, null, function* () {
|
|
203
|
+
const response = yield axiosAPI_default.request({
|
|
204
|
+
method: "post",
|
|
205
|
+
url: `custom-entity/${schemaName}`,
|
|
206
|
+
data
|
|
207
|
+
});
|
|
208
|
+
return response.data;
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function deleteCustomObject(schemaName, id) {
|
|
212
|
+
return __async(this, null, function* () {
|
|
213
|
+
const response = yield axiosAPI_default.request({
|
|
214
|
+
method: "delete",
|
|
215
|
+
maxBodyLength: Infinity,
|
|
216
|
+
url: `custom-entity/${schemaName}/${id}`
|
|
217
|
+
});
|
|
218
|
+
return response.data;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
173
221
|
function getAllObjects(_0) {
|
|
174
222
|
return __async(this, arguments, function* (entity, queryParams = {}) {
|
|
175
223
|
const response = yield axiosAPI_default.get(`${entity}`, {
|
|
@@ -206,6 +254,11 @@ var _a;
|
|
|
206
254
|
var konversiAPI = {
|
|
207
255
|
setToken: setAuthToken,
|
|
208
256
|
setCompanyId,
|
|
257
|
+
getAllCustomObjects,
|
|
258
|
+
getCustomObjectById,
|
|
259
|
+
updateCustomObject,
|
|
260
|
+
deleteCustomObject,
|
|
261
|
+
createCustomObject,
|
|
209
262
|
getAllObjects,
|
|
210
263
|
getObjectById,
|
|
211
264
|
updateObject,
|
package/index.ts
CHANGED
|
@@ -2,6 +2,52 @@ import axiosAPI, { setAuthToken, setCompanyId } from "./axiosAPI";
|
|
|
2
2
|
|
|
3
3
|
import * as crudEndpoints from "./crudEndpoints";
|
|
4
4
|
|
|
5
|
+
async function getAllCustomObjects(schemaName: string, queryParams: any = {}) {
|
|
6
|
+
const response = await axiosAPI.request({
|
|
7
|
+
method: 'get',
|
|
8
|
+
url: `custom-entity/${schemaName}`,
|
|
9
|
+
})
|
|
10
|
+
return response.data;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function getCustomObjectById(schemaName: string, id: string) {
|
|
14
|
+
const response = await axiosAPI.request({
|
|
15
|
+
method: 'get',
|
|
16
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
17
|
+
})
|
|
18
|
+
return response.data;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function updateCustomObject(schemaName: string, id: string, newData: any) {
|
|
22
|
+
const response = await axiosAPI.request({
|
|
23
|
+
method: 'put',
|
|
24
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
25
|
+
data: newData
|
|
26
|
+
})
|
|
27
|
+
return response.data;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function createCustomObject(schemaName: string, data: any) {
|
|
31
|
+
const response = await axiosAPI.request({
|
|
32
|
+
method: 'post',
|
|
33
|
+
url: `custom-entity/${schemaName}`,
|
|
34
|
+
data: data
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return response.data;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function deleteCustomObject(schemaName: string, id: string) {
|
|
41
|
+
const response = await axiosAPI.request({
|
|
42
|
+
method: 'delete',
|
|
43
|
+
maxBodyLength: Infinity,
|
|
44
|
+
url: `custom-entity/${schemaName}/${id}`,
|
|
45
|
+
})
|
|
46
|
+
return response.data;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// CRUD Base Objects
|
|
5
51
|
async function getAllObjects(entity: any, queryParams: any = {}) {
|
|
6
52
|
const response = await axiosAPI.get(`${entity}`, {
|
|
7
53
|
params: queryParams
|
|
@@ -35,6 +81,12 @@ const konversiAPI = {
|
|
|
35
81
|
setToken: setAuthToken,
|
|
36
82
|
setCompanyId,
|
|
37
83
|
|
|
84
|
+
getAllCustomObjects,
|
|
85
|
+
getCustomObjectById,
|
|
86
|
+
updateCustomObject,
|
|
87
|
+
deleteCustomObject,
|
|
88
|
+
createCustomObject,
|
|
89
|
+
|
|
38
90
|
getAllObjects,
|
|
39
91
|
getObjectById,
|
|
40
92
|
updateObject,
|
package/package.json
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import K from '../index';
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
let createdObject = await K.createCustomObject('ticket', {numEntries: 100, amount: 500000, code: "TICKET-123456"})
|
|
5
|
+
console.log(`created object`, createdObject);
|
|
6
|
+
|
|
7
|
+
let allObjects = await K.getAllCustomObjects('ticket');
|
|
8
|
+
|
|
9
|
+
console.log(`all objects`, allObjects);
|
|
10
|
+
|
|
11
|
+
let updateResult = await K.updateCustomObject('ticket', createdObject.id, {numEntries: 200});
|
|
12
|
+
console.log(`updated object`, updateResult);
|
|
13
|
+
|
|
14
|
+
// let deleteResult = await K.deleteCustomObject('ticket', createdObject.id);
|
|
15
|
+
// console.log(`deleted object`, deleteResult);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
main();
|