@zauru-sdk/services 1.0.49 → 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.
Files changed (108) hide show
  1. package/dist/cjs/common.js +235 -0
  2. package/dist/cjs/index.js +50 -0
  3. package/dist/cjs/sessions/sessions.js +18 -0
  4. package/dist/cjs/sessions/upstash.js +59 -0
  5. package/dist/cjs/zauru/httpGraphQL.js +42 -0
  6. package/dist/cjs/zauru/httpOauth.js +42 -0
  7. package/dist/cjs/zauru/httpZauru.js +42 -0
  8. package/dist/cjs/zauru/zauru-agencies.js +27 -0
  9. package/dist/cjs/zauru/zauru-automatic-numbers.js +28 -0
  10. package/dist/cjs/zauru/zauru-bookings.js +90 -0
  11. package/dist/cjs/zauru/zauru-bundles.js +104 -0
  12. package/dist/cjs/zauru/zauru-cases.js +30 -0
  13. package/dist/cjs/zauru/zauru-consolidated.js +81 -0
  14. package/dist/cjs/zauru/zauru-currencies.js +27 -0
  15. package/dist/cjs/zauru/zauru-deliveries.js +53 -0
  16. package/dist/cjs/zauru/zauru-discharges.js +55 -0
  17. package/dist/cjs/zauru/zauru-employees.js +30 -0
  18. package/dist/cjs/zauru/zauru-forms.js +363 -0
  19. package/dist/cjs/zauru/zauru-invoices.js +104 -0
  20. package/dist/cjs/zauru/zauru-items.js +293 -0
  21. package/dist/cjs/zauru/zauru-lote-record.js +33 -0
  22. package/dist/cjs/zauru/zauru-lotes.js +312 -0
  23. package/dist/cjs/zauru/zauru-motivos-rechazo.js +57 -0
  24. package/dist/cjs/zauru/zauru-payees.js +247 -0
  25. package/dist/cjs/zauru/zauru-payment-terms.js +75 -0
  26. package/dist/cjs/zauru/zauru-price-lists.js +49 -0
  27. package/dist/cjs/zauru/zauru-profiles.js +80 -0
  28. package/dist/cjs/zauru/zauru-purchase-orders.js +438 -0
  29. package/dist/cjs/zauru/zauru-receptions.js +104 -0
  30. package/dist/cjs/zauru/zauru-shipments.js +62 -0
  31. package/dist/cjs/zauru/zauru-suggested-prices.js +94 -0
  32. package/dist/cjs/zauru/zauru-tags.js +20 -0
  33. package/dist/cjs/zauru/zauru-templates.js +22 -0
  34. package/dist/cjs/zauru/zauru-variables.js +56 -0
  35. package/dist/cjs/zauru/zauru-web-app-tables.js +167 -0
  36. package/package.json +12 -9
  37. package/CHANGELOG.md +0 -232
  38. package/src/common.ts +0 -343
  39. package/src/index.ts +0 -37
  40. package/src/sessions/sessions.ts +0 -17
  41. package/src/sessions/upstash.ts +0 -55
  42. package/src/zauru/httpGraphQL.ts +0 -55
  43. package/src/zauru/httpOauth.ts +0 -55
  44. package/src/zauru/httpZauru.ts +0 -56
  45. package/src/zauru/zauru-agencies.ts +0 -32
  46. package/src/zauru/zauru-automatic-numbers.ts +0 -35
  47. package/src/zauru/zauru-bookings.ts +0 -134
  48. package/src/zauru/zauru-bundles.ts +0 -157
  49. package/src/zauru/zauru-cases.ts +0 -44
  50. package/src/zauru/zauru-consolidated.ts +0 -129
  51. package/src/zauru/zauru-currencies.ts +0 -39
  52. package/src/zauru/zauru-deliveries.ts +0 -70
  53. package/src/zauru/zauru-discharges.ts +0 -90
  54. package/src/zauru/zauru-employees.ts +0 -43
  55. package/src/zauru/zauru-forms.ts +0 -618
  56. package/src/zauru/zauru-invoices.ts +0 -142
  57. package/src/zauru/zauru-items.ts +0 -481
  58. package/src/zauru/zauru-lote-record.ts +0 -77
  59. package/src/zauru/zauru-lotes.ts +0 -484
  60. package/src/zauru/zauru-motivos-rechazo.ts +0 -121
  61. package/src/zauru/zauru-payees.ts +0 -402
  62. package/src/zauru/zauru-payment-terms.ts +0 -126
  63. package/src/zauru/zauru-price-lists.ts +0 -68
  64. package/src/zauru/zauru-profiles.ts +0 -106
  65. package/src/zauru/zauru-purchase-orders.ts +0 -701
  66. package/src/zauru/zauru-receptions.ts +0 -148
  67. package/src/zauru/zauru-shipments.ts +0 -88
  68. package/src/zauru/zauru-suggested-prices.ts +0 -137
  69. package/src/zauru/zauru-tags.ts +0 -22
  70. package/src/zauru/zauru-templates.ts +0 -24
  71. package/src/zauru/zauru-variables.ts +0 -67
  72. package/src/zauru/zauru-web-app-tables.ts +0 -256
  73. package/tsconfig.json +0 -24
  74. /package/dist/{common.js → esm/common.js} +0 -0
  75. /package/dist/{index.js → esm/index.js} +0 -0
  76. /package/dist/{sessions → esm/sessions}/sessions.js +0 -0
  77. /package/dist/{sessions → esm/sessions}/upstash.js +0 -0
  78. /package/dist/{zauru → esm/zauru}/httpGraphQL.js +0 -0
  79. /package/dist/{zauru → esm/zauru}/httpOauth.js +0 -0
  80. /package/dist/{zauru → esm/zauru}/httpZauru.js +0 -0
  81. /package/dist/{zauru → esm/zauru}/zauru-agencies.js +0 -0
  82. /package/dist/{zauru → esm/zauru}/zauru-automatic-numbers.js +0 -0
  83. /package/dist/{zauru → esm/zauru}/zauru-bookings.js +0 -0
  84. /package/dist/{zauru → esm/zauru}/zauru-bundles.js +0 -0
  85. /package/dist/{zauru → esm/zauru}/zauru-cases.js +0 -0
  86. /package/dist/{zauru → esm/zauru}/zauru-consolidated.js +0 -0
  87. /package/dist/{zauru → esm/zauru}/zauru-currencies.js +0 -0
  88. /package/dist/{zauru → esm/zauru}/zauru-deliveries.js +0 -0
  89. /package/dist/{zauru → esm/zauru}/zauru-discharges.js +0 -0
  90. /package/dist/{zauru → esm/zauru}/zauru-employees.js +0 -0
  91. /package/dist/{zauru → esm/zauru}/zauru-forms.js +0 -0
  92. /package/dist/{zauru → esm/zauru}/zauru-invoices.js +0 -0
  93. /package/dist/{zauru → esm/zauru}/zauru-items.js +0 -0
  94. /package/dist/{zauru → esm/zauru}/zauru-lote-record.js +0 -0
  95. /package/dist/{zauru → esm/zauru}/zauru-lotes.js +0 -0
  96. /package/dist/{zauru → esm/zauru}/zauru-motivos-rechazo.js +0 -0
  97. /package/dist/{zauru → esm/zauru}/zauru-payees.js +0 -0
  98. /package/dist/{zauru → esm/zauru}/zauru-payment-terms.js +0 -0
  99. /package/dist/{zauru → esm/zauru}/zauru-price-lists.js +0 -0
  100. /package/dist/{zauru → esm/zauru}/zauru-profiles.js +0 -0
  101. /package/dist/{zauru → esm/zauru}/zauru-purchase-orders.js +0 -0
  102. /package/dist/{zauru → esm/zauru}/zauru-receptions.js +0 -0
  103. /package/dist/{zauru → esm/zauru}/zauru-shipments.js +0 -0
  104. /package/dist/{zauru → esm/zauru}/zauru-suggested-prices.js +0 -0
  105. /package/dist/{zauru → esm/zauru}/zauru-tags.js +0 -0
  106. /package/dist/{zauru → esm/zauru}/zauru-templates.js +0 -0
  107. /package/dist/{zauru → esm/zauru}/zauru-variables.js +0 -0
  108. /package/dist/{zauru → esm/zauru}/zauru-web-app-tables.js +0 -0
@@ -1,402 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import {
4
- AxiosUtilsResponse,
5
- PayeeCategoryGraphQL,
6
- PayeeGraphQL,
7
- } from "@zauru-sdk/types";
8
- import httpGraphQLAPI from "./httpGraphQL.js";
9
- import { getGraphQLAPIHeaders } from "../common.js";
10
- import {
11
- getClientCategoriesStringQuery,
12
- getPayeeByIdStringQuery,
13
- getPayeeCategoriesByNotesMatchStringQuery,
14
- getPayeeCategoriesStringQuery,
15
- getPayeeCategoryByIdStringQuery,
16
- getPayeesStringQuery,
17
- getProviderCategoriesStringQuery,
18
- getProvidersStringQuery,
19
- } from "@zauru-sdk/graphql";
20
- import httpZauru from "./httpZauru.js";
21
-
22
- /**
23
- * getPayees
24
- * @param headers
25
- * @returns
26
- */
27
- export async function getPayees(
28
- session: Session
29
- ): Promise<AxiosUtilsResponse<PayeeGraphQL[]>> {
30
- return handlePossibleAxiosErrors(async () => {
31
- const headers = await getGraphQLAPIHeaders(session);
32
- const response = await httpGraphQLAPI.post<{
33
- data: { payees: PayeeGraphQL[] };
34
- }>(
35
- ``,
36
- {
37
- query: getPayeesStringQuery,
38
- },
39
- {
40
- headers,
41
- }
42
- );
43
-
44
- return response.data?.data.payees;
45
- });
46
- }
47
-
48
- /**
49
- * getProviders
50
- * @param headers
51
- * @returns
52
- */
53
- export async function getProviders(
54
- session: Session
55
- ): Promise<AxiosUtilsResponse<PayeeGraphQL[]>> {
56
- return handlePossibleAxiosErrors(async () => {
57
- const headers = await getGraphQLAPIHeaders(session);
58
- const response = await httpGraphQLAPI.post<{
59
- data: { payees: PayeeGraphQL[] };
60
- }>(
61
- ``,
62
- {
63
- query: getProvidersStringQuery,
64
- },
65
- {
66
- headers,
67
- }
68
- );
69
-
70
- return response.data?.data.payees;
71
- });
72
- }
73
-
74
- /**
75
- * getPayee
76
- * @param session
77
- * @param id
78
- */
79
- export async function getPayee(
80
- session: Session,
81
- id: number | string
82
- ): Promise<AxiosUtilsResponse<PayeeGraphQL | undefined>> {
83
- return handlePossibleAxiosErrors(async () => {
84
- const headers = await getGraphQLAPIHeaders(session);
85
-
86
- const responsePayee = await httpGraphQLAPI.post<{
87
- data: { payees: PayeeGraphQL[] };
88
- }>(
89
- "",
90
- {
91
- query: getPayeeByIdStringQuery,
92
- variables: {
93
- id,
94
- },
95
- },
96
- { headers }
97
- );
98
-
99
- if (!responsePayee?.data?.data?.payees[0]) {
100
- throw new Error("No se encontró el beneficiario indicado");
101
- }
102
-
103
- return responsePayee?.data?.data?.payees[0];
104
- });
105
- }
106
-
107
- /**
108
- * getPayeesByCategoryId
109
- * @param session
110
- * @param categoryId
111
- * @returns
112
- */
113
- export async function getPayeesByCategoryId(
114
- session: Session,
115
- id: number | string
116
- ): Promise<AxiosUtilsResponse<PayeeGraphQL[]>> {
117
- return handlePossibleAxiosErrors(async () => {
118
- const headers = await getGraphQLAPIHeaders(session);
119
- const response = await httpGraphQLAPI.post<{
120
- data: {
121
- payee_categories: { payees: PayeeGraphQL[] }[];
122
- };
123
- errors?: {
124
- message: string;
125
- extensions: { path: string; code: string };
126
- }[];
127
- }>(
128
- ``,
129
- {
130
- query: getPayeeCategoryByIdStringQuery,
131
- variables: { id },
132
- },
133
- { headers }
134
- );
135
-
136
- if (response.data.errors) {
137
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
138
- }
139
-
140
- if (!response?.data?.data?.payee_categories[0]) {
141
- return [];
142
- }
143
-
144
- return response.data?.data?.payee_categories[0]?.payees;
145
- });
146
- }
147
-
148
- /**
149
- * getPayeeCategoriesByNotesMatch
150
- * @param session
151
- * @param match
152
- * @returns
153
- */
154
- export async function getPayeeCategoriesByNotesMatch(
155
- session: Session,
156
- match: string
157
- ): Promise<AxiosUtilsResponse<PayeeCategoryGraphQL[]>> {
158
- return handlePossibleAxiosErrors(async () => {
159
- const headers = await getGraphQLAPIHeaders(session);
160
- const response = await httpGraphQLAPI.post<{
161
- data: {
162
- payee_categories: PayeeCategoryGraphQL[];
163
- };
164
- errors?: {
165
- message: string;
166
- extensions: { path: string; code: string };
167
- }[];
168
- }>(
169
- ``,
170
- {
171
- query: getPayeeCategoriesByNotesMatchStringQuery(match),
172
- },
173
- { headers }
174
- );
175
-
176
- if (response.data.errors) {
177
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
178
- }
179
-
180
- return response.data?.data?.payee_categories;
181
- });
182
- }
183
-
184
- /**
185
- * getPayeeCategories
186
- * @param session
187
- * @param match
188
- * @returns
189
- */
190
- export async function getPayeeCategories(
191
- session: Session
192
- ): Promise<AxiosUtilsResponse<PayeeCategoryGraphQL[]>> {
193
- return handlePossibleAxiosErrors(async () => {
194
- const headers = await getGraphQLAPIHeaders(session);
195
- const response = await httpGraphQLAPI.post<{
196
- data: {
197
- payee_categories: PayeeCategoryGraphQL[];
198
- };
199
- errors?: {
200
- message: string;
201
- extensions: { path: string; code: string };
202
- }[];
203
- }>(
204
- ``,
205
- {
206
- query: getPayeeCategoriesStringQuery,
207
- },
208
- { headers }
209
- );
210
-
211
- if (response.data.errors) {
212
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
213
- }
214
-
215
- return response.data?.data?.payee_categories;
216
- });
217
- }
218
-
219
- /**
220
- * getProviderCategories
221
- * @param session
222
- * @param match
223
- * @returns
224
- */
225
- export async function getProviderCategories(
226
- session: Session
227
- ): Promise<AxiosUtilsResponse<PayeeCategoryGraphQL[]>> {
228
- return handlePossibleAxiosErrors(async () => {
229
- const headers = await getGraphQLAPIHeaders(session);
230
- const response = await httpGraphQLAPI.post<{
231
- data: {
232
- payee_categories: PayeeCategoryGraphQL[];
233
- };
234
- errors?: {
235
- message: string;
236
- extensions: { path: string; code: string };
237
- }[];
238
- }>(
239
- ``,
240
- {
241
- query: getProviderCategoriesStringQuery,
242
- },
243
- { headers }
244
- );
245
-
246
- if (response.data.errors) {
247
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
248
- }
249
-
250
- return response.data?.data?.payee_categories;
251
- });
252
- }
253
-
254
- /**
255
- * getProviderCategories
256
- * @param session
257
- * @param match
258
- * @returns
259
- */
260
- export async function getClientCategories(
261
- session: Session
262
- ): Promise<AxiosUtilsResponse<PayeeCategoryGraphQL[]>> {
263
- return handlePossibleAxiosErrors(async () => {
264
- const headers = await getGraphQLAPIHeaders(session);
265
- const response = await httpGraphQLAPI.post<{
266
- data: {
267
- payee_categories: PayeeCategoryGraphQL[];
268
- };
269
- errors?: {
270
- message: string;
271
- extensions: { path: string; code: string };
272
- }[];
273
- }>(
274
- ``,
275
- {
276
- query: getClientCategoriesStringQuery,
277
- },
278
- { headers }
279
- );
280
-
281
- if (response.data.errors) {
282
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
283
- }
284
-
285
- return response.data?.data?.payee_categories;
286
- });
287
- }
288
-
289
- /**
290
- * createPayee
291
- * @param session
292
- * @param headers
293
- * @returns
294
- */
295
- export async function createPayee(
296
- headers: any,
297
- body: Partial<PayeeGraphQL>
298
- ): Promise<AxiosUtilsResponse<boolean>> {
299
- return handlePossibleAxiosErrors(async () => {
300
- await httpZauru.post<any>("/settings/payees", { payee: body }, { headers });
301
- return true;
302
- });
303
- }
304
-
305
- /**
306
- * deletePayee
307
- * @param headers
308
- * @param id
309
- * @returns
310
- */
311
- export async function deletePayee(
312
- headers: any,
313
- id: string | number
314
- ): Promise<AxiosUtilsResponse<boolean>> {
315
- return handlePossibleAxiosErrors(async () => {
316
- await httpZauru.delete<any>(`/settings/payees/${id}?destroy=true`, {
317
- headers,
318
- });
319
- return true;
320
- });
321
- }
322
-
323
- /**
324
- * updatePayee
325
- * @param session
326
- * @param headers
327
- * @returns
328
- */
329
- export async function updatePayee(
330
- headers: any,
331
- body: Partial<PayeeGraphQL>
332
- ): Promise<AxiosUtilsResponse<boolean>> {
333
- return handlePossibleAxiosErrors(async () => {
334
- await httpZauru.patch<any>(
335
- `/settings/payees/${body.id}`,
336
- { payee: body },
337
- { headers }
338
- );
339
- return true;
340
- });
341
- }
342
-
343
- /**
344
- * createPayeeCategory
345
- * @param session
346
- * @param headers
347
- * @returns
348
- */
349
- export async function createPayeeCategory(
350
- headers: any,
351
- body: Partial<PayeeCategoryGraphQL>
352
- ): Promise<AxiosUtilsResponse<PayeeCategoryGraphQL>> {
353
- return handlePossibleAxiosErrors(async () => {
354
- const response = await httpZauru.post<any>(
355
- "/settings/payees/payee_categories",
356
- { payee_category: body },
357
- { headers }
358
- );
359
- return response.data;
360
- });
361
- }
362
-
363
- /**
364
- * updatePayeeCategory
365
- * @param session
366
- * @param headers
367
- * @returns
368
- */
369
- export async function updatePayeeCategory(
370
- headers: any,
371
- body: Partial<PayeeCategoryGraphQL>
372
- ): Promise<AxiosUtilsResponse<boolean>> {
373
- return handlePossibleAxiosErrors(async () => {
374
- await httpZauru.patch<any>(
375
- `/settings/payees/payee_categories/${body.id}`,
376
- { payee_category: body },
377
- { headers }
378
- );
379
- return true;
380
- });
381
- }
382
-
383
- /**
384
- * deletePayeeCategory
385
- * @param headers
386
- * @param id
387
- * @returns
388
- */
389
- export async function deletePayeeCategory(
390
- headers: any,
391
- id: string | number
392
- ): Promise<AxiosUtilsResponse<boolean>> {
393
- return handlePossibleAxiosErrors(async () => {
394
- await httpZauru.delete<any>(
395
- `/settings/payees/payee_categories/${id}?destroy=true`,
396
- {
397
- headers,
398
- }
399
- );
400
- return true;
401
- });
402
- }
@@ -1,126 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
3
- import { AxiosUtilsResponse, PaymentTermGraphQL } from "@zauru-sdk/types";
4
- import { getGraphQLAPIHeaders } from "../common.js";
5
- import httpGraphQLAPI from "./httpGraphQL.js";
6
- import {
7
- getPaymentTermByIdStringQuery,
8
- getPaymentTermsStringQuery,
9
- } from "@zauru-sdk/graphql";
10
- import httpZauru from "./httpZauru.js";
11
-
12
- /**
13
- * getPaymentTerms
14
- */
15
- export async function getPaymentTerms(
16
- session: Session
17
- ): Promise<AxiosUtilsResponse<PaymentTermGraphQL[]>> {
18
- return handlePossibleAxiosErrors(async () => {
19
- const headers = await getGraphQLAPIHeaders(session);
20
-
21
- const response = await httpGraphQLAPI.post<{
22
- data: { payment_terms: PaymentTermGraphQL[] };
23
- errors?: {
24
- message: string;
25
- extensions: { path: string; code: string };
26
- }[];
27
- }>(
28
- "",
29
- {
30
- query: getPaymentTermsStringQuery,
31
- },
32
- { headers }
33
- );
34
-
35
- if (response.data.errors) {
36
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
37
- }
38
-
39
- const registers = response?.data?.data?.payment_terms;
40
-
41
- return registers;
42
- });
43
- }
44
-
45
- /**
46
- * getPaymentTermById
47
- */
48
- export async function getPaymentTermById(
49
- session: Session,
50
- id: string | number
51
- ): Promise<AxiosUtilsResponse<PaymentTermGraphQL>> {
52
- return handlePossibleAxiosErrors(async () => {
53
- const headers = await getGraphQLAPIHeaders(session);
54
-
55
- const response = await httpGraphQLAPI.post<{
56
- data: { payment_terms: PaymentTermGraphQL[] };
57
- errors?: {
58
- message: string;
59
- extensions: { path: string; code: string };
60
- }[];
61
- }>(
62
- "",
63
- {
64
- query: getPaymentTermByIdStringQuery,
65
- variables: { id },
66
- },
67
- { headers }
68
- );
69
-
70
- if (response.data.errors) {
71
- throw new Error(response.data.errors.map((x) => x.message).join(";"));
72
- }
73
-
74
- if (!response?.data?.data?.payment_terms[0]) {
75
- throw new Error(
76
- "No se encontró ningún método de pago con este id: " + id
77
- );
78
- }
79
-
80
- const registers = response?.data?.data?.payment_terms[0] ?? [];
81
-
82
- return registers;
83
- });
84
- }
85
-
86
- /**
87
- * createPaymentTerm
88
- * @param headers
89
- */
90
- export async function createPaymentTerm(
91
- headers: any,
92
- payment_term: PaymentTermGraphQL
93
- ): Promise<AxiosUtilsResponse<PaymentTermGraphQL>> {
94
- return handlePossibleAxiosErrors(async () => {
95
- const response = await httpZauru.patch<PaymentTermGraphQL>(
96
- `/sales/settings/payment_terms.json`,
97
- {
98
- payment_term,
99
- },
100
- { headers }
101
- );
102
-
103
- return response.data;
104
- });
105
- }
106
-
107
- /**
108
- * updatePaymentTerm
109
- * @param headers
110
- */
111
- export async function updatePaymentTerm(
112
- headers: any,
113
- payment_term: Partial<PaymentTermGraphQL> & any
114
- ): Promise<AxiosUtilsResponse<PaymentTermGraphQL>> {
115
- return handlePossibleAxiosErrors(async () => {
116
- const response = await httpZauru.patch<PaymentTermGraphQL>(
117
- `/sales/settings/payment_terms/${payment_term.id}.json`,
118
- {
119
- payment_term,
120
- },
121
- { headers }
122
- );
123
-
124
- return response.data;
125
- });
126
- }
@@ -1,68 +0,0 @@
1
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
- import {
3
- AxiosUtilsResponse,
4
- CreatePriceListBody,
5
- PriceListGraphQL,
6
- } from "@zauru-sdk/types";
7
- import httpZauru from "./httpZauru.js";
8
-
9
- /**
10
- * createPriceList
11
- * @param session
12
- * @param headers
13
- * @returns
14
- */
15
- export async function createPriceList(
16
- headers: any,
17
- body: CreatePriceListBody
18
- ): Promise<AxiosUtilsResponse<PriceListGraphQL>> {
19
- return handlePossibleAxiosErrors(async () => {
20
- const response = await httpZauru.post<any>(
21
- "/sales/settings/price_lists",
22
- { price_list: body },
23
- { headers }
24
- );
25
- return response.data;
26
- });
27
- }
28
-
29
- /**
30
- * deletePriceList
31
- * @param headers
32
- * @param id
33
- * @returns
34
- */
35
- export async function deletePriceList(
36
- headers: any,
37
- id: string | number
38
- ): Promise<AxiosUtilsResponse<boolean>> {
39
- return handlePossibleAxiosErrors(async () => {
40
- await httpZauru.delete<any>(
41
- `/sales/settings/price_lists/${id}?destroy=true`,
42
- {
43
- headers,
44
- }
45
- );
46
- return true;
47
- });
48
- }
49
-
50
- /**
51
- * updatePriceList
52
- * @param session
53
- * @param headers
54
- * @returns
55
- */
56
- export async function updatePriceList(
57
- headers: any,
58
- body: Partial<PriceListGraphQL>
59
- ): Promise<AxiosUtilsResponse<boolean>> {
60
- return handlePossibleAxiosErrors(async () => {
61
- await httpZauru.patch<any>(
62
- `/sales/settings/price_lists/${body.id}`,
63
- { price_list: body },
64
- { headers }
65
- );
66
- return true;
67
- });
68
- }
@@ -1,106 +0,0 @@
1
- import type { Session } from "@remix-run/node";
2
- import httpZauru from "./httpZauru.js";
3
- import httpOauth from "./httpOauth.js";
4
- import {
5
- AgencyGraphQL,
6
- EmployeeGraphQL,
7
- OauthProfile,
8
- ProfileResponse,
9
- AxiosUtilsResponse,
10
- } from "@zauru-sdk/types";
11
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
12
- import { config } from "@zauru-sdk/config";
13
-
14
- /**
15
- * getOauthUserInfo
16
- * @param codeValue
17
- * @returns
18
- */
19
- export const getOauthUserInfo = async (
20
- codeValue: string
21
- ): Promise<AxiosUtilsResponse<OauthProfile>> => {
22
- return handlePossibleAxiosErrors(async () => {
23
- const response = await httpOauth.get<OauthProfile>(`/api/userinfo`, {
24
- headers: {
25
- Authorization: `Bearer ${codeValue}`,
26
- },
27
- });
28
- return response.data;
29
- });
30
- };
31
-
32
- /**
33
- *
34
- * @param employeeId
35
- * @param headers
36
- * @returns
37
- */
38
- export const getEmployeeInfo = async (
39
- id: number,
40
- headers: any
41
- ): Promise<AxiosUtilsResponse<EmployeeGraphQL>> => {
42
- return handlePossibleAxiosErrors(async () => {
43
- const employeeInfo = await httpZauru.get<EmployeeGraphQL>(
44
- `/settings/employees/${id}.json`,
45
- { headers }
46
- );
47
- return employeeInfo.data;
48
- });
49
- };
50
-
51
- /**
52
- * getProfileInformation
53
- * @param headers
54
- * @returns
55
- */
56
- export const getProfileInformation = async (
57
- headers: any
58
- ): Promise<AxiosUtilsResponse<ProfileResponse>> => {
59
- return handlePossibleAxiosErrors(async () => {
60
- const response = await httpZauru.get<ProfileResponse>(`/profile.json`, {
61
- headers,
62
- });
63
-
64
- return response.data;
65
- });
66
- };
67
-
68
- export const changeEntity = async (headers: any, entityId: string) => {
69
- const changeEntityFetch = await httpZauru.patch<any>(
70
- `${config.zauruBaseURL}/company.json`,
71
- JSON.stringify({
72
- selected_entity_id: entityId,
73
- }),
74
- {
75
- headers,
76
- }
77
- );
78
- return changeEntityFetch.data;
79
- };
80
-
81
- /**
82
- *
83
- * @param headers
84
- * @returns
85
- */
86
- export const getAgencyInfo = async (
87
- headers: any,
88
- session: Session
89
- ): Promise<AxiosUtilsResponse<AgencyGraphQL>> => {
90
- return handlePossibleAxiosErrors(async () => {
91
- const agency_id = session.get("agency_id");
92
- if (!agency_id) {
93
- throw new Error(
94
- "No hay una agencia asignada para este usuario... Contacte con su administrador."
95
- );
96
- }
97
- const response = await httpZauru.get<AgencyGraphQL>(
98
- `/settings/agencies/${agency_id}.json`,
99
- {
100
- headers,
101
- }
102
- );
103
-
104
- return response?.data;
105
- });
106
- };