2024-06-18
This commit is contained in:
@ -40,9 +40,6 @@ class Nubox extends Ideal\Service
|
||||
->withHeader('Content-Type', 'application/json')
|
||||
->withHeader('Accept', 'application/json');
|
||||
$response = $this->client->sendRequest($request);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $response->getStatusCode());
|
||||
}
|
||||
$sistemas = json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
$this->setToken($inmobiliaria_rut, $response->getHeaderLine('Token'))
|
||||
@ -133,9 +130,6 @@ class Nubox extends Ideal\Service
|
||||
];
|
||||
$uri = 'contabilidad/libro-mayor?' . http_build_query($query);
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $response->getStatusCode());
|
||||
}
|
||||
return json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
}
|
||||
public function getLibroDiario(int $inmobiliaria_rut, DateTimeInterface $from, DateTimeInterface $to): array
|
||||
@ -157,10 +151,6 @@ class Nubox extends Ideal\Service
|
||||
];
|
||||
$uri = 'contabilidad/libro-diario?' . http_build_query($query);
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
$this->logger->debug($uri);
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $response->getStatusCode());
|
||||
}
|
||||
return json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
}
|
||||
public function getMesCuenta(int $inmobiliaria_rut, string $cuenta, DateTimeInterface $mes): array
|
||||
@ -186,11 +176,29 @@ class Nubox extends Ideal\Service
|
||||
];
|
||||
$uri = 'contabilidad/libro-mayor?' . http_build_query($query);
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $response->getStatusCode());
|
||||
}
|
||||
return json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
}
|
||||
public function getFacturas(int $inmobiliaria_rut, DateTimeInterface $dia): array
|
||||
{
|
||||
//$inmobiliaria = $this->nuboxRepository->fetchByInmobiliaria($inmobiliaria_rut);
|
||||
$query = [
|
||||
'factura',
|
||||
'documento',
|
||||
'78017310-6',
|
||||
'estadoVenta',
|
||||
551,
|
||||
'FAC-EL',
|
||||
1
|
||||
];
|
||||
$uri = implode('/', $query);
|
||||
$response = $this->send($uri, $inmobiliaria_rut);
|
||||
$content = json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
if (!is_array($content)) {
|
||||
$this->logger->error($content);
|
||||
return [];
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
private function send(string $uri, int $inmobiliaria_rut, string $method = 'GET', ?StreamInterface $body = null): ResponseInterface
|
||||
{
|
||||
@ -200,6 +208,12 @@ class Nubox extends Ideal\Service
|
||||
if ($body !== null) {
|
||||
$request = $request->withBody($body);
|
||||
}
|
||||
return $this->client->sendRequest($request);
|
||||
$response = $this->client->sendRequest($request);
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
$json = json_decode($response->getBody()->getContents(), JSON_OBJECT_AS_ARRAY);
|
||||
$message = $json['Message'] ?? '';
|
||||
throw new Exception\HttpResponse($response->getReasonPhrase(), $message, $response->getStatusCode());
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user