1 | <?php |
||
10 | class Postpay |
||
11 | { |
||
12 | /** |
||
13 | * @const string Version number of the Postpay SDK. |
||
14 | */ |
||
15 | const VERSION = '0.0.1'; |
||
16 | |||
17 | /** |
||
18 | * @const string Default API version for requests. |
||
19 | */ |
||
20 | const DEFAULT_API_VERSION = 'v1'; |
||
21 | |||
22 | /** |
||
23 | * @const string GraphQL path. |
||
24 | */ |
||
25 | const GRAPHQL_PATH = '/graphql'; |
||
26 | |||
27 | /** |
||
28 | * @const string GraphQL version for requests. |
||
29 | */ |
||
30 | const GRAPHQL_VERSION = 'graphql'; |
||
31 | |||
32 | /** |
||
33 | * @const string The name of the environment variable that contains the merchant ID. |
||
34 | */ |
||
35 | const MERCHANT_ID_ENV_NAME = 'POSTPAY_MERCHANT_ID'; |
||
36 | |||
37 | /** |
||
38 | * @const string The name of the environment variable that contains the secret key. |
||
39 | */ |
||
40 | const SECRET_KEY_ENV_NAME = 'POSTPAY_SECRET_KEY'; |
||
41 | |||
42 | /** |
||
43 | * @var Client The Postpay client service. |
||
44 | */ |
||
45 | protected $client; |
||
46 | |||
47 | /** |
||
48 | * @var array The basic auth credentials. |
||
49 | */ |
||
50 | protected $auth; |
||
51 | |||
52 | /** |
||
53 | * @var string|null The default API version. |
||
54 | */ |
||
55 | protected $apiVersion; |
||
56 | |||
57 | /** |
||
58 | * @var bool Set to true for sandbox requests. |
||
59 | */ |
||
60 | protected $sandbox; |
||
61 | |||
62 | /** |
||
63 | * @var \Postpay\Http\Response|null Stores the last request. |
||
64 | */ |
||
65 | protected $lastResponse; |
||
66 | |||
67 | /** |
||
68 | * Instantiates a new Postpay super-class object. |
||
69 | * |
||
70 | * @param array $config |
||
71 | * |
||
72 | * @throws PostpayException |
||
73 | */ |
||
74 | 7 | public function __construct(array $config = []) |
|
92 | |||
93 | /** |
||
94 | * Returns the client service. |
||
95 | * |
||
96 | * @return Client |
||
97 | */ |
||
98 | 1 | public function getClient() |
|
99 | { |
||
100 | 1 | return $this->client; |
|
101 | } |
||
102 | |||
103 | /** |
||
104 | * Returns the last response returned from API. |
||
105 | * |
||
106 | * @return \Postpay\Http\Response|null |
||
107 | */ |
||
108 | public function getLastResponse() |
||
112 | |||
113 | /** |
||
114 | * Sends a GET request to API and returns the response. |
||
115 | * |
||
116 | * @param string $path |
||
117 | * @param array $params |
||
118 | * |
||
119 | * @return \Postpay\Http\Response |
||
120 | * |
||
121 | * @throws PostpayException |
||
122 | */ |
||
123 | 1 | public function get($path, array $params = []) |
|
127 | |||
128 | /** |
||
129 | * Sends a POST request to API and returns the response. |
||
130 | * |
||
131 | * @param string $path |
||
132 | * @param array $params |
||
133 | * |
||
134 | * @return \Postpay\Http\Response |
||
135 | * |
||
136 | * @throws PostpayException |
||
137 | */ |
||
138 | 1 | public function post($path, array $params = []) |
|
142 | |||
143 | /** |
||
144 | * Sends a PUT request to API and returns the response. |
||
145 | * |
||
146 | * @param string $path |
||
147 | * @param array $params |
||
148 | * |
||
149 | * @return \Postpay\Http\Response |
||
150 | * |
||
151 | * @throws PostpayException |
||
152 | */ |
||
153 | 1 | public function put($path, array $params = []) |
|
157 | |||
158 | /** |
||
159 | * Sends a PATCH request to API and returns the response. |
||
160 | * |
||
161 | * @param string $path |
||
162 | * @param array $params |
||
163 | * |
||
164 | * @return \Postpay\Http\Response |
||
165 | * |
||
166 | * @throws PostpayException |
||
167 | */ |
||
168 | 1 | public function patch($path, array $params = []) |
|
172 | |||
173 | /** |
||
174 | * Sends a DELETE request to API and returns the response. |
||
175 | * |
||
176 | * @param string $path |
||
177 | * @param array $params |
||
178 | * |
||
179 | * @return \Postpay\Http\Response |
||
180 | * |
||
181 | * @throws PostpayException |
||
182 | */ |
||
183 | 1 | public function delete($path, array $params = []) |
|
187 | |||
188 | /** |
||
189 | * Sends a query to GraphQL API and returns the response. |
||
190 | * |
||
191 | * @param string $query |
||
192 | * @param array $variables |
||
193 | * |
||
194 | * @return \Postpay\Http\Response |
||
195 | * |
||
196 | * @throws PostpayException |
||
197 | */ |
||
198 | 1 | public function query($query, array $variables = []) |
|
211 | |||
212 | /** |
||
213 | * Sends a request to API and returns the response. |
||
214 | * |
||
215 | * @param string $method |
||
216 | * @param string $path |
||
217 | * @param array $params |
||
218 | * @param string|null $apiVersion |
||
219 | * |
||
220 | * @return \Postpay\Http\Response |
||
221 | * |
||
222 | * @throws PostpayException |
||
223 | */ |
||
224 | 6 | public function request( |
|
240 | } |
||
241 |