webapix / mygls-sdk

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

Repeated download of labels #14

Closed MottlShean closed 2 years ago

MottlShean commented 2 years ago

Repeated download of labels:

It can happen that user makes mistake or there is a downloading error etc. Repeated download of labels is sometimes necessary.

How can I download labels repeatedly if needs to download it again? Thanks

` private function printPackages(array $packages, ?Shipment $shipment): ?string { $client = new Client(new HttpClient()); $request = new GetPrintedLabels();

    foreach ($packages as $package) {
        $request->addParcelId($package);
    }

    /** @var GetPrintedLabelsResponse $response */
    $response = $client->on($this->account)
        ->request($request);

    if ($response->successfull()) {
        return $response->getPdf();
    }

    if ($shipment) {
        $shipment->update(
            [
                'error_message' => $this->glsErrorsToText($response->errors()),
            ]
        );
    }
    Log::error('printLabel: ' . $this->glsErrorsToText($response->errors()));
    return null;
}

`

zsocakave commented 2 years ago

Hello,

You can download/generate the labels only once, unfortunately MyGLS doesn't support calling GetPrintedLabels multiple times for the same parcel.

MottlShean commented 2 years ago

Thanks for fast reaction. Jan