1 | <?php |
||
15 | class JCResponse implements iJCResponse |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * @var ResponseInterface |
||
20 | */ |
||
21 | public $response; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected $body; |
||
27 | |||
28 | /** |
||
29 | * JCResponse constructor. |
||
30 | * @param $response |
||
31 | */ |
||
32 | public function __construct($response) |
||
33 | { |
||
34 | $this->response = $response; |
||
35 | $this->body = $this->response->getBody()->getContents(); |
||
36 | } |
||
37 | |||
38 | |||
39 | public function status() |
||
40 | { |
||
41 | return $this->response->getStatusCode(); |
||
42 | } |
||
43 | |||
44 | public function body() |
||
45 | { |
||
46 | return $this->body; |
||
47 | } |
||
48 | |||
49 | public function headers() |
||
50 | { |
||
51 | return $this->response->getHeaders(); |
||
52 | } |
||
53 | |||
54 | public function json() |
||
55 | { |
||
56 | return GuzzleHttp\json_decode($this->body()); |
||
57 | } |
||
58 | |||
59 | public function success() |
||
63 | } |