@zauru-sdk/services 2.0.169 → 2.0.171

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.
@@ -1,7 +1,8 @@
1
- import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
1
+ import { arrayToObject, handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
2
  import { getGraphQLAPIHeaders } from "../common.js";
3
3
  import { httpGraphQLAPI } from "./httpGraphQL.js";
4
4
  import { getCasesStringQuery } from "@zauru-sdk/graphql";
5
+ import { httpZauru } from "./httpZauru.js";
5
6
  /**
6
7
  * getCasesByResponsibleId
7
8
  */
@@ -22,3 +23,63 @@ export async function getCasesByResponsibleId(session, filters) {
22
23
  return registers;
23
24
  });
24
25
  }
26
+ /**
27
+ * createCase
28
+ * @param headers
29
+ * @param body
30
+ * @returns
31
+ */
32
+ export async function createCase(headers, body) {
33
+ return handlePossibleAxiosErrors(async () => {
34
+ const sendBody = {
35
+ ...body,
36
+ case_supplies_attributes: arrayToObject(body.case_supplies),
37
+ tag_ids: ["", ...(body.taggings?.map((x) => x.tag_id) ?? [])],
38
+ };
39
+ if (sendBody.deleted_case_supplies)
40
+ delete sendBody.deleted_case_supplies;
41
+ if (sendBody.__rvfInternalFormId)
42
+ delete sendBody.__rvfInternalFormId;
43
+ if (sendBody.case_supplies)
44
+ delete sendBody.case_supplies;
45
+ if (sendBody.taggings)
46
+ delete sendBody.taggings;
47
+ const response = await httpZauru.post(`/support/cases.json`, { case: sendBody }, { headers });
48
+ return response.data;
49
+ });
50
+ }
51
+ /**
52
+ * updateCase
53
+ * @param headers
54
+ * @param body
55
+ * @returns
56
+ */
57
+ export async function updateCase(headers, body) {
58
+ return handlePossibleAxiosErrors(async () => {
59
+ const sendBody = {
60
+ ...body,
61
+ case_supplies_attributes: arrayToObject(body.case_supplies),
62
+ };
63
+ if (sendBody.deleted_case_supplies)
64
+ delete sendBody.deleted_case_supplies;
65
+ if (sendBody.__rvfInternalFormId)
66
+ delete sendBody.__rvfInternalFormId;
67
+ if (sendBody.case_supplies)
68
+ delete sendBody.case_supplies;
69
+ const response = await httpZauru.patch(`/support/cases/${body.id}.json`, { case: sendBody }, { headers });
70
+ return response.data;
71
+ });
72
+ }
73
+ /**
74
+ * deleteCase
75
+ * @param headers
76
+ * @param body
77
+ */
78
+ export async function deleteCase(headers, id) {
79
+ return handlePossibleAxiosErrors(async () => {
80
+ await httpZauru.delete(`/support/cases/${id}.json`, {
81
+ headers,
82
+ });
83
+ return true;
84
+ });
85
+ }
@@ -8,3 +8,23 @@ export declare function getCasesByResponsibleId(session: Session, filters?: {
8
8
  closed?: boolean;
9
9
  client_id?: number;
10
10
  }): Promise<AxiosUtilsResponse<CaseGraphQL[]>>;
11
+ /**
12
+ * createCase
13
+ * @param headers
14
+ * @param body
15
+ * @returns
16
+ */
17
+ export declare function createCase(headers: any, body: Partial<CaseGraphQL>): Promise<AxiosUtilsResponse<CaseGraphQL>>;
18
+ /**
19
+ * updateCase
20
+ * @param headers
21
+ * @param body
22
+ * @returns
23
+ */
24
+ export declare function updateCase(headers: any, body: Partial<CaseGraphQL>): Promise<AxiosUtilsResponse<CaseGraphQL>>;
25
+ /**
26
+ * deleteCase
27
+ * @param headers
28
+ * @param body
29
+ */
30
+ export declare function deleteCase(headers: any, id: string | number): Promise<AxiosUtilsResponse<boolean>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.169",
3
+ "version": "2.0.171",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -24,12 +24,12 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@remix-run/node": "^2.8.1",
27
- "@zauru-sdk/common": "^2.0.164",
27
+ "@zauru-sdk/common": "^2.0.171",
28
28
  "@zauru-sdk/config": "^2.0.100",
29
29
  "@zauru-sdk/graphql": "^2.0.169",
30
- "@zauru-sdk/types": "^2.0.164",
30
+ "@zauru-sdk/types": "^2.0.171",
31
31
  "axios": "^1.6.7",
32
32
  "chalk": "5.3.0"
33
33
  },
34
- "gitHead": "cb9bc2cccbff6605a48b0771ab6cc422a7a9df4e"
34
+ "gitHead": "a669ce28bf81bc0f56d9d5e634892f22d9d3717c"
35
35
  }