1 | <?php |
||
30 | class DefaultApiClient extends AbstractApiClient |
||
31 | { |
||
32 | /** |
||
33 | * Default request headers. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | protected $headers = array( |
||
38 | 'Accept' => 'application/json' |
||
39 | ); |
||
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | public function makeApiCall(RequestInterface $request) |
||
79 | |||
80 | /** |
||
81 | * Creates response object from response array. |
||
82 | * |
||
83 | * @param array $response |
||
84 | * |
||
85 | * @return Response API Response object |
||
86 | * |
||
87 | * @throws ClientException Thrown when response object could not be created |
||
88 | */ |
||
89 | private function createResponseObject(array $response) |
||
97 | |||
98 | /** |
||
99 | * Adds authentication details to request with OAuth decorator. |
||
100 | * |
||
101 | * @param RequestInterface $request |
||
102 | * |
||
103 | * @return OAuthDecorator OAuth ready decorated Request |
||
104 | */ |
||
105 | private function authenticateRequest(RequestInterface $request) |
||
113 | |||
114 | /** |
||
115 | * Sends the actual request. |
||
116 | * |
||
117 | * @param RequestInterface $request |
||
118 | * |
||
119 | * @return Response Response object created from raw response |
||
120 | * |
||
121 | * @throws ClientException Thrown when response could not be created. |
||
122 | */ |
||
123 | private function sendRequest(RequestInterface $request) |
||
131 | |||
132 | /** |
||
133 | * Refreshes the token via then authenticator. |
||
134 | * |
||
135 | * @param RequestInterface $request |
||
136 | * |
||
137 | * @return void |
||
138 | */ |
||
139 | private function getNewToken(RequestInterface $request) |
||
150 | |||
151 | /** |
||
152 | * Adds default headers to the headers per request, only if the key |
||
153 | * cannot not be found in the headers per request. |
||
154 | * |
||
155 | * @param array $headers |
||
156 | * |
||
157 | * @return array |
||
158 | */ |
||
159 | private function addDefaultHeaders($headers) |
||
169 | } |
||
170 |