pixelpeter / laravel5-woocommerce-api-client

Laravel 5 wrapper for the Woocommerce REST API
MIT License
125 stars 48 forks source link

Module isn't work #29

Closed Marycka9 closed 6 years ago

Marycka9 commented 6 years ago

I install your module and I have error:

/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php Client/HttpClient.php

    /**
     * Look for errors in the request.
     *
     * @param array $parsedResponse Parsed body response.
     */
    protected function lookForErrors($parsedResponse)
    {
        // Any non-200/201/202 response code indicates an error.
        if (!\in_array($this->response->getCode(), ['200', '201', '202'])) {
            $errors = !empty($parsedResponse['errors']) ? $parsedResponse['errors'] : $parsedResponse;

            if (!empty($errors[0])) {
                $errorMessage = $errors[0]['message'];
                $errorCode    = $errors[0]['code'];
            } else {
                $errorMessage = $errors['message'];
                **$errorCode    = $errors['code'];** . // This error
            }

            throw new HttpClientException(\sprintf('Error: %s [%s]', $errorMessage, $errorCode), $this->response->getCode(), $this->request, $this->response);
        }
    }

    /**
     * Process response.
     *
     * @return array
     */
    protected function processResponse()
    {
        $body = $this->response->getBody();

        if (0 === strpos(bin2hex($body), 'efbbbf')) {
           $body = substr($body, 3);
        }

        $parsedResponse = \json_decode($body, true);

Arguments"Undefined index: code"

pixelpeter commented 6 years ago

This is not an issue with this package. It's related to https://github.com/woocommerce/wc-api-php. I'm just wrapping this functionality