picqer / picqer-php Goto Github PK
View Code? Open in Web Editor NEWPHP Client for the Picqer API
Home Page: https://picqer.com/en/api
License: MIT License
PHP Client for the Picqer API
Home Page: https://picqer.com/en/api
License: MIT License
Hi Picqer,
In the Client.php
is the method handleRateLimitReached
wrong implemented.
The local $headerInfo
variable in the method sendRequest
will never be updated again after calling handleRateLimitReached
.
To fix this, you have to return the result of the handleRateLimitReached
directly instead of saving it to the $result
variable.
See https://github.com/picqer/picqer-php/blob/main/src/Client.php#L1188C33-L1188C33 for more information.
Instead of
$result = $this->handleRateLimitReached($endpoint, $params, $method, $filters);
Fix:
return $this->handleRateLimitReached($endpoint, $params, $method, $filters);
With kind regards,
Kevin Koenen
While I don't expect the amount of detail I added in the example below I would expect type hints for single type returns and parameters.
For example changing
public function getProductStock($idproduct) {
return $this->sendRequest('/products/' . $idproduct . '/stock');
}
to
/**
* Requesting the stock for a product gives you the stock for the product per warehouse.
* @param string|int $idproduct
* @return array<string,(bool|string|array<int,array<string,int>>)>(3) {
"success"=>bool,
"rate-limit-remaining"=>string,
"data"=> array<int, array<string, int>> {
array<string, int>(7) {
"idwarehouse"=>int,
"stock"=>int,
"reserved"=>int,
"reservedbackorders"=>int,
"reservedpicklists"=>int,
"reservedallocations"=>int,
"freestock"=>int
}
}
}
* @see https://picqer.com/en/api/product-stock
*/
public function getProductStock($idproduct): array {
return $this->sendRequest('/products/' . $idproduct . '/stock');
}
An example API error response would be:
404 Not Found
{ "error": true, "error_code": 8, "error_message": "Not implemented" }
This matches what is described in the docs, and returns both an HTTP status code and a Picqer specific error code.
However, the PHP Client returns does:
$result['error'] = true;
$result['errorcode'] = $headerInfo['http_code'];
$result['errormessage'] = $apiResult;
So from the docs we expected error_code
, yet we got errorcode
(no underscore), and we also expected this to be the Picqer specific error code, but instead it is set to the http_code
from the header, so we don't have access to the Picqer specific error code at all in this response.
There is no possibility to set the iduser of the notification. So it's getting self assigned to the first id right now.
Hi!
Already send an email, and I think I might be unable to create a pull request here (access denied).
Could you add the following to the Client.php
?
public function addPurchaseorder($params)
{
return $this->sendRequest('/purchaseorders', $params, self::METHOD_POST);
}
See results made by millerdigital-rowan, after pull request, dated august 2021.
#32
Please merge these function into your project. They are useful!
Not all methods are present, for example editing a purchase order and creating/updating/deleting purchase order products are missing. But I'm also missing exceptions I can catch, getting an array with data isn't ideal.
When calling delete() from Contact or Webhook entity it produces an error:
Too few arguments to function Picqer\Financials\Moneybird\Connection::delete()
In Picqer\Financials\Moneybird\Actions\Removable line 18:
return $this->connection()->delete($this->getEndpoint() . '/' . urlencode($this->id));
Delete is called without the second $body parameter which produces this error.
I can't create any purchase orders. When i look at the client.php, i cant find any method for it.
I tried to create my own request:
public function addPurchaseorders($data)
{
return $this->sendRequest('/purchaseorders', $data, self::METHOD_POST);
}
this will make a post request to: https://example.picqer.com/api/v1/purchaseorders as it is indicated in the picqer documentation: https://picqer.com/en/api/purchaseorders#h-create-new-purchase-order
But no success, when i pass a warehouse or supplier id that doesn't exists it will return a valid error message but when i send the correct data it will return a HTML string in the error message.
C:\MAMP\htdocs\eye\vendor\picqer\api-client\src\Client.php
` protected function parseRawHeaders()
{
$parsedHeaders = [];
foreach ($this->rawResponseHeaders as $header) {
$headerPieces = explode(':', $header, 2);
if (! isset($headerPieces[0]) || ! isset($headerPieces[1])) {
continue;
}
$parsedHeaders[$headerPieces[0]] = trim($headerPieces[1]);
}
return $parsedHeaders;
}`
โฆ\vendor\picqer\api-client\src\Client.php1005
foreach ($this->rawResponseHeaders as $header) {
stuck on this i cant get any data, on laravel
public function getCustomerByCustomerid($customerid)
{
$result = $this->sendRequest('/customers?customerid=' . urlencode($customerid));
if (is_array($result['data']) && count($result['data']) == 1) {
$result['data'] = $result['data'][0];
} else {
$result['data'] = null;
}
return $result;
}
public function getProductByProductcode($productcode)
{
$result = $this->sendRequest('/products?productcode=' . urlencode($productcode));
if (is_array($result['data']) && count($result['data']) == 1) {
$result['data'] = $result['data'][0];
} else {
$result['data'] = null;
}
return $result;
}
Dumps when data is not defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.