Total Complexity | 6 |
Total Lines | 46 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
8 | class SproutsocialsApiException extends \Exception |
||
9 | { |
||
10 | protected Response $response; |
||
11 | |||
12 | 2 | public function __construct(Response $response) |
|
13 | { |
||
14 | 2 | $this->response = $response; |
|
15 | 2 | $error = $this->response->json('error', ''); |
|
16 | 2 | if (!$error) { |
|
17 | 2 | $error = $this->response->json('message', ''); |
|
18 | } |
||
19 | |||
20 | 2 | parent::__construct("Api returned error: \"{$error}\". Meta: {$this->getResponseApiVersion()}|{$this->getResponseServerVersion()}|{$this->getResponseUUID()}", $response->status()); |
|
21 | } |
||
22 | |||
23 | |||
24 | /** |
||
25 | * @return Response |
||
26 | */ |
||
27 | 1 | public function getResponse(): Response |
|
28 | { |
||
29 | 1 | return $this->response; |
|
30 | } |
||
31 | |||
32 | /** |
||
33 | * @return Response |
||
34 | */ |
||
35 | 2 | public function getResponseUUID(): string |
|
38 | } |
||
39 | |||
40 | /** |
||
41 | * @return Response |
||
42 | */ |
||
43 | 2 | public function getResponseServerVersion(): string |
|
44 | { |
||
45 | 2 | return (string)$this->response->header('X-Sprout-Server-Version'); |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return Response |
||
50 | */ |
||
51 | 2 | public function getResponseApiVersion(): string |
|
54 | } |
||
55 | } |
||
56 |