| 1 | <?php |
||
| 9 | final class Response |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * The http status of the response. |
||
| 13 | * |
||
| 14 | * @var int |
||
| 15 | */ |
||
| 16 | private $_httpCode; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * The response from the API |
||
| 20 | * |
||
| 21 | * @var array |
||
| 22 | */ |
||
| 23 | private $_body; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * A array of headers received with the response. |
||
| 27 | * |
||
| 28 | * @var array array where each header key has an array of values |
||
| 29 | */ |
||
| 30 | private $_headers; |
||
| 31 | |||
| 32 | /** |
||
| 33 | * Create a new instance of Response |
||
| 34 | * |
||
| 35 | * @param int $httpCode |
||
| 36 | * @param array $headers |
||
| 37 | * @param array $body |
||
| 38 | * |
||
| 39 | * @throws \InvalidArgumentException Throw if $httpCode is not an integer between 100 and 600 |
||
| 40 | */ |
||
| 41 | public function __construct($httpCode, array $headers, array $body = []) |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Returns the HTTP status code of the response |
||
| 56 | * |
||
| 57 | * @return int |
||
| 58 | */ |
||
| 59 | public function getHttpCode() |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns an array representing the response from the API |
||
| 66 | * |
||
| 67 | * @return array |
||
| 68 | */ |
||
| 69 | public function getResponse() |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Returns the parsed response headers from the API |
||
| 76 | * |
||
| 77 | * @return array array where each header key has an array of values |
||
| 78 | */ |
||
| 79 | public function getResponseHeaders() |
||
| 83 | } |
||
| 84 |