Skip to content

Commit 30edb45

Browse files
committed
fix: Switch response message parsing to read warnings key
https://developers.autotrader.co.uk/api#release-notes 18/11/2024
1 parent fd873ae commit 30edb45

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Api/Exceptions/BadRequestException.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@
88

99
class BadRequestException extends ClientException
1010
{
11-
protected array $messages = [];
11+
protected array $warnings = [];
1212

1313
public function __construct(string $message, Request $request, Response $response = null, \Exception $previous = null)
1414
{
1515
if ($response) {
1616
$body = json_decode($response->getBody(), true);
1717

18-
$this->messages = $body['messages'] ?? [];
18+
$this->warnings = $body['warnings'] ?? [];
1919
}
2020

2121
parent::__construct($message, $request, $response, $previous);
2222
}
2323

24-
public function getMessages(): array
24+
public function getWarnings(): array
2525
{
26-
return $this->messages;
26+
return $this->warnings;
2727
}
2828

29-
public function messagesContain(string $pattern): bool
29+
public function warningsContain(string $pattern): bool
3030
{
3131
$pattern = preg_quote($pattern);
3232

33-
foreach ($this->messages as $message) {
33+
foreach ($this->warnings as $message) {
3434
if (preg_match("/$pattern/i", $message)) {
3535
return true;
3636
}

0 commit comments

Comments
 (0)