Skip to content

Commit

Permalink
Create TaxClass method added
Browse files Browse the repository at this point in the history
  • Loading branch information
ursuleacv committed Nov 21, 2016
1 parent 4459251 commit f7cd913
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ursuleacv/oauth2-lightspeed",
"description": "LightSpeed OAuth 2.0 Client Provider for The PHP League OAuth2-Client",
"license": "MIT",
"version": "2.0.6",
"version": "2.0.8",
"authors": [
{
"name": "Valentin Ursuleac",
Expand Down
40 changes: 39 additions & 1 deletion src/Provider/MerchantOS.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,44 @@ public function createCustomField($data)
return [];
}

/**
* @param array $data
* @return mixed
*/
public function createTaxClass($data)
{
$params = [];
$response = $this->makeAPICall('Account.TaxClass', 'POST', null, $params, $data);

//validate the response
if (isset($response['TaxClass']) && $this->itemsCount($response) == 1) {
return $response['TaxClass'];
} elseif (isset($response['TaxClass']) && $this->itemsCount($response) > 1) {
return $response['TaxClass'];
}

return [];
}

/**
* @param int $taxClassId
* @param array $params
* @return mixed
*/
public function getTaxClass($taxClassId, $params)
{
$response = $this->makeAPICall('Account.TaxClass', 'GET', $taxClassId, $params, $data = []);

//validate the response
if (isset($response['TaxClass']) && $this->itemsCount($response) == 1) {
return $response['TaxClass'];
} elseif (isset($response['TaxClass']) && $this->itemsCount($response) > 1) {
return $response['TaxClass'];
}

return [];
}

/**
* @param array $data
* @return mixed
Expand Down Expand Up @@ -499,7 +537,7 @@ public function makeAPICall($controlUrl, $action, $uniqueId, $params, $data)
$headers = [
'User-Agent' => $this->userAgent,
'Accept' => 'application/vnd.merchantos-v2+json',
'Authorization' => 'OAuth ' . $this->oauthToken,
'Authorization' => 'Bearer ' . $this->oauthToken,
];

$client = new \GuzzleHttp\Client();
Expand Down

0 comments on commit f7cd913

Please sign in to comment.