@zauru-sdk/services 2.0.82 → 2.0.84
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.
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { config } from "@zauru-sdk/config";
|
|
4
|
+
const axiosInstance = axios.create({
|
|
5
|
+
baseURL: `${config.cmsAPIBaseURL}`,
|
|
6
|
+
});
|
|
7
|
+
axiosInstance.interceptors.request.use(function (request) {
|
|
8
|
+
// Do something before request is sent
|
|
9
|
+
console.log("---------------- EJECUTANDO REQUEST CMS ----------------");
|
|
10
|
+
//console.time(`${request.baseURL}${request.url}`);
|
|
11
|
+
console.log(chalk.green(`${request.baseURL}${request.url}`));
|
|
12
|
+
request.timeout = 200000;
|
|
13
|
+
return request;
|
|
14
|
+
}, function (error) {
|
|
15
|
+
console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
|
|
16
|
+
console.log(`${error}`);
|
|
17
|
+
// Do something with request error
|
|
18
|
+
return Promise.reject(error);
|
|
19
|
+
});
|
|
20
|
+
// Add a response interceptor
|
|
21
|
+
axiosInstance.interceptors.response.use(function (response) {
|
|
22
|
+
// Do something with response data
|
|
23
|
+
//console.timeEnd(`${response.config.baseURL}${response.config.url}`);
|
|
24
|
+
return response;
|
|
25
|
+
}, function (error) {
|
|
26
|
+
console.log(chalk.red("---------------- ERROR CON REQUEST CMS ----------------"));
|
|
27
|
+
console.log(`${error}`);
|
|
28
|
+
// Do something with response error
|
|
29
|
+
const { response } = error;
|
|
30
|
+
const msgError = response
|
|
31
|
+
? `HTTP ${response.status} ${response.statusText} - URL: ${response?.config?.baseURL}${response?.config?.url} - ${JSON.stringify(response?.data)}`
|
|
32
|
+
: error;
|
|
33
|
+
console.log(chalk.red(`${msgError}`));
|
|
34
|
+
throw new Error(msgError);
|
|
35
|
+
});
|
|
36
|
+
export const httpCMSAPI = axiosInstance;
|
|
@@ -9,7 +9,18 @@ import { httpZauru } from "./httpZauru.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export async function createNewReception(headers, body, purchase_order_id) {
|
|
11
11
|
return handlePossibleAxiosErrors(async () => {
|
|
12
|
-
const
|
|
12
|
+
const sendBody = {
|
|
13
|
+
...body,
|
|
14
|
+
reception_details_attributes: arrayToObject(body.reception_details),
|
|
15
|
+
};
|
|
16
|
+
delete sendBody.reception_details;
|
|
17
|
+
const response = await httpZauru(`/purchases/purchase_orders/${purchase_order_id}/receptions.json`, {
|
|
18
|
+
method: "POST",
|
|
19
|
+
headers,
|
|
20
|
+
data: {
|
|
21
|
+
reception: sendBody,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
13
24
|
return response.data;
|
|
14
25
|
});
|
|
15
26
|
}
|
|
@@ -27,13 +38,14 @@ export async function deleteReception(headers, receptionId, poId) {
|
|
|
27
38
|
return true;
|
|
28
39
|
});
|
|
29
40
|
}
|
|
41
|
+
//TODO: PASARLO A UTILS
|
|
30
42
|
/**
|
|
31
43
|
*
|
|
32
44
|
* @param headers
|
|
33
45
|
* @param poId
|
|
34
46
|
* @returns
|
|
35
47
|
*/
|
|
36
|
-
export async function
|
|
48
|
+
export async function createNewLabPurchaseOrderReception(headers, session, body) {
|
|
37
49
|
return handlePossibleAxiosErrors(async () => {
|
|
38
50
|
const sendBody = {
|
|
39
51
|
reception: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const httpCMSAPI: import("axios").AxiosInstance;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Session } from "@remix-run/node";
|
|
2
|
-
import { AxiosUtilsResponse,
|
|
2
|
+
import { AxiosUtilsResponse, DeepPartial, PurchaseOrderGraphQL, ReceptionGraphQL } from "@zauru-sdk/types";
|
|
3
3
|
/**
|
|
4
4
|
* createNewReception
|
|
5
5
|
* @param headers
|
|
@@ -7,7 +7,7 @@ import { AxiosUtilsResponse, NewReceptionBody, PurchaseOrderGraphQL } from "@zau
|
|
|
7
7
|
* @param purchase_order_id
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function createNewReception(headers: any, body:
|
|
10
|
+
export declare function createNewReception(headers: any, body: DeepPartial<ReceptionGraphQL>, purchase_order_id: number | string): Promise<AxiosUtilsResponse<any>>;
|
|
11
11
|
/**
|
|
12
12
|
* deleteReception
|
|
13
13
|
* @param headers
|
|
@@ -21,4 +21,4 @@ export declare function deleteReception(headers: any, receptionId: string | numb
|
|
|
21
21
|
* @param poId
|
|
22
22
|
* @returns
|
|
23
23
|
*/
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function createNewLabPurchaseOrderReception(headers: any, session: Session, body: Partial<PurchaseOrderGraphQL>): Promise<AxiosUtilsResponse<boolean>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.84",
|
|
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.
|
|
28
|
-
"@zauru-sdk/config": "^2.0.
|
|
27
|
+
"@zauru-sdk/common": "^2.0.84",
|
|
28
|
+
"@zauru-sdk/config": "^2.0.83",
|
|
29
29
|
"@zauru-sdk/graphql": "^2.0.69",
|
|
30
|
-
"@zauru-sdk/types": "^2.0.
|
|
30
|
+
"@zauru-sdk/types": "^2.0.84",
|
|
31
31
|
"axios": "^1.6.7",
|
|
32
32
|
"chalk": "5.3.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "5f802bbd907d746b74dcce0e8594ef896d92eae2"
|
|
35
35
|
}
|