mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-12-25 06:00:28 +01:00
Sendcloud error handling
This commit is contained in:
parent
3fe2c7a5d9
commit
575ab86157
@ -77,9 +77,9 @@ class SendCloudApi
|
|||||||
$response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]);
|
$response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]);
|
||||||
switch ($response['code']) {
|
switch ($response['code']) {
|
||||||
case 200:
|
case 200:
|
||||||
if (isset($response->parcel))
|
if (isset($response['body']->parcel))
|
||||||
try {
|
try {
|
||||||
return ParcelResponse::fromApiResponse($response->parcel);
|
return ParcelResponse::fromApiResponse($response['body']->parcel);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new SendcloudApiException(previous: $e);
|
throw new SendcloudApiException(previous: $e);
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,11 @@ class SendcloudApiException extends Exception
|
|||||||
{
|
{
|
||||||
public static function fromResponse(array $response) : SendcloudApiException {
|
public static function fromResponse(array $response) : SendcloudApiException {
|
||||||
if (!isset($response['body']) || !is_object($response['body']))
|
if (!isset($response['body']) || !is_object($response['body']))
|
||||||
return new SendcloudApiException();
|
return new SendcloudApiException(print_r($response,true));
|
||||||
|
|
||||||
return new SendcloudApiException(
|
return new SendcloudApiException(
|
||||||
$response['body']->error->message ?? '',
|
print_r($response['body'],true),
|
||||||
$response['body']->error->code ?? 0
|
$response['code']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -353,7 +353,7 @@ abstract class Versanddienstleister
|
|||||||
public function Paketmarke(string $target, string $docType, int $docId): void
|
public function Paketmarke(string $target, string $docType, int $docId): void
|
||||||
{
|
{
|
||||||
$address = $this->GetAdressdaten($docId, $docType);
|
$address = $this->GetAdressdaten($docId, $docType);
|
||||||
if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) {
|
if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) {
|
||||||
$json = json_decode(file_get_contents('php://input'));
|
$json = json_decode(file_get_contents('php://input'));
|
||||||
$ret = [];
|
$ret = [];
|
||||||
if ($json->submit == 'print') {
|
if ($json->submit == 'print') {
|
||||||
|
@ -131,7 +131,7 @@ class Versandart_sendcloud extends Versanddienstleister
|
|||||||
$ret->Errors[] = $result;
|
$ret->Errors[] = $result;
|
||||||
}
|
}
|
||||||
} catch (SendcloudApiException $e) {
|
} catch (SendcloudApiException $e) {
|
||||||
$ret->Errors[] = $e->getMessage();
|
$ret->Errors[] = strval($e);
|
||||||
}
|
}
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user