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 6e95bb7 commit c9e26f7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Someline/Rest/RestClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$this->printArray($options);
$response = $this->client->get($uri, array_merge($options, [
'query' => $query,
Expand All @@ -466,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->post($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -485,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->post($uri, array_merge($options, [
'multipart' => $multipart,
]));
Expand All @@ -503,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$multipart = [];
foreach ($data as $key => $value) {
$multipart[] = [
Expand All @@ -527,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->head($uri, array_merge($options, [
'body' => $data,
]));
Expand All @@ -545,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->put($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -563,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->patch($uri, array_merge($options, [
'form_params' => $data,
]));
Expand All @@ -581,7 +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;
$uri = $api ? $this->getServiceConfig('api_url') . $uri : $uri;
$response = $this->client->delete($uri, array_merge($options, [
'form_params' => $data,
]));
Expand Down

0 comments on commit c9e26f7

Please sign in to comment.