Giter Club home page Giter Club logo

picqer-php's People

Contributors

annajeanine avatar barryvdh avatar casperbakker avatar fmeccanici avatar gerp avatar kleiram avatar lewisvoncken avatar pf-jordy avatar questionmark78 avatar ricklambrechts avatar ricohageman avatar sebastiansommer avatar stephangroen avatar tombaars avatar xyz1123581321 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

picqer-php's Issues

Method handleRateLimitReached wrong implemented in sendRequest method

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

[enhancement] Add type hinting

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');
}

Confusing error codes

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.

addPurchaseOrder missing

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);
}

Add all methods and exceptions

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.

Deleting entities gives too few arguments error

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.

Create new purchase order

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.

picqer issue

Invalid argument supplied for foreach()

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

Undefined array key "data"

    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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.