1 | <?php |
||
8 | class Client |
||
9 | { |
||
10 | /** |
||
11 | * Demo environment URL. |
||
12 | */ |
||
13 | const DEMO_URL = 'https://demo.vivapayments.com'; |
||
14 | |||
15 | /** |
||
16 | * Production environment URL. |
||
17 | */ |
||
18 | const PRODUCTION_URL = 'https://www.vivapayments.com'; |
||
19 | |||
20 | /** |
||
21 | * @var \GuzzleHttp\ClientInterface |
||
22 | */ |
||
23 | protected $client; |
||
24 | |||
25 | /** |
||
26 | * Constructor. |
||
27 | * |
||
28 | * @param \GuzzleHttp\ClientInterface $client |
||
29 | */ |
||
30 | public function __construct(ClientInterface $client) |
||
34 | |||
35 | /** |
||
36 | * Make a GET request. |
||
37 | * |
||
38 | * @param string $url |
||
39 | * @param array $options |
||
40 | * @return object |
||
41 | */ |
||
42 | public function get($url, array $options = []) |
||
48 | |||
49 | /** |
||
50 | * Make a POST request. |
||
51 | * |
||
52 | * @param string $url |
||
53 | * @param array $options |
||
54 | * @return object |
||
55 | */ |
||
56 | public function post($url, array $options = []) |
||
62 | |||
63 | /** |
||
64 | * Make a PATCH request. |
||
65 | * |
||
66 | * @param string $url |
||
67 | * @param array $options |
||
68 | * @return object |
||
69 | */ |
||
70 | public function patch($url, array $options = []) |
||
76 | |||
77 | /** |
||
78 | * Make a DELETE request. |
||
79 | * |
||
80 | * @param string $url |
||
81 | * @param array $options |
||
82 | * @return object |
||
83 | */ |
||
84 | public function delete($url, array $options = []) |
||
90 | |||
91 | /** |
||
92 | * Get the response body. |
||
93 | * |
||
94 | * @param \GuzzleHttp\Psr7\Response $response |
||
95 | * @return mixed |
||
96 | * |
||
97 | * @throws \Sebdesign\VivaPayments\VivaException |
||
98 | */ |
||
99 | protected function getBody(Response $response) |
||
109 | |||
110 | /** |
||
111 | * Get the URL. |
||
112 | * |
||
113 | * @return \GuzzleHttp\Psr7\Uri |
||
114 | */ |
||
115 | public function getUrl() |
||
119 | |||
120 | /** |
||
121 | * Get the Guzzle client. |
||
122 | * |
||
123 | * @return \GuzzleHttp\Client |
||
124 | */ |
||
125 | public function getClient() |
||
129 | } |
||
130 |