Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
Correct API version not being used for non-GET requests. (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
swichers authored Dec 5, 2019
1 parent d66507c commit 26f414f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,31 @@ public function __construct(HttpClientInterface $httpClient, ActionManagerInterf
*/
public function apiDelete($method, array $data, int $api_version = NULL): ResponseInterface {

return $this->apiRequest('DELETE', $method, ['json' => $data]);
return $this->apiRequest('DELETE', $method, ['json' => $data], $api_version);
}

/**
* {@inheritdoc}
*/
public function apiGet($method, array $params = [], int $api_version = NULL): ResponseInterface {

return $this->apiRequest(
'GET',
$method,
['query' => $params],
$api_version
);
return $this->apiRequest('GET', $method, ['query' => $params], $api_version);
}

/**
* {@inheritdoc}
*/
public function apiPost($method, array $data, int $api_version = NULL): ResponseInterface {

return $this->apiRequest('POST', $method, ['json' => $data]);
return $this->apiRequest('POST', $method, ['json' => $data], $api_version);
}

/**
* {@inheritdoc}
*/
public function apiPut($method, array $data, int $api_version = NULL): ResponseInterface {

return $this->apiRequest('PUT', $method, ['json' => $data]);
return $this->apiRequest('PUT', $method, ['json' => $data], $api_version);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions tests/Unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,13 @@ public function testApiPost() {
'https://www.ligula-dapibus.acsitefactory.com/api/v1/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);

$resp = $this->getClient()->apiPost('Unit/Test', [], 2);
$this->assertInstanceOf(ResponseInterface::class, $resp);
$this->assertEquals(
'https://www.ligula-dapibus.acsitefactory.com/api/v2/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);
}

/**
Expand All @@ -392,6 +399,13 @@ public function testApiDelete() {
'https://www.ligula-dapibus.acsitefactory.com/api/v1/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);

$resp = $this->getClient()->apiDelete('Unit/Test', [], 2);
$this->assertInstanceOf(ResponseInterface::class, $resp);
$this->assertEquals(
'https://www.ligula-dapibus.acsitefactory.com/api/v2/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);
}

/**
Expand All @@ -409,6 +423,13 @@ public function testApiPut() {
'https://www.ligula-dapibus.acsitefactory.com/api/v1/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);

$resp = $this->getClient()->apiPut('Unit/Test', [], 2);
$this->assertInstanceOf(ResponseInterface::class, $resp);
$this->assertEquals(
'https://www.ligula-dapibus.acsitefactory.com/api/v2/Unit/Test',
$resp->getOriginalResponse()->getInfo('url')
);
}

/**
Expand Down

0 comments on commit 26f414f

Please sign in to comment.