mirror of
https://github.com/OpenXE-org/OpenXE.git
synced 2024-11-14 12:07:15 +01:00
Sendcloud ParcelCreation added additional rules for DPD
This commit is contained in:
parent
56cfc54aa5
commit
8c1f434833
@ -12,19 +12,29 @@ class ParcelCreation extends ParcelBase
|
||||
{
|
||||
public ?int $SenderAddressId = null;
|
||||
|
||||
// const DEFAUlT_LENGTH = 150;
|
||||
|
||||
public function toApiRequest(): array
|
||||
{
|
||||
|
||||
define("DEFAULT_LENGTH", 150);
|
||||
|
||||
// DPD-special condition, to be checked in detail
|
||||
$address_2 = substr($this->Adress2, 0, 35);
|
||||
$company_name = substr($this->CompanyName, 0, 35);
|
||||
$length = strlen($address_2)+strlen($company_name);
|
||||
if ($length > 34) {
|
||||
$company_name_length = 34-strlen($address_2);
|
||||
if ($company_name_length < 0) {
|
||||
$company_name_lenght = 0;
|
||||
}
|
||||
$company_name = substr($company_name, 0, $company_name_length);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'name' => substr($this->Name, 0, 75),
|
||||
'company_name' => substr($this->CompanyName, 0, 50),
|
||||
'address' => substr($this->Address, 0, 75),
|
||||
'address_2' => substr($this->Address2, 0, 75),
|
||||
'house_number' => substr($this->HouseNumber, 0, 20),
|
||||
'name' => substr($this->Name, 0, 35),
|
||||
'company_name' => $company_name,
|
||||
'address' => substr($this->Address, 0, 35),
|
||||
'address_2' => $address_2,
|
||||
'house_number' => substr($this->HouseNumber, 0, 8),
|
||||
'city' => substr($this->City, 0, 30),
|
||||
'postal_code' => substr($this->PostalCode, 0, 12),
|
||||
'telephone' => substr($this->Telephone, 0, 20),
|
||||
@ -52,7 +62,8 @@ class ParcelCreation extends ParcelBase
|
||||
if ($this->CustomsShipmentType !== null) {
|
||||
$data['customs_shipment_type'] = substr($this->CustomsShipmentType, 0, DEFAULT_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user