Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
zopyx committed Mar 28, 2017
1 parent ad22d33 commit e86e851
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Release notes
=============

0.2.0 (2017-03-28)
------------------

- added Partner API version check
7 changes: 4 additions & 3 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ private function standard_headers()

private function check_http_response($response, $status_code_expected = 200, $exc_name = 'SmashdocsError', $decode_json = true)
{
global $API_MIN_VERSION;

$httpcode = $response->getStatusCode();
if ($httpcode != $status_code_expected) {
Expand All @@ -178,9 +179,9 @@ private function check_http_response($response, $status_code_expected = 200, $ex
}

$api_version = $response->getHeaders()['X-Api-Version'][0];
if (version_compare($api_version, $API_MIN_VERSION) < 0) {
$msg = "Partner API version too old: " . $api_version;
throw SmashdocsError($msg);
if (version_compare($api_version, $API_MIN_VERSION, '<')) {
$msg = "Partner API version too old: " . $api_version . ", expected minimal: " . $API_MIN_VERSION;
throw new SmashdocsError($msg);
}

if ($decode_json) {
Expand Down

0 comments on commit e86e851

Please sign in to comment.