Skip to content

Commit

Permalink
Added support for order tags and delete requests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephangroen committed Mar 4, 2015
1 parent 19f055d commit 89a45d9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions src/Picqer/Api/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Client {
protected $apiversion = 'v1';

protected $debug = false;
protected $clientversion = '0.9.8';
protected $clientversion = '0.9.9';

protected $skipverification = false;

Expand Down Expand Up @@ -248,6 +248,28 @@ public function closeOrder($idorder)
return $result;
}

public function getOrderTags($idorder)
{
$result = $this->sendRequest('/orders/' . $idorder . '/tags');
return $result;
}

public function addOrderTag($idorder, $idtag)
{
$params = array(
'idtag' => $idtag
);

$result = $this->sendRequest('/orders/' . $idorder . '/tags' , $params, 'POST');
return $result;
}

public function removeOrderTag($idorder, $idtag)
{
$result = $this->sendRequest('/orders/' . $idorder . '/tags/' . $idtag, array(), 'DELETE');
return $result;
}

/*
* Orders
*/
Expand Down Expand Up @@ -485,7 +507,7 @@ protected function sendRequest($endpoint, $params = array(), $method = 'GET', $f
curl_setopt($ch, CURLOPT_USERPWD, $this->username . ':' . $this->password);
curl_setopt($ch, CURLOPT_USERAGENT, 'Picqer PHP API Client ' . $this->clientversion . ' (www.picqer.com)');
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Accept: application/json'));
if ($method == 'POST' || $method == 'PUT')
if ($method == 'POST' || $method == 'PUT' || $method == 'DELETE')
{
$data = $this->prepareData($params);
if ($this->debug)
Expand All @@ -498,6 +520,9 @@ protected function sendRequest($endpoint, $params = array(), $method = 'GET', $f
} elseif ($method == 'PUT')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
} elseif ($method == 'DELETE')
{
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
}
Expand Down

0 comments on commit 89a45d9

Please sign in to comment.