Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Model/Organization.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ class Organization extends DataTransferObject

public ?Address $invoice_address;

public Person $contact_person;
public ?Person $contact_person;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ abstract class AbstractJsonContentProcessor implements ProcessorInterface
public function run(MethodInterface $method, ResponseInterface $httpResponse): ?Response
{
if (in_array($httpResponse->getStatusCode(), $this->getHttpStatusCodes())) {
$contentType = explode('; ', $httpResponse->getHeaderLine('Content-Type'));
$mediaType = reset($contentType);
$contentType = explode(';', $httpResponse->getHeaderLine('Content-Type'));
$mediaType = trim(reset($contentType));
if ($mediaType === 'application/json') {
$httpResponse->getBody()->rewind();
$data = json_decode($httpResponse->getBody()->getContents(), true);
Expand Down
6 changes: 5 additions & 1 deletion src/Response/HttpResponseProcessor/ErrorProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ protected function getPayload(
return new Error([
'status' => $data['status'],
'error' => $data['key'],
'message' => $data['error']
'message' => $data['error'],
]);
}
return null;
}
$data['status'] ??= $httpResponse->getStatusCode();
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snapshotpl Wow! I didn't know ??= operator 👍.

$data['error'] ??= $data['key'] ?? '';
$data['message'] ??= $data['error'] ?? '';

return new Error($data);
}
}
1 change: 1 addition & 0 deletions tests/Integration/Client/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ protected function assertSuccessWithFile(Response $response, DataTransferObject
if (!$response->getSuccess()) {
$this->debug(print_r($response->getPayload()->toArray(), true));
}

$this->assertTrue($response->getSuccess());
$this->assertInstanceOf(BinaryContent::class, $payload);
/** @var BinaryContent $payload */
Expand Down