PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / vendor / square / square / src / Legacy / Exceptions / ApiException.php

ApiException.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at vendor/square/square/src/Legacy/Exceptions/ApiException.php

66 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Square\Legacy\Exceptions;
6
7 use CoreInterfaces\Sdk\ExceptionInterface;
8 use Square\Legacy\Http\HttpResponse;
9 use Square\Legacy\Http\HttpRequest;
10
11 /**
12 * Thrown when there is a network error or HTTP response status code is not okay.
13 */
14 class ApiException extends \Exception implements ExceptionInterface
15 {
16 /**
17 * HTTP request
18 *
19 * @var HttpRequest
20 */
21 private $request;
22
23 /**
24 * HTTP response
25 *
26 * @var HttpResponse|null
27 */
28 private $response;
29
30 /**
31 * @param string $reason the reason for raising an exception
32 * @param HttpRequest $request
33 * @param HttpResponse|null $response
34 */
35 public function __construct(string $reason, HttpRequest $request, ?HttpResponse $response)
36 {
37 parent::__construct($reason, \is_null($response) ? 0 : $response->getStatusCode());
38 $this->request = $request;
39 $this->response = $response;
40 }
41
42 /**
43 * Returns the HTTP request
44 */
45 public function getHttpRequest(): HttpRequest
46 {
47 return $this->request;
48 }
49
50 /**
51 * Returns the HTTP response
52 */
53 public function getHttpResponse(): ?HttpResponse
54 {
55 return $this->response;
56 }
57
58 /**
59 * Is the response available?
60 */
61 public function hasResponse(): bool
62 {
63 return !\is_null($this->response);
64 }
65 }
66