1 | <?php |
||
7 | abstract class RestGateway extends Gateway |
||
8 | { |
||
9 | /** |
||
10 | * Get the base uri for gateway to make the requests. |
||
11 | * |
||
12 | * @return string |
||
13 | */ |
||
14 | abstract protected function getBaseUri(); |
||
15 | |||
16 | /** |
||
17 | * Authenticate gateway. |
||
18 | * It is common for rest gateways to authenticate with basic auth, bearer |
||
19 | * or custom header authentication. |
||
20 | * So here we can add directly to client the appropriate authentication |
||
21 | * info. |
||
22 | * |
||
23 | * @param RestClient $client |
||
24 | * @return void |
||
25 | */ |
||
26 | abstract protected function authenticate(RestClient $client); |
||
27 | |||
28 | /** |
||
29 | * Returns the RestClient for given resource name. |
||
30 | * |
||
31 | * Resource name is usually the uri path for the resource to call. |
||
32 | * In conjuction with base uri will create the full endpoint uri of |
||
33 | * gateway to request. |
||
34 | * |
||
35 | * @param string $resource |
||
36 | * @return RestClient |
||
37 | */ |
||
38 | 1 | protected function getRestClient($resource) |
|
45 | |||
46 | /** |
||
47 | * Factory method for creating the rest client. |
||
48 | * |
||
49 | * @param string $uri The base uri path of gateway. |
||
50 | * @param string $resource The resource path to request. |
||
51 | * @return RestClient |
||
52 | */ |
||
53 | protected function createClient($uri, $resource) |
||
57 | |||
58 | /** |
||
59 | * Returns the final Response object |
||
60 | * |
||
61 | * @param array $response The response returned from RestClient @see |
||
62 | * RestClient::resolveResponse method |
||
63 | * @return \Larium\Pay\Response |
||
64 | */ |
||
65 | 2 | protected function getResponse(array $response) |
|
78 | } |
||
79 |