@zauru-sdk/services 2.0.211 → 2.0.213

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,4 +1,4 @@
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 { getShipmentsStringQuery } from "@zauru-sdk/graphql";
@@ -36,10 +36,24 @@ export async function getShipments(session, config) {
36
36
  */
37
37
  export async function receiveShipment_booking(headers, id) {
38
38
  return handlePossibleAxiosErrors(async () => {
39
- const response = await httpZauru.get(`/inventories/bookings/${id}/deliver.json`, { headers });
40
- if (!response.data) {
41
- throw new Error(`Sin respuesta de: /inventories/bookings/${id}/deliver.json - ${JSON.stringify(response)}`);
42
- }
39
+ await httpZauru.get(`/inventories/bookings/${id}/deliver.json`, {
40
+ headers,
41
+ });
42
+ return true;
43
+ });
44
+ }
45
+ export async function receiveTransit(headers, body) {
46
+ return handlePossibleAxiosErrors(async () => {
47
+ const sendBody = {
48
+ shipment: {
49
+ ...body,
50
+ movements_attributes: arrayToObject(body.movements),
51
+ },
52
+ };
53
+ delete sendBody.shipment.movements;
54
+ await httpZauru.put(`/inventories/transits/${body.id}.json`, sendBody, {
55
+ headers,
56
+ });
43
57
  return true;
44
58
  });
45
59
  }
@@ -4,6 +4,7 @@ import { AxiosUtilsResponse, ShipmentGraphQL } from "@zauru-sdk/types";
4
4
  * getShipments
5
5
  */
6
6
  export declare function getShipments(session: Session, config: {
7
+ id?: string | number;
7
8
  agency_to_id?: string | number;
8
9
  agency_from_id?: string | number;
9
10
  suffix?: string;
@@ -34,6 +35,7 @@ export declare function getShipments(session: Session, config: {
34
35
  * @returns
35
36
  */
36
37
  export declare function receiveShipment_booking(headers: any, id: string | number): Promise<AxiosUtilsResponse<boolean>>;
38
+ export declare function receiveTransit(headers: any, body: ShipmentGraphQL): Promise<AxiosUtilsResponse<boolean>>;
37
39
  /**
38
40
  * despacharShipment_booking
39
41
  * Esta función cambia el atributo 'shipment' de los envíos a 'true', lo que indica que el envío está en tránsito.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "2.0.211",
3
+ "version": "2.0.213",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -27,10 +27,10 @@
27
27
  "@upstash/redis": "^1.34.5",
28
28
  "@zauru-sdk/common": "^2.0.210",
29
29
  "@zauru-sdk/config": "^2.0.100",
30
- "@zauru-sdk/graphql": "^2.0.206",
30
+ "@zauru-sdk/graphql": "^2.0.213",
31
31
  "@zauru-sdk/types": "^2.0.210",
32
32
  "axios": "^1.6.7",
33
33
  "chalk": "5.3.0"
34
34
  },
35
- "gitHead": "51c5039e25476e90e00ef056c6895460c9dc2f07"
35
+ "gitHead": "052200a1481b4d079fa4adecaec4b5add072338d"
36
36
  }