1 | <?php |
||
8 | class ApiResponse |
||
9 | { |
||
10 | use AttributesMassAssignable; |
||
11 | |||
12 | protected $headers; |
||
13 | protected $content; |
||
14 | protected $statusCode; |
||
15 | |||
16 | /** |
||
17 | * Construct object |
||
18 | * |
||
19 | * @param int $statusCode |
||
20 | * @param string $content |
||
21 | * @param array $headers |
||
22 | */ |
||
23 | public function __construct($statusCode, $content, $headers = array()) |
||
36 | |||
37 | /** |
||
38 | * Get array format of api response |
||
39 | * @return array |
||
40 | */ |
||
41 | public function toArray() : array |
||
45 | |||
46 | /** |
||
47 | * Get json format of api response |
||
48 | * @return string |
||
49 | */ |
||
50 | public function toJson() : string |
||
54 | |||
55 | /** |
||
56 | * Get the status code of the response |
||
57 | * @return numeric |
||
58 | */ |
||
59 | public function getStatusCode() : int |
||
63 | |||
64 | public function getHeaders() |
||
68 | |||
69 | /** |
||
70 | * Checks if api call was successful ie 200, 201 etc |
||
71 | * return bool |
||
72 | */ |
||
73 | public function isSuccess() : bool |
||
77 | |||
78 | |||
79 | public function __toString() |
||
83 | } |
||
84 |