webapix / mygls-sdk

An unofficial lightweight PHP SDK for the MyGLS (GLS logistics) REST API.
MIT License
28 stars 10 forks source link

Incorrect endpoint url #23

Closed piotrpog closed 10 months ago

piotrpog commented 1 year ago

Url for requests is incorrect and causes requests to return code 404. It is missing '.svc/json/ part. So, in Client.php file, it should be:

    public function request(Request $request): Response
    {
        if (! $this->account) {
            throw new InvalidArgumentException('You need to define an account to make a request!');
        }
        $url = rtrim($this->account->apiURL(), '/').'/' . 'ParcelService.svc' . '/' . 'json' . '/' . $request->getEndpoint();
        $response = $this->client->request(
            $request->getMethod(),
            $url,
            [
                'json' => $this->payload($request),
                'http_errors' => false,
            ]
        );

        if (! $this->successful($response)) {
            throw new RequestException($response);
        }

        return $this->decodeResponse(
            $response,
            $request
        );
    }
PavelWeirich commented 10 months ago

Everything is OK. Tested on version 1.7.3. Pass the entire URL (e.g. https://api.mygls.cz/ParcelService.svc/json/) to the apiUrl parameter in the class Account.