@zauru-sdk/services 2.0.199 → 2.0.202

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.
@@ -239,8 +239,17 @@ export async function getInvoiceFormSubmissionsByInvoiceId(headersZauru, session
239
239
  throw new Error(response.data.errors.map((x) => x.message).join(";"));
240
240
  }
241
241
  let registers = response?.data?.data?.submission_invoices;
242
+ // Filtrar los registros para obtener sólo los de la versión más alta.
243
+ const groupedByVersion = registers.reduce((acc, record) => {
244
+ const zid = record.settings_form_submission.zid;
245
+ if (!acc[zid]) {
246
+ acc[zid] = record;
247
+ }
248
+ return acc;
249
+ }, {});
250
+ let latestVersionRecords = Object.values(groupedByVersion).reverse();
242
251
  if (withFiles) {
243
- registers = await Promise.all(registers.map(async (register) => {
252
+ latestVersionRecords = await Promise.all(latestVersionRecords.map(async (register) => {
244
253
  try {
245
254
  const responseZauru = await httpZauru.get(`/settings/forms/form_submissions/${register.settings_form_submission.id}.json`, {
246
255
  headers: headersZauru,
@@ -264,15 +273,6 @@ export async function getInvoiceFormSubmissionsByInvoiceId(headersZauru, session
264
273
  }
265
274
  }));
266
275
  }
267
- // Filtrar los registros para obtener sólo los de la versión más alta.
268
- const groupedByVersion = registers.reduce((acc, record) => {
269
- const zid = record.settings_form_submission.zid;
270
- if (!acc[zid]) {
271
- acc[zid] = record;
272
- }
273
- return acc;
274
- }, {});
275
- const latestVersionRecords = Object.values(groupedByVersion).reverse();
276
276
  return latestVersionRecords;
277
277
  });
278
278
  }
@@ -290,8 +290,17 @@ export async function getCaseFormSubmissionsByCaseId(headersZauru, session, case
290
290
  throw new Error(response.data.errors.map((x) => x.message).join(";"));
291
291
  }
292
292
  let registers = response?.data?.data?.submission_cases;
293
+ // Filtrar los registros para obtener sólo los de la versión más alta.
294
+ const groupedByVersion = registers.reduce((acc, record) => {
295
+ const zid = record.settings_form_submission.zid;
296
+ if (!acc[zid]) {
297
+ acc[zid] = record;
298
+ }
299
+ return acc;
300
+ }, {});
301
+ let latestVersionRecords = Object.values(groupedByVersion).reverse();
293
302
  if (withFiles) {
294
- registers = await Promise.all(registers.map(async (register) => {
303
+ latestVersionRecords = await Promise.all(latestVersionRecords.map(async (register) => {
295
304
  try {
296
305
  const responseZauru = await httpZauru.get(`/settings/forms/form_submissions/${register.settings_form_submission.id}.json`, {
297
306
  headers: headersZauru,
@@ -315,15 +324,6 @@ export async function getCaseFormSubmissionsByCaseId(headersZauru, session, case
315
324
  }
316
325
  }));
317
326
  }
318
- // Filtrar los registros para obtener sólo los de la versión más alta.
319
- const groupedByVersion = registers.reduce((acc, record) => {
320
- const zid = record.settings_form_submission.zid;
321
- if (!acc[zid]) {
322
- acc[zid] = record;
323
- }
324
- return acc;
325
- }, {});
326
- const latestVersionRecords = Object.values(groupedByVersion).reverse();
327
327
  return latestVersionRecords;
328
328
  });
329
329
  }
@@ -432,3 +432,15 @@ export async function deleteFormSubmission(headers, id) {
432
432
  return true;
433
433
  });
434
434
  }
435
+ /**
436
+ * sendFormSubmissionEmail
437
+ * @param headers
438
+ * @param id
439
+ * @param body
440
+ */
441
+ export async function sendFormSubmissionEmail(headers, id, body) {
442
+ return handlePossibleAxiosErrors(async () => {
443
+ await httpZauru.post(`/settings/forms/form_submissions/${id}/send_email.json`, body, { headers });
444
+ return true;
445
+ });
446
+ }
@@ -108,3 +108,15 @@ export declare function updateSubmissionInvoiceFormSubmission(headers: any, body
108
108
  * @param body
109
109
  */
110
110
  export declare function deleteFormSubmission(headers: any, id: string | number): Promise<AxiosUtilsResponse<boolean>>;
111
+ /**
112
+ * sendFormSubmissionEmail
113
+ * @param headers
114
+ * @param id
115
+ * @param body
116
+ */
117
+ export declare function sendFormSubmissionEmail(headers: any, id: string | number, body: {
118
+ recipient_email: string;
119
+ recipient_name: string;
120
+ email_subject: string;
121
+ email_body: string;
122
+ }): Promise<AxiosUtilsResponse<boolean>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.199",
3
+ "version": "2.0.202",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -32,5 +32,5 @@
32
32
  "axios": "^1.6.7",
33
33
  "chalk": "5.3.0"
34
34
  },
35
- "gitHead": "ac9f963d081c81851a7890a0634fac9bbc8ff7d6"
35
+ "gitHead": "02024107088737551a72e04666cfd3d297547c95"
36
36
  }