Merge branch 'fix/api_il_guardar' into 'main'

Corregida ruta api/salvar

See merge request jjimenez/safekat!583
This commit is contained in:
Ignacio Martinez Navajas
2025-03-02 21:00:55 +00:00

View File

@ -57,7 +57,7 @@ class ImprimelibrosApi extends ResourceController
'precios' => $response['precio_u'] 'precios' => $response['precio_u']
] ]
]; ];
}else{ } else {
$response = [ $response = [
'status' => 400, 'status' => 400,
'error' => $response 'error' => $response
@ -75,23 +75,42 @@ class ImprimelibrosApi extends ResourceController
// Access the entire POST data // Access the entire POST data
$post_data = $this->request->getJSON(true); $post_data = $this->request->getJSON(true);
//return $this->respond(var_dump($post_data));
// Instancia de presupuesto cliente // Instancia de presupuesto cliente
$presupuestocliente = new Presupuestocliente(); $presupuestocliente = new Presupuestocliente();
$response = $presupuestocliente->guardar($post_data); try {
$response = $presupuestocliente->guardar($post_data);
return $this->respond($response); // DEBUG LINE
//return $this->respond($response);
$response = [ if (!isset($response['sk_id'])) {
'status' => 200, return $this->respond([
'error' => null, 'status' => 400,
'data' => [ 'error' => 'Missing sk_id',
'tiradas' => $response['tiradas'], 'message' => 'El identificador sk_id es requerido pero no se recibió.'
'precios' => $response['precio_u'] ], 400);
] }
];
return $this->respond($response); $response = [
'status' => 200,
'error' => null,
'data' => [
'sk_id' => $response['sk_id'],
'sk_url' => $response['sk_url'] ?? null
]
];
return $this->respond($response);
} catch (\Exception $e) {
return $this->respond([
'status' => 500,
'error' => 'Server error',
'message' => 'Error inesperado durante el procesado'
]);
}
} }