In ParcelAdapter::parseAddResponse, the $responseObject->PdfLabel member is an array of SimpleXMLElement (even for a single label) but it's casted to a string resulting in an empty Pdf.
I removed the cast and changed the AddParcelResponse::setPdfLabel method signature so that $pdfLabel parameter is an Array:
public function setPdfLabel(array $pdfLabel): void
furthermore I added a method to add a pdfLabel:
public function addPdfLabel(string $pdfLabel) : void {
$this->pdfLabel[] = $pdfLabel;
}
Added also a method to retrieve the number of labels in AddParcelResponse:
public function getNumLabels() : int {
if(empty($this->pdfLabel)) {
return 0;
} else if(is_array($this->pdfLabel)) {
return count($this->pdfLabel);
}
}
and modified the getPdfLabel() method:
public function getPdfLabel(int $idx): ?string {
return $this->pdfLabel[$idx] ?? null;
}
Finally in the ParcelAdapter::parseAddResponse method i changed this line:
In ParcelAdapter::parseAddResponse, the $responseObject->PdfLabel member is an array of SimpleXMLElement (even for a single label) but it's casted to a string resulting in an empty Pdf. I removed the cast and changed the AddParcelResponse::setPdfLabel method signature so that $pdfLabel parameter is an Array:
public function setPdfLabel(array $pdfLabel): void
furthermore I added a method to add a pdfLabel:
Added also a method to retrieve the number of labels in AddParcelResponse:
and modified the getPdfLabel() method:
Finally in the ParcelAdapter::parseAddResponse method i changed this line:
$response->setPdfLabel((string)$parcel->PdfLabel);
with this:
I'm not an expert about GLS API so I don't know if these changes are correct. For now this is for me the only way to get the Labels.