Skip to content

Commit

Permalink
Merge pull request #28 from picqer/adds-some-available-api-calls
Browse files Browse the repository at this point in the history
Adds additional methods to the client to support more of the Picqer API
  • Loading branch information
stephangroen authored Oct 25, 2020
2 parents 778c14b + 3b8a242 commit 5e54dc0
Showing 1 changed file with 107 additions and 3 deletions.
110 changes: 107 additions & 3 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Client
protected $apiVersion = 'v1';
protected $userAgent = 'Picqer PHP API Client (picqer.com)';

protected $clientVersion = '0.21.1';
protected $clientVersion = '0.22.0';

protected $debug = false;
protected $skipSslVerification = false;
Expand Down Expand Up @@ -144,6 +144,16 @@ public function addProduct($params)
return $this->sendRequest('/products', $params, self::METHOD_POST);
}

public function inactivateProduct($idproduct)
{
return $this->sendRequest('/products/' . $idproduct . '/inactivate', [], self::METHOD_POST);
}

public function activateProduct($idproduct)
{
return $this->sendRequest('/products/' . $idproduct . '/activate', [], self::METHOD_POST);
}

public function getProductStock($idproduct)
{
return $this->sendRequest('/products/' . $idproduct . '/stock');
Expand Down Expand Up @@ -305,9 +315,9 @@ public function addOrder($params)
return $this->sendRequest('/orders', $params, self::METHOD_POST);
}

public function cancelOrder($idorder)
public function cancelOrder($idorder, $params = [])
{
return $this->sendRequest('/orders/' . $idorder, [], self::METHOD_DELETE);
return $this->sendRequest('/orders/' . $idorder, $params, self::METHOD_DELETE);
}

public function getOrderProductStatus($idorder)
Expand All @@ -331,6 +341,11 @@ public function processOrder($idorder)
return $this->sendRequest('/orders/' . $idorder . '/process', null, self::METHOD_POST);
}

public function getOrderNotes($idorder)
{
return $this->sendRequest('/orders/' . $idorder . '/notes');
}

public function addOrderNote($idorder, $note)
{
return $this->sendRequest('/orders/' . $idorder . '/notes', ['note' => $note], self::METHOD_POST);
Expand Down Expand Up @@ -364,6 +379,21 @@ public function updateOrder($idorder, $params)
return $this->sendRequest('/orders/' . $idorder, $params, self::METHOD_PUT);
}

public function allocateStockForOrder($idorder)
{
return $this->sendRequest('/orders/' . $idorder . '/allocate', null, self::METHOD_POST);
}

public function deallocateStockForOrder($idorder)
{
return $this->sendRequest('/orders/' . $idorder . '/deallocate', null, self::METHOD_POST);
}

public function prioritiseOrder($idorder)
{
return $this->sendRequest('/orders/' . $idorder . '/prioritise', null, self::METHOD_POST);
}

/*
* Picklists
*/
Expand Down Expand Up @@ -393,11 +423,31 @@ public function getPicklistByPicklistid($picklistid)
return $result;
}

public function updatePicklist($idpicklist, $params)
{
return $this->sendRequest('/picklists/' . $idpicklist, $params, self::METHOD_PUT);
}

public function closePicklist($idpicklist)
{
return $this->sendRequest('/picklists/' . $idpicklist . '/close', null, self::METHOD_POST);
}

public function cancelPicklist($idpicklist)
{
return $this->sendRequest('/picklists/' . $idpicklist . '/cancel', null, self::METHOD_POST);
}

public function pickProductOnPicklist($idpicklist, $product, $amount)
{
$params = [
'product' => $product,
'amount' => $amount
];

return $this->sendRequest('/picklists/' . $idpicklist . '/pick', $params, self::METHOD_POST);
}

public function pickallPicklist($idpicklist)
{
return $this->sendRequest('/picklists/' . $idpicklist . '/pickall', null, self::METHOD_POST);
Expand Down Expand Up @@ -496,6 +546,39 @@ public function cancelPurchaseorder($idpurchaseorder)
return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/cancel', null, self::METHOD_POST);
}

public function getPurchaseorderProducts($idpurchaseorder)
{
return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/products');
}

public function addProductToPurchaseorder($idpurchaseorder, $idproduct, $amount, $price = null, $deliverydate = null)
{
$params = [
'idproduct' => $idproduct,
'amount' => $amount
];

if (! is_null($price)) {
$params['price'] = $price;
}

if (! is_null($deliverydate)) {
$params['delivery_date'] = $deliverydate;
}

return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/products', $params, self::METHOD_POST);
}

public function updatePurchaseorderProduct($idpurchaseorder, $idpurchaseorder_product, $params)
{
return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/products/' . $idpurchaseorder_product, $params, self::METHOD_PUT);
}

public function removePurchaseorderProduct($idpurchaseorder, $idpurchaseorder_product)
{
return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/products/' . $idpurchaseorder_product, [], self::METHOD_DELETE);
}

public function getReceiptsFromPurchaseorder($idpurchaseorder)
{
return $this->sendRequest('/purchaseorders/' . $idpurchaseorder . '/receipts');
Expand Down Expand Up @@ -545,6 +628,17 @@ public function updateReturn($idreturn, $params)
return $this->sendRequest('/returns/' . $idreturn, $params, self::METHOD_PUT);
}

public function getReturnLogAndComments($idreturn)
{
return $this->sendRequest('/returns/' . $idreturn . '/logs');
}

public function addReturnLogOrChangeStatus($idreturn, $params)
{
return $this->sendRequest('/returns/' . $idreturn . '/logs', $params, self::METHOD_POST);

}

/*
* Returned Products
*/
Expand All @@ -569,6 +663,11 @@ public function removeReturnedProduct($idreturn, $idreturn_product)
return $this->sendRequest('/returns/' . $idreturn . '/returned_products/' . $idreturn_product, null,self::METHOD_DELETE);
}

public function receiveReturnedProducts($idreturn, $params)
{
return $this->sendRequest('/returns/' . $idreturn . '/receive', $params, self::METHOD_POST);
}

/*
* Replacement Products
*/
Expand Down Expand Up @@ -670,6 +769,11 @@ public function deleteBackorder($idbackorder)
return $this->sendRequest('/backorders/' . $idbackorder, null, self::METHOD_DELETE);
}

public function getBackordersForOrder($idorder)
{
return $this->sendRequest('/order/' . $idorder . '/backorders');
}

/*
* Warehouses
*/
Expand Down

0 comments on commit 5e54dc0

Please sign in to comment.