@chift/chift-nodejs 1.0.5 → 1.0.7

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.
Files changed (70) hide show
  1. package/.github/workflows/ci.yml +38 -38
  2. package/CHANGELOG.md +22 -0
  3. package/dist/src/modules/accounting.d.ts +6 -6
  4. package/dist/src/modules/accounting.js +17 -11
  5. package/dist/src/modules/api.d.ts +1925 -27777
  6. package/dist/src/modules/consumer.d.ts +372 -70
  7. package/dist/src/modules/consumer.js +10 -0
  8. package/dist/src/modules/consumers.d.ts +1931 -396
  9. package/dist/src/modules/ecommerce.d.ts +8 -0
  10. package/dist/src/modules/ecommerce.js +28 -0
  11. package/dist/src/modules/flow.js +1 -1
  12. package/dist/src/modules/internalApi.js +10 -5
  13. package/dist/src/modules/pos.d.ts +6 -0
  14. package/dist/src/modules/pos.js +21 -0
  15. package/dist/src/modules/sync.d.ts +1552 -324
  16. package/dist/src/modules/syncs.d.ts +8 -27387
  17. package/dist/src/modules/syncs.js +10 -0
  18. package/dist/test/modules/accounting.test.js +0 -11
  19. package/dist/test/modules/ecommerce.test.js +34 -7
  20. package/dist/test/modules/pos.test.js +18 -0
  21. package/jest.config.ts +1 -1
  22. package/package.json +2 -2
  23. package/src/modules/accounting.ts +25 -13
  24. package/src/modules/api.ts +2 -2
  25. package/src/modules/consumer.ts +21 -0
  26. package/src/modules/ecommerce.ts +52 -0
  27. package/src/modules/flow.ts +1 -1
  28. package/src/modules/pos.ts +40 -0
  29. package/src/modules/sync.ts +1 -1
  30. package/src/modules/syncs.ts +34 -3
  31. package/src/types/public-api/schema.d.ts +3299 -1950
  32. package/test/modules/accounting.test.ts +0 -14
  33. package/test/modules/consumer.test.ts +1 -1
  34. package/test/modules/ecommerce.test.ts +34 -3
  35. package/test/modules/pos.test.ts +21 -0
  36. package/.eslintcache +0 -1
  37. package/coverage/clover.xml +0 -1645
  38. package/coverage/coverage-final.json +0 -19
  39. package/coverage/lcov-report/base.css +0 -224
  40. package/coverage/lcov-report/block-navigation.js +0 -87
  41. package/coverage/lcov-report/favicon.png +0 -0
  42. package/coverage/lcov-report/index.html +0 -146
  43. package/coverage/lcov-report/prettify.css +0 -1
  44. package/coverage/lcov-report/prettify.js +0 -2
  45. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  46. package/coverage/lcov-report/sorter.js +0 -196
  47. package/coverage/lcov-report/src/helpers/index.html +0 -131
  48. package/coverage/lcov-report/src/helpers/openapi.ts.html +0 -151
  49. package/coverage/lcov-report/src/helpers/settings.ts.html +0 -94
  50. package/coverage/lcov-report/src/index.html +0 -116
  51. package/coverage/lcov-report/src/index.ts.html +0 -88
  52. package/coverage/lcov-report/src/modules/accounting.ts.html +0 -1156
  53. package/coverage/lcov-report/src/modules/api.ts.html +0 -190
  54. package/coverage/lcov-report/src/modules/consumer.ts.html +0 -616
  55. package/coverage/lcov-report/src/modules/consumers.ts.html +0 -331
  56. package/coverage/lcov-report/src/modules/custom.ts.html +0 -193
  57. package/coverage/lcov-report/src/modules/datastores.ts.html +0 -142
  58. package/coverage/lcov-report/src/modules/ecommerce.ts.html +0 -331
  59. package/coverage/lcov-report/src/modules/flow.ts.html +0 -589
  60. package/coverage/lcov-report/src/modules/index.html +0 -326
  61. package/coverage/lcov-report/src/modules/integrations.ts.html +0 -151
  62. package/coverage/lcov-report/src/modules/internalApi.ts.html +0 -586
  63. package/coverage/lcov-report/src/modules/invoicing.ts.html +0 -391
  64. package/coverage/lcov-report/src/modules/pos.ts.html +0 -421
  65. package/coverage/lcov-report/src/modules/sync.ts.html +0 -316
  66. package/coverage/lcov-report/src/modules/syncs.ts.html +0 -169
  67. package/coverage/lcov-report/src/modules/webhooks.ts.html +0 -343
  68. package/coverage/lcov.info +0 -1976
  69. package/dist/test/modules/flow.test.d.ts +0 -1
  70. package/dist/test/modules/flow.test.js +0 -69
@@ -21,9 +21,19 @@ const Syncs = (internalApi) => {
21
21
  const { data } = yield _internalApi.get(`/syncs/${syncid}`);
22
22
  return (0, sync_1.Sync)(_internalApi, data);
23
23
  });
24
+ const createSync = (body) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const { data, } = yield _internalApi.post('/syncs', body);
26
+ return (0, sync_1.Sync)(_internalApi, data);
27
+ });
28
+ const updateSync = (body) => __awaiter(void 0, void 0, void 0, function* () {
29
+ const { data, } = yield _internalApi.patch('/syncs', body);
30
+ return (0, sync_1.Sync)(_internalApi, data);
31
+ });
24
32
  return {
33
+ createSync,
25
34
  getSyncs,
26
35
  getSyncById,
36
+ updateSync,
27
37
  };
28
38
  };
29
39
  exports.Syncs = Syncs;
@@ -377,17 +377,6 @@ let analyticAccounts;
377
377
  const analyticAccountsWithMultiplePlans = yield consumer.accounting.getAnalyticAccountsWithMultiplePlans();
378
378
  (0, globals_1.expect)(analyticAccountsWithMultiplePlans).toBeInstanceOf(Array);
379
379
  }));
380
- (0, globals_1.test)('getAnalyticLinesOfAccount', () => __awaiter(void 0, void 0, void 0, function* () {
381
- const analyticLinesOfAccount = yield consumer.accounting.getAnalyticLinesOfAccount(analyticAccounts[0].id);
382
- (0, globals_1.expect)(analyticLinesOfAccount).toBeInstanceOf(Array);
383
- if (analyticLinesOfAccount.length > 0) {
384
- (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('account_id', analyticAccounts[0].id);
385
- (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('description', globals_1.expect.any(String));
386
- (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('amount', globals_1.expect.any(Number));
387
- (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('date', globals_1.expect.any(String));
388
- (0, globals_1.expect)(analyticLinesOfAccount[0]).toHaveProperty('id', globals_1.expect.any(String));
389
- }
390
- }));
391
380
  (0, globals_1.test)('createJournalEntry', () => __awaiter(void 0, void 0, void 0, function* () {
392
381
  const journal = journals.find((journal) => journal.journal_type === 'customer_invoice');
393
382
  if (!journal) {
@@ -122,9 +122,9 @@ let locations;
122
122
  (0, globals_1.expect)(product).toBeTruthy();
123
123
  (0, globals_1.expect)(product).toHaveProperty('available_quantity', globals_1.expect.any(Number));
124
124
  }));
125
- /*
126
- test('createOrder', async () => {
127
- const order = await consumer.ecommerce.createOrder({
125
+ // TODO: Fix create order test
126
+ globals_1.test.skip('createOrder', () => __awaiter(void 0, void 0, void 0, function* () {
127
+ const order = yield consumer.ecommerce.createOrder({
128
128
  customer: {
129
129
  email: 'test@test.com',
130
130
  },
@@ -155,10 +155,9 @@ test('createOrder', async () => {
155
155
  ],
156
156
  payment_method: 'bank-transfer',
157
157
  });
158
- expect(order).toBeTruthy();
159
- expect(order).toHaveProperty('id', expect.any(String));
160
- });
161
- */
158
+ (0, globals_1.expect)(order).toBeTruthy();
159
+ (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
160
+ }));
162
161
  let orders;
163
162
  (0, globals_1.test)('getOrders', () => __awaiter(void 0, void 0, void 0, function* () {
164
163
  orders = yield consumer.ecommerce.getOrders({
@@ -191,3 +190,31 @@ let orders;
191
190
  (0, globals_1.expect)(order).toHaveProperty('lines', globals_1.expect.any(Array));
192
191
  (0, globals_1.expect)(order).toHaveProperty('other_fees');
193
192
  }));
193
+ (0, globals_1.test)('getPaymentMethods', () => __awaiter(void 0, void 0, void 0, function* () {
194
+ const paymentMethods = yield consumer.ecommerce.getPaymentMethods();
195
+ (0, globals_1.expect)(paymentMethods).toBeInstanceOf(Array);
196
+ (0, globals_1.expect)(paymentMethods.length).toBeGreaterThan(0);
197
+ (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('id', globals_1.expect.any(String));
198
+ (0, globals_1.expect)(paymentMethods[0]).toHaveProperty('name', globals_1.expect.any(String));
199
+ }));
200
+ (0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
201
+ const productCategories = yield consumer.ecommerce.getProductCategories();
202
+ (0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
203
+ (0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
204
+ (0, globals_1.expect)(productCategories[0]).toHaveProperty('id', globals_1.expect.any(String));
205
+ (0, globals_1.expect)(productCategories[0]).toHaveProperty('name', globals_1.expect.any(String));
206
+ }));
207
+ (0, globals_1.test)('getCountries', () => __awaiter(void 0, void 0, void 0, function* () {
208
+ const countries = yield consumer.ecommerce.getCountries();
209
+ (0, globals_1.expect)(countries).toBeInstanceOf(Array);
210
+ (0, globals_1.expect)(countries.length).toBeGreaterThan(0);
211
+ (0, globals_1.expect)(countries[0]).toHaveProperty('code', globals_1.expect.any(String));
212
+ (0, globals_1.expect)(countries[0]).toHaveProperty('name', globals_1.expect.any(String));
213
+ }));
214
+ (0, globals_1.test)('getTaxes', () => __awaiter(void 0, void 0, void 0, function* () {
215
+ const taxes = yield consumer.ecommerce.getTaxes();
216
+ (0, globals_1.expect)(taxes).toBeInstanceOf(Array);
217
+ (0, globals_1.expect)(taxes.length).toBeGreaterThan(0);
218
+ (0, globals_1.expect)(taxes[0]).toHaveProperty('id', globals_1.expect.any(String));
219
+ (0, globals_1.expect)(taxes[0]).toHaveProperty('rate', globals_1.expect.any(Number));
220
+ }));
@@ -45,11 +45,14 @@ const client = new chift.API({
45
45
  // Split testing between two APIs to support all endpoints
46
46
  const cashpadConsumerId = process.env.CHIFT_CASHPAD_CONSUMER_ID;
47
47
  const lightspeedConsumerId = process.env.CHIFT_LIGHTSPEED_CONSUMER_ID;
48
+ const popinaConsumerId = process.env.CHIFT_POPINA_CONSUMER_ID;
48
49
  let cashpadConsumer;
49
50
  let lightspeedConsumer;
51
+ let popinaConsumer;
50
52
  (0, globals_1.beforeAll)(() => __awaiter(void 0, void 0, void 0, function* () {
51
53
  cashpadConsumer = yield client.Consumers.getConsumerById(cashpadConsumerId);
52
54
  lightspeedConsumer = yield client.Consumers.getConsumerById(lightspeedConsumerId);
55
+ popinaConsumer = yield client.Consumers.getConsumerById(popinaConsumerId);
53
56
  }));
54
57
  (0, globals_1.test)('getLocations', () => __awaiter(void 0, void 0, void 0, function* () {
55
58
  const locations = yield lightspeedConsumer.pos.getLocations();
@@ -162,3 +165,18 @@ globals_1.test.skip('updateOrder', () => __awaiter(void 0, void 0, void 0, funct
162
165
  (0, globals_1.expect)(order).toBeTruthy();
163
166
  (0, globals_1.expect)(order).toHaveProperty('id', globals_1.expect.any(String));
164
167
  }));
168
+ (0, globals_1.test)('getProducts', () => __awaiter(void 0, void 0, void 0, function* () {
169
+ const products = yield popinaConsumer.pos.getProducts();
170
+ (0, globals_1.expect)(products).toBeInstanceOf(Array);
171
+ (0, globals_1.expect)(products.length).toBeGreaterThan(0);
172
+ }));
173
+ (0, globals_1.test)('getProductCategories', () => __awaiter(void 0, void 0, void 0, function* () {
174
+ const productCategories = yield popinaConsumer.pos.getProductCategories();
175
+ (0, globals_1.expect)(productCategories).toBeInstanceOf(Array);
176
+ (0, globals_1.expect)(productCategories.length).toBeGreaterThan(0);
177
+ }));
178
+ (0, globals_1.test)('getAccountingCategories', () => __awaiter(void 0, void 0, void 0, function* () {
179
+ const accountingCategories = yield popinaConsumer.pos.getAccountingCategories();
180
+ (0, globals_1.expect)(accountingCategories).toBeInstanceOf(Array);
181
+ (0, globals_1.expect)(accountingCategories.length).toBeGreaterThan(0);
182
+ }));
package/jest.config.ts CHANGED
@@ -191,5 +191,5 @@ export default {
191
191
  // Whether to use watchman for file crawling
192
192
  // watchman: true,
193
193
 
194
- testTimeout: 30000,
194
+ testTimeout: 60000,
195
195
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chift/chift-nodejs",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "The Chift NodeJS library provides convenient access to the Chift API from applications written in the NodeJS language (Javascript/Typescript).",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -8,7 +8,7 @@
8
8
  "dev": "chokidar src --command 'npm run build' --debounce=5000",
9
9
  "prepare": "husky install",
10
10
  "build": "tsc",
11
- "test": "jest"
11
+ "test": "jest --maxWorkers 1"
12
12
  },
13
13
  "keywords": [],
14
14
  "author": "Chift",
@@ -242,14 +242,6 @@ const accountingFactory = {
242
242
  url: '/consumers/{consumer_id}/accounting/analytic-accounts/multi-analytic-plans',
243
243
  };
244
244
  },
245
- getAnalyticLinesOfAccount(
246
- analytic_account_id: string
247
- ): RequestData<components['schemas']['AnalyticAccountLineItemOut'][]> {
248
- return {
249
- method: 'get',
250
- url: `/consumers/{consumer_id}/accounting/analytic-account-lines/account/${analytic_account_id}`,
251
- };
252
- },
253
245
  getJournalEntries(
254
246
  params: getJournalEntriesParams
255
247
  ): RequestData<components['schemas']['JournalEntryMonoAnalyticPlan'][]> {
@@ -296,18 +288,22 @@ const accountingFactory = {
296
288
  };
297
289
  },
298
290
  createMiscOperation(
299
- operation: components['schemas']['MiscellaneousOperationIn']
291
+ operation: components['schemas']['MiscellaneousOperationIn'],
292
+ params: operations['accounting_create_miscellaneous_operation']['parameters']['query']
300
293
  ): RequestData<components['schemas']['MiscellaneousOperationOut']> {
301
294
  return {
295
+ params,
302
296
  method: 'post',
303
297
  url: '/consumers/{consumer_id}/accounting/miscellaneous-operation',
304
298
  body: operation,
305
299
  };
306
300
  },
307
301
  getMiscOperation(
308
- operation_id: string
302
+ operation_id: string,
303
+ params: operations['accounting_get_miscellaneous_operation']['parameters']['query']
309
304
  ): RequestData<components['schemas']['MiscellaneousOperationOut']> {
310
305
  return {
306
+ params,
311
307
  method: 'get',
312
308
  url: `/consumers/{consumer_id}/accounting/miscellaneous-operation/${operation_id}`,
313
309
  };
@@ -334,16 +330,21 @@ const accountingFactory = {
334
330
  };
335
331
  },
336
332
  getBalanceOfAccounts(
337
- filter: components['schemas']['AccountBalanceFilter']
333
+ filter: components['schemas']['AccountBalanceFilter'],
334
+ params: operations['accounting_get_accounts_balances']['parameters']['query']
338
335
  ): RequestData<components['schemas']['AccountBalance'][]> {
339
336
  return {
337
+ params,
340
338
  method: 'post',
341
339
  url: '/consumers/{consumer_id}/accounting/chart-of-accounts/balance',
342
340
  body: filter,
343
341
  };
344
342
  },
345
- getEmployees(): RequestData<components['schemas']['EmployeeItem'][]> {
343
+ getEmployees(
344
+ params: operations['accounting_get_employees']['parameters']['query']
345
+ ): RequestData<components['schemas']['EmployeeItem'][]> {
346
346
  return {
347
+ params,
347
348
  method: 'get',
348
349
  url: '/consumers/{consumer_id}/accounting/employees',
349
350
  };
@@ -382,7 +383,7 @@ const accountingFactory = {
382
383
  body: financial_entry,
383
384
  };
384
385
  },
385
- createJournalEntry(
386
+ createJournalEntryOld(
386
387
  journal_entry: components['schemas']['JournalEntryIn']
387
388
  ): RequestData<components['schemas']['JournalEntryMultiAnalyticPlan']> {
388
389
  return {
@@ -391,6 +392,17 @@ const accountingFactory = {
391
392
  body: journal_entry,
392
393
  };
393
394
  },
395
+ createJournalEntry(
396
+ journal_entry: components['schemas']['GenericJournalEntry'],
397
+ params: operations['accounting_create_generic_journal_entry']['parameters']['query']
398
+ ): RequestData<components['schemas']['JournalEntryMultiAnalyticPlan']> {
399
+ return {
400
+ params,
401
+ method: 'post',
402
+ url: '/consumers/{consumer_id}/accounting/journal-entries',
403
+ body: journal_entry,
404
+ };
405
+ },
394
406
  };
395
407
 
396
408
  export { accountingFactory };
@@ -1,7 +1,7 @@
1
1
  import { AuthType } from '../types/api';
2
2
  import { InternalAPI } from './internalApi';
3
3
  import { Consumers } from './consumers';
4
- import { Syncs } from './syncs';
4
+ import { Syncs, SyncsAPI } from './syncs';
5
5
  import { Integrations } from './integrations';
6
6
  import { Webhooks } from './webhooks';
7
7
  import { DataStores } from './datastores';
@@ -11,7 +11,7 @@ export class API {
11
11
  token?: string;
12
12
  internalApi?: any;
13
13
  Consumers;
14
- Syncs;
14
+ Syncs: SyncsAPI;
15
15
  Integrations;
16
16
  Webhooks;
17
17
  DataStores;
@@ -80,6 +80,18 @@ const Consumer = (
80
80
  return data;
81
81
  };
82
82
 
83
+ const enableFlow = async (
84
+ syncId: string,
85
+ flowId: string,
86
+ body: components['schemas']['EnableFlowConsumer']
87
+ ) => {
88
+ const { data }: { data: SimpleResponseModel } = await _internalApi.post(
89
+ `/consumers/${consumerId}/syncs/${syncId}/flows/${flowId}/enable`,
90
+ body
91
+ );
92
+ return data;
93
+ };
94
+
83
95
  const getDataByDataStoreName = async (dataStoreName: string, params?: object) => {
84
96
  const { data }: { data: components['schemas']['DataStoreItem'][] } = await _internalApi.get(
85
97
  `/datastores`
@@ -135,6 +147,13 @@ const Consumer = (
135
147
  return response;
136
148
  };
137
149
 
150
+ const deleteDataStoreData = async (dataStoreId: string, dataStoreDataId: string) => {
151
+ const { data: response }: { data: SimpleResponseModel } = await _internalApi.delete(
152
+ `/consumers/${consumerId}/datastore/${dataStoreId}/data/${dataStoreDataId}`
153
+ );
154
+ return response;
155
+ };
156
+
138
157
  /**
139
158
  * This function is used to add logs related to a chainexecution (passed in the header)
140
159
  * INTERNAL USE only
@@ -155,6 +174,7 @@ const Consumer = (
155
174
  createConnection,
156
175
  updateConnection,
157
176
  deleteConnection,
177
+ enableFlow,
158
178
  getSyncUrl,
159
179
  name,
160
180
  redirect_url,
@@ -170,6 +190,7 @@ const Consumer = (
170
190
  getDataByDataStoreName,
171
191
  addDataByDataStoreName,
172
192
  updateDataStoreData,
193
+ deleteDataStoreData,
173
194
  logData,
174
195
  };
175
196
  };
@@ -6,6 +6,26 @@ type getOrdersParams = Omit<
6
6
  'page' | 'size'
7
7
  >;
8
8
 
9
+ type getPaymentMethodsParams = Omit<
10
+ operations['ecommerce_get_payments_methods']['parameters']['query'],
11
+ 'page' | 'size'
12
+ >;
13
+
14
+ type getProductCategoriesParams = Omit<
15
+ operations['ecommerce_get_product_categories']['parameters']['query'],
16
+ 'page' | 'size'
17
+ >;
18
+
19
+ type getTaxesParams = Omit<
20
+ operations['ecommerce_get_taxes']['parameters']['query'],
21
+ 'page' | 'size'
22
+ >;
23
+
24
+ type getCountriesParams = Omit<
25
+ operations['ecommerce_get_countries']['parameters']['query'],
26
+ 'page' | 'size'
27
+ >;
28
+
9
29
  const ecommerceFactory = {
10
30
  getCustomers(): RequestData<components['schemas']['CommerceCustomerItem'][]> {
11
31
  return {
@@ -77,6 +97,38 @@ const ecommerceFactory = {
77
97
  url: `/consumers/{consumer_id}/commerce/orders/${orderId}`,
78
98
  };
79
99
  },
100
+ getPaymentMethods(
101
+ params: getPaymentMethodsParams
102
+ ): RequestData<components['schemas']['PaymentMethodItem'][]> {
103
+ return {
104
+ params,
105
+ method: 'get',
106
+ url: `/consumers/{consumer_id}/commerce/payment-methods`,
107
+ };
108
+ },
109
+ getProductCategories(
110
+ params: getProductCategoriesParams
111
+ ): RequestData<components['schemas']['CategoryItem'][]> {
112
+ return {
113
+ params,
114
+ method: 'get',
115
+ url: `/consumers/{consumer_id}/commerce/product-categories`,
116
+ };
117
+ },
118
+ getTaxes(params: getTaxesParams): RequestData<components['schemas']['TaxRateItem'][]> {
119
+ return {
120
+ params,
121
+ method: 'get',
122
+ url: `/consumers/{consumer_id}/commerce/taxes`,
123
+ };
124
+ },
125
+ getCountries(params: getCountriesParams): RequestData<components['schemas']['CountryItem'][]> {
126
+ return {
127
+ params,
128
+ method: 'get',
129
+ url: `/consumers/{consumer_id}/commerce/countries`,
130
+ };
131
+ },
80
132
  };
81
133
 
82
134
  export { ecommerceFactory };
@@ -38,7 +38,7 @@ const Flow = (
38
38
  name: data.name,
39
39
  description: data.description,
40
40
  execution: data.execution,
41
- trigger: data.trigger,
41
+ triggers: data.triggers,
42
42
  config: data.config,
43
43
  });
44
44
  // execute locally or remotely by sending an event to execute the flow
@@ -11,11 +11,26 @@ type getPaymentMethodsParams = Omit<
11
11
  'page' | 'size'
12
12
  >;
13
13
 
14
+ type getProductCategoriesParams = Omit<
15
+ operations['pos_get_product_categories']['parameters']['query'],
16
+ 'page' | 'size'
17
+ >;
18
+
19
+ type getProductsParams = Omit<
20
+ operations['pos_get_products']['parameters']['query'],
21
+ 'page' | 'size'
22
+ >;
23
+
14
24
  type getCustomersParams = Omit<
15
25
  operations['pos_get_customers']['parameters']['query'],
16
26
  'page' | 'size'
17
27
  >;
18
28
 
29
+ type getAccountingCategoriesParams = Omit<
30
+ operations['pos_get_accounting_categories']['parameters']['query'],
31
+ 'page' | 'size'
32
+ >;
33
+
19
34
  type getOrdersParams = Omit<operations['pos_get_orders']['parameters']['query'], 'page' | 'size'>;
20
35
 
21
36
  const posFactory = {
@@ -71,6 +86,22 @@ const posFactory = {
71
86
  url: `/consumers/{consumer_id}/pos/payment-methods`,
72
87
  };
73
88
  },
89
+ getProductCategories(
90
+ params: getProductCategoriesParams
91
+ ): RequestData<components['schemas']['CategoryItem'][]> {
92
+ return {
93
+ params,
94
+ method: 'get',
95
+ url: `/consumers/{consumer_id}/pos/product-categories`,
96
+ };
97
+ },
98
+ getProducts(params: getProductsParams): RequestData<components['schemas']['POSProductItem'][]> {
99
+ return {
100
+ params,
101
+ method: 'get',
102
+ url: `/consumers/{consumer_id}/pos/products`,
103
+ };
104
+ },
74
105
  getSales(
75
106
  params: operations['pos_get_sales']['parameters']['query']
76
107
  ): RequestData<components['schemas']['SalesItem']> {
@@ -107,6 +138,15 @@ const posFactory = {
107
138
  body: order,
108
139
  };
109
140
  },
141
+ getAccountingCategories(
142
+ params: getAccountingCategoriesParams
143
+ ): RequestData<components['schemas']['AccountingCategoryItem'][]> {
144
+ return {
145
+ params,
146
+ method: 'get',
147
+ url: `/consumers/{consumer_id}/pos/accounting-categories`,
148
+ };
149
+ },
110
150
  };
111
151
 
112
152
  export { posFactory };
@@ -4,7 +4,7 @@ import { ContextType } from '../types/sync';
4
4
  import { Consumer } from './consumer';
5
5
  import { Flow } from './flow';
6
6
 
7
- const Sync = (internalApi: InternalAPI, body: components['schemas']['SyncItem']) => {
7
+ const Sync = (internalApi: InternalAPI, body: components['schemas']['ReadSyncItem']) => {
8
8
  const _internalApi: InternalAPI = internalApi;
9
9
  const data = body;
10
10
  const name = data.name;
@@ -2,26 +2,57 @@ import { components } from '../types/public-api/schema';
2
2
  import { InternalAPI } from './internalApi';
3
3
  import { Sync } from './sync';
4
4
 
5
- const Syncs = (internalApi: InternalAPI) => {
5
+ export type SyncsAPI = {
6
+ createSync: (
7
+ body?: components['schemas']['CreateSyncItem']
8
+ ) => Promise<ReturnType<typeof Sync>>;
9
+ getSyncs: () => Promise<ReturnType<typeof Sync>[]>;
10
+ getSyncById: (syncid: string) => Promise<ReturnType<typeof Sync>>;
11
+ updateSync: (
12
+ body?: components['schemas']['CreateSyncItem']
13
+ ) => Promise<ReturnType<typeof Sync>>;
14
+ };
15
+
16
+ const Syncs = (internalApi: InternalAPI): SyncsAPI => {
6
17
  const _internalApi: InternalAPI = internalApi;
7
18
 
8
19
  const getSyncs = async () => {
9
- const { data }: { data: components['schemas']['SyncItem'][] } = await _internalApi.get(
20
+ const { data }: { data: components['schemas']['ReadSyncItem'][] } = await _internalApi.get(
10
21
  '/syncs'
11
22
  );
12
23
  return data.map((sync) => Sync(_internalApi, sync));
13
24
  };
14
25
 
15
26
  const getSyncById = async (syncid: string) => {
16
- const { data }: { data: components['schemas']['SyncItem'] } = await _internalApi.get(
27
+ const { data }: { data: components['schemas']['ReadSyncItem'] } = await _internalApi.get(
17
28
  `/syncs/${syncid}`
18
29
  );
19
30
  return Sync(_internalApi, data);
20
31
  };
21
32
 
33
+ const createSync = async (body?: components['schemas']['CreateSyncItem']) => {
34
+ const {
35
+ data,
36
+ }: {
37
+ data: components['schemas']['ReadSyncItem'];
38
+ } = await _internalApi.post('/syncs', body);
39
+ return Sync(_internalApi, data);
40
+ };
41
+
42
+ const updateSync = async (body?: components['schemas']['CreateSyncItem']) => {
43
+ const {
44
+ data,
45
+ }: {
46
+ data: components['schemas']['ReadSyncItem'];
47
+ } = await _internalApi.patch('/syncs', body);
48
+ return Sync(_internalApi, data);
49
+ };
50
+
22
51
  return {
52
+ createSync,
23
53
  getSyncs,
24
54
  getSyncById,
55
+ updateSync,
25
56
  };
26
57
  };
27
58