Skip to content

Commit

Permalink
Improved base uri with api support
Browse files Browse the repository at this point in the history
  • Loading branch information
libern committed Aug 24, 2016
1 parent f687455 commit 6e95bb7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Someline/Rest/RestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ public function withoutOAuthToken()
public function get($uri, array $query = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$this->printArray($options);
$response = $this->client->get($uri, array_merge($options, [
'query' => $query,
Expand All @@ -465,6 +466,7 @@ public function get($uri, array $query = [], array $options = [], $api = true)
public function post($uri, array $data = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->post($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -483,6 +485,7 @@ public function post($uri, array $data = [], array $options = [], $api = true)
public function postMultipart($uri, array $multipart = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->post($uri, array_merge($options, [
'multipart' => $multipart,
]));
Expand All @@ -500,6 +503,7 @@ public function postMultipart($uri, array $multipart = [], array $options = [],
public function postMultipartSimple($uri, array $data = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$multipart = [];
foreach ($data as $key => $value) {
$multipart[] = [
Expand All @@ -523,6 +527,7 @@ public function postMultipartSimple($uri, array $data = [], array $options = [],
*/
public function head($uri, array $data = [], array $options = [], $api = true)
{
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->head($uri, array_merge($options, [
'body' => $data,
]));
Expand All @@ -540,6 +545,7 @@ public function head($uri, array $data = [], array $options = [], $api = true)
public function put($uri, array $data = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->put($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -557,6 +563,7 @@ public function put($uri, array $data = [], array $options = [], $api = true)
public function patch($uri, array $data = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->patch($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -574,6 +581,7 @@ public function patch($uri, array $data = [], array $options = [], $api = true)
public function delete($uri, array $data = [], array $options = [], $api = true)
{
$options = $this->configureOptions($options);
$uri = $api ? $uri . $this->getServiceConfig('api_url') : $uri;
$response = $this->client->delete($uri, array_merge($options, [
'form_params' => $data,
]));
Expand Down

0 comments on commit 6e95bb7

Please sign in to comment.