Skip to content

Commit

Permalink
get tags, update discount
Browse files Browse the repository at this point in the history
  • Loading branch information
ursuleacv committed Dec 19, 2016
1 parent 23bb0e2 commit a0e9e42
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
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.9",
"version": "2.0.10",
"authors": [
{
"name": "Valentin Ursuleac",
Expand Down
50 changes: 50 additions & 0 deletions src/Provider/MerchantOS.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ public function setUserAgent($agent)
$this->userAgent = $agent;
}

/**
* @param $params
* @return array
*/
public function getTags($params = [])
{
$response = $this->makeAPICall('Account.Tag', 'GET', null, $params, null);

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

return [];
}

/**
* @param $itemId
* @param $params
Expand Down Expand Up @@ -489,6 +506,39 @@ public function createDiscount($data)
return [];
}

/**
* @param $discountId
* @param $data
* @return mixed
*/
public function updateDiscount($discountId = null, $data)
{
$params = [];
$response = $this->makeAPICall('Account.Discount', 'PUT', $discountId, $params, $data);

if (isset($response['Discount']) && $this->itemsCount($response) > 0) {
return $response['Discount'];
}

return [];
}

/**
* @param $discountId
* @return mixed
*/
public function deleteDiscount($discountId = null)
{
$params = [];
$response = $this->makeAPICall('Account.Discount', 'DELETE', $discountId, $params, null);

if (isset($response['Discount']) && $this->itemsCount($response) > 0) {
return $response['Discount'];
}

return [];
}

/**
* @param int $saleId
* @param array $data
Expand Down

0 comments on commit a0e9e42

Please sign in to comment.