@@ -53,7 +53,7 @@ class Api
53
53
* @var array
54
54
*/
55
55
private $ endpoints = [
56
- 'ovh-eu ' => 'https://api.ovh.com/1.0 ' ,
56
+ 'ovh-eu ' => 'https://eu. api.ovh.com/1.0 ' ,
57
57
'ovh-ca ' => 'https://ca.api.ovh.com/1.0 ' ,
58
58
'kimsufi-eu ' => 'https://eu.api.kimsufi.com/1.0 ' ,
59
59
'kimsufi-ca ' => 'https://ca.api.kimsufi.com/1.0 ' ,
@@ -223,7 +223,7 @@ public function requestCredentials(
223
223
* @return array
224
224
* @throws \GuzzleHttp\Exception\ClientException if http request is an error
225
225
*/
226
- private function rawCall ($ method , $ path , $ content = null , $ is_authenticated = true )
226
+ private function rawCall ($ method , $ path , $ content = null , $ is_authenticated = true , $ headers = null )
227
227
{
228
228
$ url = $ this ->endpoint . $ path ;
229
229
$ request = new Request ($ method , $ url );
@@ -262,10 +262,12 @@ private function rawCall($method, $path, $content = null, $is_authenticated = tr
262
262
} else {
263
263
$ body = "" ;
264
264
}
265
- $ headers = [
266
- 'Content-Type ' => 'application/json; charset=utf-8 ' ,
267
- 'X-Ovh-Application ' => $ this ->application_key ,
268
- ];
265
+ if (!is_array ($ headers ))
266
+ {
267
+ $ headers = [];
268
+ }
269
+ $ headers ['Content-Type ' ] = 'application/json; charset=utf-8 ' ;
270
+ $ headers ['X-Ovh-Application ' ] = $ this ->application_key ;
269
271
270
272
if ($ is_authenticated ) {
271
273
if (!isset ($ this ->time_delta )) {
@@ -309,10 +311,10 @@ private function decodeResponse(Response $response)
309
311
* @return array
310
312
* @throws \GuzzleHttp\Exception\ClientException if http request is an error
311
313
*/
312
- public function get ($ path , $ content = null )
314
+ public function get ($ path , $ content = null , $ headers = null )
313
315
{
314
316
return $ this ->decodeResponse (
315
- $ this ->rawCall ("GET " , $ path , $ content )
317
+ $ this ->rawCall ("GET " , $ path , $ content, true , $ headers )
316
318
);
317
319
}
318
320
@@ -325,10 +327,10 @@ public function get($path, $content = null)
325
327
* @return array
326
328
* @throws \GuzzleHttp\Exception\ClientException if http request is an error
327
329
*/
328
- public function post ($ path , $ content = null )
330
+ public function post ($ path , $ content = null , $ headers = null )
329
331
{
330
332
return $ this ->decodeResponse (
331
- $ this ->rawCall ("POST " , $ path , $ content )
333
+ $ this ->rawCall ("POST " , $ path , $ content, true , $ headers )
332
334
);
333
335
}
334
336
@@ -341,10 +343,10 @@ public function post($path, $content = null)
341
343
* @return array
342
344
* @throws \GuzzleHttp\Exception\ClientException if http request is an error
343
345
*/
344
- public function put ($ path , $ content )
346
+ public function put ($ path , $ content, $ headers = null )
345
347
{
346
348
return $ this ->decodeResponse (
347
- $ this ->rawCall ("PUT " , $ path , $ content )
349
+ $ this ->rawCall ("PUT " , $ path , $ content, true , $ headers )
348
350
);
349
351
}
350
352
@@ -357,10 +359,10 @@ public function put($path, $content)
357
359
* @return array
358
360
* @throws \GuzzleHttp\Exception\ClientException if http request is an error
359
361
*/
360
- public function delete ($ path , $ content = null )
362
+ public function delete ($ path , $ content = null , $ headers = null )
361
363
{
362
364
return $ this ->decodeResponse (
363
- $ this ->rawCall ("DELETE " , $ path , $ content )
365
+ $ this ->rawCall ("DELETE " , $ path , $ content, true , $ headers )
364
366
);
365
367
}
366
368
0 commit comments