Merge pull request #26 from exciler/sendcloud
Basic Sendcloud integration with Shipment rework
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Bank
|
||||
{
|
||||
public string $accountOwner;
|
||||
public string $bankName;
|
||||
public string $iban;
|
||||
public string $note1;
|
||||
public string $note2;
|
||||
public ?string $bic;
|
||||
public ?string $accountreference;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Communication
|
||||
{
|
||||
public ?string $phone;
|
||||
public ?string $email;
|
||||
public ?string $contactPerson;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Contact
|
||||
{
|
||||
public ?Communication $Communication;
|
||||
public ?NativeAddress $Address;
|
||||
public ?Name $Name;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Country
|
||||
{
|
||||
public ?string $country;
|
||||
public string $countryISOCode;
|
||||
public ?string $state;
|
||||
|
||||
public static function Create(string $isoCode, ?string $state = null):Country {
|
||||
$obj = new Country();
|
||||
$obj->countryISOCode = $isoCode;
|
||||
$obj->state = $state;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class CreateShipmentOrderRequest
|
||||
{
|
||||
public Version $Version;
|
||||
public ShipmentOrder $ShipmentOrder;
|
||||
public ?string $labelResponseType;
|
||||
public ?string $groupProfileName;
|
||||
public ?string $labelFormat;
|
||||
public ?string $labelFormatRetoure;
|
||||
public ?string $combinedPrinting;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class CreateShipmentOrderResponse
|
||||
{
|
||||
public Version $Version;
|
||||
public Statusinformation $Status;
|
||||
public ?CreationState $CreationState;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class CreationState
|
||||
{
|
||||
public string $sequenceNumber;
|
||||
public ?string $shipmentNumber;
|
||||
public ?string $returnShipmentNumber;
|
||||
public LabelData $LabelData;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Customer
|
||||
{
|
||||
public Name $Name;
|
||||
public ?string $vatID;
|
||||
public string $EKP;
|
||||
public NativeAddress $Address;
|
||||
public Contact $Contact;
|
||||
public ?Bank $Bank;
|
||||
public ?string $note;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class DeleteShipmentOrderRequest
|
||||
{
|
||||
public Version $Version;
|
||||
public string $shipmentNumber;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class DeleteShipmentOrderResponse
|
||||
{
|
||||
public Version $Version;
|
||||
public Statusinformation $Status;
|
||||
public ?DeletionState $DeletionState;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class DeletionState
|
||||
{
|
||||
public string $shipmentNumber;
|
||||
public Statusinformation $Status;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class DeliveryAddress
|
||||
{
|
||||
public ?NativeAddress $NativeAddress;
|
||||
public ?Postfiliale $PostOffice;
|
||||
public ?PackStation $PackStation;
|
||||
public ?string $streetNameCode;
|
||||
public ?string $streetNumberCode;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Dimension
|
||||
{
|
||||
public int $length;
|
||||
public int $width;
|
||||
public int $height;
|
||||
public ?string $unit;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ExportDocPosition
|
||||
{
|
||||
public string $description;
|
||||
public string $countryCodeOrigin;
|
||||
public string $customsTariffNumber;
|
||||
public int $amount;
|
||||
public float $netWeightInKG;
|
||||
public float $customsValue;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ExportDocument
|
||||
{
|
||||
const TYPE_PRESENT = 'PRESENT';
|
||||
const TYPE_DOCUMENT = 'DOCUMENT';
|
||||
const TYPE_COMMERCIAL_GOODS = 'COMMERCIAL_GOODS';
|
||||
const TYPE_COMMERCIAL_SAMPLE = 'COMMERCIAL_SAMPLE';
|
||||
const TYPE_RETURN_OF_GOODS= 'RETURN_OF_GOODS';
|
||||
const TYPE_OTHER = 'OTHER';
|
||||
|
||||
const TERMS_DDP = 'DDP';
|
||||
const TERMS_DXV = 'DXV';
|
||||
const TERMS_DAP = 'DAP';
|
||||
const TERMS_DDX = 'DDX';
|
||||
const TERMS_CPT = 'CPT';
|
||||
|
||||
public ?string $invoiceNumber;
|
||||
public string $exportType;
|
||||
public ?string $exportTypeDescription;
|
||||
public ?string $termsOfTrade;
|
||||
public string $placeOfCommital;
|
||||
public ?float $additionalFee;
|
||||
public ?string $customsCurrency;
|
||||
public ?string $permitNumber;
|
||||
public ?string $attestationNumber;
|
||||
public ?string $addresseesCustomsReference;
|
||||
public ?string $sendersCustomsReference;
|
||||
public ?bool $WithElectronicExportNtfctn;
|
||||
/** @var ExportDocPosition[] $ExportDocPosition */
|
||||
public array $ExportDocPosition;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class LabelData
|
||||
{
|
||||
public Statusinformation $Status;
|
||||
public ?string $shipmentNumber;
|
||||
public ?string $labelUrl;
|
||||
public ?string $labelData;
|
||||
public ?string $returnLabelUrl;
|
||||
public ?string $returnLabelData;
|
||||
public ?string $exportLabelUrl;
|
||||
public ?string $exportLabelData;
|
||||
public ?string $codLabelUrl;
|
||||
public ?string $codLabelData;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Name
|
||||
{
|
||||
public string $name1;
|
||||
public ?string $name2;
|
||||
public ?string $name3;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class NativeAddress
|
||||
{
|
||||
public string $streetName;
|
||||
public ?string $streetNumber;
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
public array $addressAddition;
|
||||
public ?string $dispatchingInformation;
|
||||
public string $zip;
|
||||
public string $city;
|
||||
public ?string $province;
|
||||
public ?Country $Origin;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class NativeAddressNew
|
||||
{
|
||||
public string $streetName;
|
||||
public ?string $streetNumber;
|
||||
public string $zip;
|
||||
public string $city;
|
||||
public ?Country $Origin;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class PackStation
|
||||
{
|
||||
public string $postNumber;
|
||||
public string $packstationNumber;
|
||||
public string $zip;
|
||||
public string $city;
|
||||
public ?string $province;
|
||||
public ?Country $Origin;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Postfiliale
|
||||
{
|
||||
public string $postfilialeNumber;
|
||||
public string $postNumber;
|
||||
public string $zip;
|
||||
public string $city;
|
||||
public ?Country $Origin;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Receiver
|
||||
{
|
||||
public string $name1;
|
||||
public ?ReceiverNativeAddress $Address;
|
||||
public ?PackStation $Packstation;
|
||||
public ?Postfiliale $Postfiliale;
|
||||
public ?Communication $Communication;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ReceiverNativeAddress
|
||||
{
|
||||
public ?string $name2;
|
||||
public ?string $name3;
|
||||
public string $streetName;
|
||||
public ?string $streetNumber;
|
||||
public array|string|null $addressAddition;
|
||||
public ?string $dispatchingInformation;
|
||||
public string $zip;
|
||||
public string $city;
|
||||
public ?string $province;
|
||||
public ?Country $Origin;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Shipment
|
||||
{
|
||||
public ShipmentDetails $ShipmentDetails;
|
||||
public Shipper $Shipper;
|
||||
public string $ShipperReference;
|
||||
public Receiver $Receiver;
|
||||
public ?Shipper $ReturnReceiver;
|
||||
public ?ExportDocument $ExportDocument;
|
||||
public ?string $feederSystem;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->ShipmentDetails = new ShipmentDetails();
|
||||
$this->Shipper = new Shipper();
|
||||
$this->ShipperReference = '';
|
||||
$this->Receiver = new Receiver();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
use DateTimeImmutable;
|
||||
|
||||
class ShipmentDetails
|
||||
{
|
||||
public string $product;
|
||||
public string $accountNumber;
|
||||
public string $customerReference;
|
||||
private string $shipmentDate;
|
||||
public string $costCentre;
|
||||
public string $returnShipmentAccountNumber;
|
||||
public string $returnShipmentReference;
|
||||
public ShipmentItem $ShipmentItem;
|
||||
public ShipmentService $Service;
|
||||
public ShipmentNotification $Notification;
|
||||
public Bank $BankData;
|
||||
|
||||
public function SetShipmentDate(DateTimeImmutable $date): void {
|
||||
$this->shipmentDate = $date->format('Y-m-d');
|
||||
}
|
||||
|
||||
public function GetShipmentDate(): DateTimeImmutable {
|
||||
return DateTimeImmutable::createFromFormat('Y-m-d', $this->shipmentDate);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ShipmentItem
|
||||
{
|
||||
public float $weightInKG;
|
||||
public ?int $lengthInCM;
|
||||
public ?int $widthInCM;
|
||||
public ?int $heightInCM;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ShipmentNotification
|
||||
{
|
||||
public string $recipientEmailAddress;
|
||||
public ?string $templateId;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ShipmentOrder
|
||||
{
|
||||
public string $sequenceNumber;
|
||||
public Shipment $Shipment;
|
||||
public ?Serviceconfiguration $PrintOnlyIfCodeable;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class ShipmentService
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Shipper
|
||||
{
|
||||
public Name $Name;
|
||||
public NativeAddressNew $Address;
|
||||
public ?Communication $Communication;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->Name = new Name();
|
||||
$this->Address = new NativeAddressNew();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Status
|
||||
{
|
||||
public string $statuscode;
|
||||
public string $statusDescription;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class StatusElement
|
||||
{
|
||||
public string $statusElement;
|
||||
public string $statusMessage;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Statusinformation
|
||||
{
|
||||
public int $statusCode;
|
||||
public string $statusText;
|
||||
public array|string $statusMessage;
|
||||
public string $statusType;
|
||||
public StatusElement $errorMessage;
|
||||
public StatusElement $warningMessage;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl\Data;
|
||||
|
||||
class Version
|
||||
{
|
||||
public string $majorRelease;
|
||||
public string $minorRelease;
|
||||
public ?string $build;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\Dhl;
|
||||
|
||||
use SoapClient;
|
||||
use SoapHeader;
|
||||
use Xentral\Carrier\Dhl\Data\CreateShipmentOrderRequest;
|
||||
use Xentral\Carrier\Dhl\Data\CreateShipmentOrderResponse;
|
||||
use Xentral\Carrier\Dhl\Data\CreationState;
|
||||
use Xentral\Carrier\Dhl\Data\LabelData;
|
||||
use Xentral\Carrier\Dhl\Data\Shipment;
|
||||
use Xentral\Carrier\Dhl\Data\ShipmentOrder;
|
||||
use Xentral\Carrier\Dhl\Data\Statusinformation;
|
||||
use Xentral\Carrier\Dhl\Data\Version;
|
||||
|
||||
class DhlApi
|
||||
{
|
||||
private SoapClient $soapClient;
|
||||
|
||||
private const SANDBOX_URL = 'https://cig.dhl.de/services/sandbox/soap';
|
||||
private const PRODUCTION_URL = 'https://cig.dhl.de/services/production/soap';
|
||||
private const NAMESPACE_CIS = 'http://dhl.de/webservice/cisbase';
|
||||
|
||||
public function __construct(string $user, string $signature)
|
||||
{
|
||||
$this->soapClient = new SoapClient(__DIR__ . '/Wsdl/geschaeftskundenversand-api-3.4.0.wsdl', [
|
||||
'login' => 'OpenXE_1',
|
||||
'password' => 'cjzNEpGXxbbnRwcYLISX3ZTTcQrQrz',
|
||||
'location' => self::PRODUCTION_URL,
|
||||
'trace' => 1,
|
||||
'connection_timeout' => 30,
|
||||
'classmap' => [
|
||||
'CreateShipmentOrderResponse' => CreateShipmentOrderResponse::class,
|
||||
'CreationState' => CreationState::class,
|
||||
'LabelData' => LabelData::class,
|
||||
'Statusinformation' => Statusinformation::class,
|
||||
'Version' => Version::class,
|
||||
]
|
||||
]);
|
||||
|
||||
$authHeader = new SoapHeader(self::NAMESPACE_CIS, 'Authentification', [
|
||||
'user' => $user,
|
||||
'signature' => $signature
|
||||
]);
|
||||
$this->soapClient->__setSoapHeaders($authHeader);
|
||||
}
|
||||
|
||||
public function CreateShipment(Shipment $shipment): CreateShipmentOrderResponse|string
|
||||
{
|
||||
$request = new CreateShipmentOrderRequest();
|
||||
$request->Version = $this->getVersion();
|
||||
$request->ShipmentOrder = new ShipmentOrder();
|
||||
$request->ShipmentOrder->Shipment = $shipment;
|
||||
$request->ShipmentOrder->sequenceNumber = '1';
|
||||
$request->labelResponseType = "B64";
|
||||
try {
|
||||
$response = $this->soapClient->createShipmentOrder($request);
|
||||
return $response;
|
||||
} catch (\SoapFault $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private function getVersion() {
|
||||
$version = new Version();
|
||||
$version->majorRelease = '3';
|
||||
$version->minorRelease = '4';
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,340 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Version: 3.4.0
|
||||
Date: 2022-08-01T22:00:51Z
|
||||
--><wsdl:definitions xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
||||
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
|
||||
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
|
||||
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
|
||||
xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||
xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
|
||||
xmlns:cis="http://dhl.de/webservice/cisbase"
|
||||
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
|
||||
xmlns:bcs="http://dhl.de/webservices/businesscustomershipping/3.0"
|
||||
targetNamespace="http://dhl.de/webservices/businesscustomershipping/3.0">
|
||||
<wsdl:types>
|
||||
<xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified">
|
||||
<xs:import namespace="http://dhl.de/webservice/cisbase"
|
||||
schemaLocation="geschaeftskundenversand-api-3.4.0-schema-cis_base.xsd"/>
|
||||
<xs:import namespace="http://dhl.de/webservices/businesscustomershipping/3.0"
|
||||
schemaLocation="geschaeftskundenversand-api-3.4.0-schema-bcs_base.xsd"/>
|
||||
</xs:schema>
|
||||
</wsdl:types>
|
||||
<wsdl:message name="AuthentificationHeaderMessage">
|
||||
<wsdl:documentation>The authentication data.</wsdl:documentation>
|
||||
<wsdl:part name="header" element="cis:Authentification"/>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="createShipmentOrderMessage">
|
||||
<wsdl:documentation>The shipmentdata for creating a shipment.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:CreateShipmentOrderRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="createShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the createShipment operation and the identifier for the
|
||||
shipment.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:CreateShipmentOrderResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="validateShipmentMessage">
|
||||
<wsdl:documentation>The shipmentdata for validating a shipment.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:ValidateShipmentOrderRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="validateShipmentResponseMessage">
|
||||
<wsdl:documentation>The status of the validateShipment operation and the identifier for the
|
||||
shipment.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:ValidateShipmentResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="deleteShipmentOrderMessage">
|
||||
<wsdl:documentation>The identifier for the shipment which should be
|
||||
deleted.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:DeleteShipmentOrderRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="deleteShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the deletion operation.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:DeleteShipmentOrderResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="doManifestMessage">
|
||||
<wsdl:documentation>The identifier for the shipment which should be
|
||||
manifested.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:DoManifestRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="doManifestResponseMessage">
|
||||
<wsdl:documentation>The status of the manifest operation.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:DoManifestResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getLabelMessage">
|
||||
<wsdl:documentation>The identifier for the DD shipment for which the label url is
|
||||
requested.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetLabelRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getLabelResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the label url (if
|
||||
available).</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetLabelResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getVersionRequestMessage">
|
||||
<wsdl:documentation>The version of webservice implementation.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:Version"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getVersionResponseMessage">
|
||||
<wsdl:documentation>The version of webservice implementation.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetVersionResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getExportDocMessage">
|
||||
<wsdl:documentation>The identifier for the DD shipment for which the label url is
|
||||
requested.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetExportDocRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getExportDocResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the label url (if
|
||||
available).</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetExportDocResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getManifestRequestMessage">
|
||||
<wsdl:documentation>Request a manifest of the given date / date range.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetManifestRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="getManifestResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the manifest url (if
|
||||
available).</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:GetManifestResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="updateShipmentOrderRequestMessage">
|
||||
<wsdl:documentation>Request a manifest of the given date / date range.</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:UpdateShipmentOrderRequest"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="updateShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the manifest url (if
|
||||
available).</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:UpdateShipmentOrderResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:message name="readShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the manifest url (if
|
||||
available).</wsdl:documentation>
|
||||
<wsdl:part name="part1" element="bcs:ReadShipmentOrderResponse"> </wsdl:part>
|
||||
</wsdl:message>
|
||||
<wsdl:portType name="GKV3XAPIServicePortType">
|
||||
<wsdl:operation name="createShipmentOrder">
|
||||
<wsdl:documentation>Creates shipments.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:createShipmentOrderMessage">
|
||||
<wsdl:documentation>The shipment data.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:createShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the createShipment operation and the identifier for the
|
||||
shipment.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="validateShipment">
|
||||
<wsdl:documentation>Creates shipments.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:validateShipmentMessage">
|
||||
<wsdl:documentation>The shipment data.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:validateShipmentResponseMessage">
|
||||
<wsdl:documentation>The status of the validateShipment operation and the identifier for the
|
||||
shipment.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="deleteShipmentOrder">
|
||||
<wsdl:documentation>Deletes the requested shipments.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:deleteShipmentOrderMessage">
|
||||
<wsdl:documentation>The identifier for the shipment which should be
|
||||
deleted.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:deleteShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the deletion operation.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="doManifest">
|
||||
<wsdl:documentation>Manifest the requested DD shipments.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:doManifestMessage">
|
||||
<wsdl:documentation>The identifier for the shipment which should be
|
||||
manifested.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:doManifestResponseMessage">
|
||||
<wsdl:documentation>The status of the manifest operation.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getLabel">
|
||||
<wsdl:documentation>Returns the request-url for getting a label.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:getLabelMessage">
|
||||
<wsdl:documentation>The identifier for the shipment for which the label url is
|
||||
requested.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:getLabelResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the label url (if
|
||||
available).</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getVersion">
|
||||
<wsdl:documentation>Returns the actual version of the implementation of the whole ISService
|
||||
webservice.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:getVersionRequestMessage"/>
|
||||
<wsdl:output message="bcs:getVersionResponseMessage">
|
||||
<wsdl:documentation>The version of webservice implementation.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getExportDoc">
|
||||
<wsdl:documentation>Returns the request-url for getting a export
|
||||
document.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:getExportDocMessage">
|
||||
<wsdl:documentation>The identifier for the shipment for which the export document url is
|
||||
requested.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:getExportDocResponseMessage">
|
||||
<wsdl:documentation>The status of the operation and the export document url (if
|
||||
available).</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getManifest">
|
||||
<wsdl:documentation>Request the manifest.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:getManifestRequestMessage">
|
||||
<wsdl:documentation>The request data.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:getManifestResponseMessage">
|
||||
<wsdl:documentation>The status of the getManifest operation and the manifest
|
||||
url.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="updateShipmentOrder">
|
||||
<wsdl:documentation>Updates a shipment order.</wsdl:documentation>
|
||||
<wsdl:input message="bcs:updateShipmentOrderRequestMessage">
|
||||
<wsdl:documentation>The shipment data.</wsdl:documentation>
|
||||
</wsdl:input>
|
||||
<wsdl:output message="bcs:updateShipmentOrderResponseMessage">
|
||||
<wsdl:documentation>The status of the updateShipment operation and the identifier for the
|
||||
shipment.</wsdl:documentation>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
</wsdl:portType>
|
||||
<wsdl:binding name="GKV3XAPISOAP11Binding" type="bcs:GKV3XAPIServicePortType">
|
||||
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
|
||||
<wsdl:operation name="createShipmentOrder">
|
||||
<wsdl:documentation>Creates shipments.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:createShipmentOrder" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment data.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="validateShipment">
|
||||
<wsdl:documentation>Validates shipments.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:validateShipment" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment data.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="deleteShipmentOrder">
|
||||
<wsdl:documentation>Deletes the requested shipments.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:deleteShipmentOrder" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="doManifest">
|
||||
<wsdl:documentation>Manifest the requested shipments.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:doManifest" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getLabel">
|
||||
<wsdl:documentation>Returns the request-url for getting a label.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:getLabel" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation and the url for requesting the
|
||||
label.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getVersion">
|
||||
<wsdl:documentation>Returns the actual version of the implementation of the whole ISService
|
||||
webservice.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:getVersion" style="document"/>
|
||||
<wsdl:input>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The version of the implementation.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getExportDoc">
|
||||
<wsdl:documentation>Returns the request-url for getting a export
|
||||
document.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:getExportDoc" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment
|
||||
identifier.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation and the url for requesting the export
|
||||
document.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="getManifest">
|
||||
<wsdl:documentation>Requests the manifest.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:getManifest" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment data.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation and the manifest url.</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
<wsdl:operation name="updateShipmentOrder">
|
||||
<wsdl:documentation>Updates a shipment order.</wsdl:documentation>
|
||||
<soap:operation soapAction="urn:updateShipmentOrder" style="document"/>
|
||||
<wsdl:input>
|
||||
<wsdl:documentation>The authentication data and the shipment data.</wsdl:documentation>
|
||||
<soap:header message="bcs:AuthentificationHeaderMessage" part="header" use="literal"/>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:input>
|
||||
<wsdl:output>
|
||||
<wsdl:documentation>The status of the operation</wsdl:documentation>
|
||||
<soap:body use="literal"/>
|
||||
</wsdl:output>
|
||||
</wsdl:operation>
|
||||
</wsdl:binding>
|
||||
<wsdl:service name="GVAPI_2_0_de">
|
||||
<wsdl:port name="GKVAPISOAP11port0" binding="bcs:GKV3XAPISOAP11Binding">
|
||||
<soap:address location="https://cig.dhl.de/services/production/soap"/>
|
||||
</wsdl:port>
|
||||
</wsdl:service>
|
||||
</wsdl:definitions>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class Document
|
||||
{
|
||||
public const TYPE_LABEL = 'label';
|
||||
public const TYPE_CP71 = 'cp71';
|
||||
public const TYPE_CN23 = 'cn23';
|
||||
public const TYPE_CN23_DEFAULT = 'cn23-default';
|
||||
public const TYPE_COMMERCIAL_INVOICE = 'commercial-invoice';
|
||||
|
||||
public string $Type;
|
||||
public string $Size;
|
||||
public string $Link;
|
||||
|
||||
public static function fromApiResponse(object $data): Document
|
||||
{
|
||||
$obj = new Document();
|
||||
$obj->Type = $data->type;
|
||||
$obj->Size = $data->size;
|
||||
$obj->Link = $data->link;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
abstract class ParcelBase
|
||||
{
|
||||
public ?string $Name = null;
|
||||
public ?string $CompanyName = null;
|
||||
public ?string $Address = null;
|
||||
public ?string $Address2 = null;
|
||||
public ?string $HouseNumber = null;
|
||||
public ?string $City = null;
|
||||
public ?string $PostalCode = null;
|
||||
public ?string $Telephone = null;
|
||||
public bool $RequestLabel = true;
|
||||
public ?string $EMail = null;
|
||||
public ?string $Country = null;
|
||||
public ?int $ShippingMethodId = null;
|
||||
/**
|
||||
* @var ?int weight in grams
|
||||
*/
|
||||
public ?int $Weight = null;
|
||||
public ?string $OrderNumber = null;
|
||||
public ?string $TotalOrderValueCurrency = null;
|
||||
public ?float $TotalOrderValue = null;
|
||||
public ?string $CountryState = null;
|
||||
public ?string $CustomsInvoiceNr = null;
|
||||
public ?int $CustomsShipmentType = null;
|
||||
public ?string $ExternalReference = null;
|
||||
public ?int $TotalInsuredValue = null;
|
||||
public ?array $ParcelItems = array();
|
||||
public bool $IsReturn = false;
|
||||
public ?string $Length = null;
|
||||
public ?string $Width = null;
|
||||
public ?string $Height = null;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class ParcelCreation extends ParcelBase
|
||||
{
|
||||
public ?int $SenderAddressId = null;
|
||||
|
||||
public function toApiRequest(): array {
|
||||
return [
|
||||
'name' => $this->Name,
|
||||
'company_name' => $this->CompanyName,
|
||||
'address' => $this->Address,
|
||||
'address_2' => $this->Address2,
|
||||
'house_number' => $this->HouseNumber,
|
||||
'city' => $this->City,
|
||||
'postal_code' => $this->PostalCode,
|
||||
'telephone' => $this->Telephone,
|
||||
'request_label' => $this->RequestLabel,
|
||||
'email' => $this->EMail,
|
||||
'country' => $this->Country,
|
||||
'shipment' => ['id' => $this->ShippingMethodId],
|
||||
'weight' => number_format($this->Weight / 1000, 3, '.', null),
|
||||
'order_number' => $this->OrderNumber,
|
||||
'total_order_value_currency' => $this->TotalOrderValueCurrency,
|
||||
'total_order_value' => number_format($this->TotalOrderValue, 2, '.', null),
|
||||
'country_state' => $this->CountryState,
|
||||
'sender_address' => $this->SenderAddressId,
|
||||
'customs_invoice_nr' => $this->CustomsInvoiceNr,
|
||||
'customs_shipment_type' => $this->CustomsShipmentType,
|
||||
'external_reference' => $this->ExternalReference,
|
||||
'total_insured_value' => $this->TotalInsuredValue ?? 0,
|
||||
'parcel_items' => array_map(fn(ParcelItem $item)=>$item->toApiRequest(), $this->ParcelItems),
|
||||
'is_return' => $this->IsReturn,
|
||||
'length' => $this->Length,
|
||||
'width' => $this->Width,
|
||||
'height' => $this->Height,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class ParcelCreationError
|
||||
{
|
||||
public int $Code;
|
||||
public string $Message;
|
||||
public string $Request;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class ParcelItem
|
||||
{
|
||||
public string $HsCode;
|
||||
|
||||
/**
|
||||
* @var int weight in grams
|
||||
*/
|
||||
public int $Weight;
|
||||
public int $Quantity;
|
||||
public string $Description;
|
||||
public string $OriginCountry;
|
||||
public float $Price;
|
||||
public ?string $Sku = null;
|
||||
public ?string $ProductId = null;
|
||||
|
||||
public function toApiRequest(): array {
|
||||
return [
|
||||
'hs_code' => $this->HsCode,
|
||||
'weight' => number_format($this->Weight / 1000, 3, '.', null),
|
||||
'quantity' => $this->Quantity,
|
||||
'description' => $this->Description,
|
||||
'value' => $this->Price,
|
||||
'origin_country' => $this->OriginCountry,
|
||||
'sku' => $this->Sku ?? '',
|
||||
'product_id' => $this->ProductId ?? '',
|
||||
];
|
||||
}
|
||||
|
||||
public static function fromApiResponse(object $data): ParcelItem
|
||||
{
|
||||
$obj = new ParcelItem();
|
||||
$obj->HsCode = $data->hs_code;
|
||||
$obj->Weight = intval(floatval($data->weight)*1000);
|
||||
$obj->Quantity = $data->quantity;
|
||||
$obj->Description = $data->description;
|
||||
$obj->Price = $data->value;
|
||||
$obj->OriginCountry = $data->origin_country;
|
||||
$obj->Sku = $data->sku;
|
||||
$obj->ProductId = $data->product_id;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Exception;
|
||||
|
||||
class ParcelResponse extends ParcelBase
|
||||
{
|
||||
public int $Id;
|
||||
public string $CarrierCode;
|
||||
public DateTimeImmutable $DateCreated;
|
||||
public DateTimeImmutable $DateUpdated;
|
||||
public DateTimeImmutable $DateAnnounced;
|
||||
public string $ShipmentMethodName;
|
||||
public int $StatusId;
|
||||
public string $StatusMessage;
|
||||
public array $Documents;
|
||||
public ?string $TrackingNumber = null;
|
||||
public ?string $TrackingUrl = null;
|
||||
public ?array $Errors;
|
||||
|
||||
public function GetDocumentByType(string $type): ?Document
|
||||
{
|
||||
/** @var Document $item */
|
||||
foreach ($this->Documents as $item)
|
||||
if ($item->Type == $type)
|
||||
return $item;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function fromApiResponse(object $data): ParcelResponse
|
||||
{
|
||||
$obj = new ParcelResponse();
|
||||
$obj->Address = $data->address_divided->street;
|
||||
$obj->Address2 = $data->address_2;
|
||||
$obj->HouseNumber = $data->address_divided->house_number;
|
||||
$obj->CarrierCode = $data->carrier->code;
|
||||
$obj->City = $data->city;
|
||||
$obj->CompanyName = $data->company_name;
|
||||
$obj->Country = $data->country->iso_2;
|
||||
$obj->CustomsInvoiceNr = $data->customs_invoice_nr;
|
||||
$obj->CustomsShipmentType = $data->customs_shipment_type;
|
||||
$obj->DateCreated = new DateTimeImmutable($data->date_created);
|
||||
$obj->DateUpdated = new DateTimeImmutable($data->date_updated);
|
||||
$obj->DateAnnounced = new DateTimeImmutable($data->date_announced);
|
||||
$obj->EMail = $data->email;
|
||||
$obj->Id = $data->id;
|
||||
$obj->Name = $data->name;
|
||||
$obj->OrderNumber = $data->order_number;
|
||||
$obj->ParcelItems = array_map(fn($item)=>ParcelItem::fromApiResponse($item), $data->parcel_items);
|
||||
$obj->PostalCode = $data->postal_code;
|
||||
$obj->ExternalReference = $data->external_reference;
|
||||
$obj->ShippingMethodId = $data->shipment->id;
|
||||
$obj->ShipmentMethodName = $data->shipment->name;
|
||||
$obj->StatusId = $data->status->id;
|
||||
$obj->StatusMessage = $data->status->message;
|
||||
$obj->Documents = array_map(fn($item)=>Document::fromApiResponse($item), $data->documents);
|
||||
$obj->Telephone = $data->telephone;
|
||||
$obj->TotalInsuredValue = $data->total_insured_value;
|
||||
$obj->TotalOrderValue = $data->total_order_value;
|
||||
$obj->TotalOrderValueCurrency = $data->total_order_value_currency;
|
||||
$obj->TrackingNumber = $data->tracking_number;
|
||||
$obj->TrackingUrl = $data->tracking_url;
|
||||
$obj->Weight = $data->weight;
|
||||
$obj->Length = $data->length;
|
||||
$obj->Height = $data->height;
|
||||
$obj->Width = $data->width;
|
||||
$obj->IsReturn = $data->is_return;
|
||||
$obj->Errors = $data->errors->non_field_errors;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class SenderAddress {
|
||||
public ?string $City;
|
||||
public ?string $CompanyName;
|
||||
public ?string $ContactName;
|
||||
public string $Country;
|
||||
public ?string $CountryState;
|
||||
public ?string $Email;
|
||||
public ?string $HouseNumber;
|
||||
public int $Id;
|
||||
public ?string $PostalBox;
|
||||
public ?string $PostalCode;
|
||||
public ?string $Street;
|
||||
public ?string $Telephone;
|
||||
public ?string $VatNumber;
|
||||
public ?string $EoriNumber;
|
||||
public int $BrandId;
|
||||
public ?string $Label;
|
||||
public ?string $SignatureFullName;
|
||||
public ?string $SignatureInitials;
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return "$this->CompanyName; $this->ContactName; $this->Street $this->HouseNumber; $this->PostalCode; $this->City";
|
||||
}
|
||||
|
||||
|
||||
public static function fromApiResponse(object $data): SenderAddress {
|
||||
$obj = new SenderAddress();
|
||||
$obj->City = $data->city;
|
||||
$obj->CompanyName = $data->company_name;
|
||||
$obj->ContactName = $data->contact_name;
|
||||
$obj->Country = $data->country;
|
||||
$obj->CountryState = $data->country_state;
|
||||
$obj->Email = $data->email;
|
||||
$obj->HouseNumber = $data->house_number;
|
||||
$obj->Id = $data->id;
|
||||
$obj->PostalBox = $data->postal_box;
|
||||
$obj->PostalCode = $data->postal_code;
|
||||
$obj->Street = $data->street;
|
||||
$obj->Telephone = $data->telephone;
|
||||
$obj->VatNumber = $data->vat_number;
|
||||
$obj->EoriNumber = $data->eori_number;
|
||||
$obj->BrandId = $data->brand_id;
|
||||
$obj->Label = $data->label;
|
||||
$obj->SignatureFullName = $data->signature_full_name;
|
||||
$obj->SignatureInitials = $data->signature_initials;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class ShippingMethod {
|
||||
public int $Id;
|
||||
public string $Name;
|
||||
public ?string $Carrier;
|
||||
public int $MinWeight;
|
||||
public int $MaxWeight;
|
||||
public int $MaxLength;
|
||||
public int $MaxWidth;
|
||||
public int $MaxHeight;
|
||||
public string $Unit;
|
||||
|
||||
public static function fromApiResponse(object $data):ShippingMethod {
|
||||
$obj = new ShippingMethod();
|
||||
$obj->Id = $data->id;
|
||||
$obj->Name = $data->name;
|
||||
$obj->Carrier = $data->carrier ?? null;
|
||||
$obj->MinWeight = $data->properties->min_weight;
|
||||
$obj->MaxWeight = $data->properties->max_weight;
|
||||
$obj->MaxLength = $data->properties->max_dimensions->length;
|
||||
$obj->MaxWidth = $data->properties->max_dimensions->width;
|
||||
$obj->MaxHeight = $data->properties->max_dimensions->height;
|
||||
$obj->Unit = $data->properties->max_dimensions->unit;
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud\Data;
|
||||
|
||||
class ShippingProduct {
|
||||
public string $Name;
|
||||
public string $Carrier;
|
||||
public string $ServicePointsCarrier;
|
||||
public string $Code;
|
||||
public int $MinWeight;
|
||||
public int $MaxWeight;
|
||||
public array $ShippingMethods;
|
||||
|
||||
public static function fromApiResponse(object $data): ShippingProduct {
|
||||
$obj = new ShippingProduct();
|
||||
$obj->Name = $data->name;
|
||||
$obj->Carrier = $data->carrier;
|
||||
$obj->ServicePointsCarrier = $data->service_points_carrier;
|
||||
$obj->Code = $data->code;
|
||||
$obj->MinWeight = $data->weight_range->min_weight;
|
||||
$obj->MaxWeight = $data->weight_range->max_weight;
|
||||
foreach ($data->methods as $method) {
|
||||
$child = ShippingMethod::fromApiResponse($method);
|
||||
$child->Carrier = $obj->Carrier;
|
||||
$obj->ShippingMethods[] = $child;
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud;
|
||||
|
||||
use Exception;
|
||||
use Xentral\Carrier\SendCloud\Data\Document;
|
||||
use Xentral\Carrier\SendCloud\Data\ParcelCreation;
|
||||
use Xentral\Carrier\SendCloud\Data\ParcelResponse;
|
||||
use Xentral\Carrier\SendCloud\Data\SenderAddress;
|
||||
use Xentral\Carrier\SendCloud\Data\ShippingProduct;
|
||||
|
||||
class SendCloudApi
|
||||
{
|
||||
/**
|
||||
* @var ?string $public_key
|
||||
*/
|
||||
protected ?string $public_key;
|
||||
/**
|
||||
* @var ?string $private_key
|
||||
*/
|
||||
protected ?string $private_key;
|
||||
|
||||
const PROD_BASE_URI = 'https://panel.sendcloud.sc/api/v2';
|
||||
|
||||
public function __construct($public_key, $private_key)
|
||||
{
|
||||
$this->public_key = $public_key;
|
||||
$this->private_key = $private_key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SendcloudApiException
|
||||
*/
|
||||
public function GetSenderAddresses(): array
|
||||
{
|
||||
$uri = self::PROD_BASE_URI . '/user/addresses/sender';
|
||||
$response = $this->sendRequest($uri);
|
||||
foreach ($response['body']->sender_addresses as $item)
|
||||
$res[] = SenderAddress::fromApiResponse($item);
|
||||
return $res ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SendcloudApiException
|
||||
*/
|
||||
public function GetShippingProducts(string $sourceCountry, ?string $targetCountry = null, ?int $weight = null,
|
||||
?int $height = null, ?int $length = null, ?int $width = null): array
|
||||
{
|
||||
$uri = self::PROD_BASE_URI . '/shipping-products';
|
||||
$params = ['from_country' => $sourceCountry];
|
||||
if ($targetCountry !== null)
|
||||
$params['to_country'] = $targetCountry;
|
||||
if ($weight !== null && $weight > 0)
|
||||
$params['weight'] = $weight;
|
||||
if ($height !== null && $height > 0) {
|
||||
$params['height'] = $height;
|
||||
$params['height_unit'] = 'centimeter';
|
||||
}
|
||||
if ($length !== null && $length > 0) {
|
||||
$params['length'] = $length;
|
||||
$params['length_unit'] = 'centimeter';
|
||||
}
|
||||
if ($width !== null && $width > 0) {
|
||||
$params['width'] = $width;
|
||||
$params['width_unit'] = 'centimeter';
|
||||
}
|
||||
$response = $this->sendRequest($uri, $params);
|
||||
return array_map(fn($x) => ShippingProduct::fromApiResponse($x), $response['body'] ?? []);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SendcloudApiException
|
||||
*/
|
||||
public function CreateParcel(ParcelCreation $parcel): ParcelResponse|string|null
|
||||
{
|
||||
$uri = self::PROD_BASE_URI . '/parcels';
|
||||
$response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]);
|
||||
switch ($response['code']) {
|
||||
case 200:
|
||||
if (isset($response['body']->parcel))
|
||||
try {
|
||||
return ParcelResponse::fromApiResponse($response['body']->parcel);
|
||||
} catch (Exception $e) {
|
||||
throw new SendcloudApiException(previous: $e);
|
||||
}
|
||||
break;
|
||||
case 400:
|
||||
if (isset($response->error))
|
||||
return $response->error->message;
|
||||
break;
|
||||
}
|
||||
throw SendcloudApiException::fromResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SendcloudApiException
|
||||
*/
|
||||
public function DownloadDocument(Document $document): string
|
||||
{
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $document->Link,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Basic " . base64_encode($this->public_key . ':' . $this->private_key)
|
||||
],
|
||||
]);
|
||||
$output = curl_exec($curl);
|
||||
$code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
|
||||
if ($code != 200)
|
||||
throw SendcloudApiException::fromResponse(['code' => $code, 'body' => $output]);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws SendcloudApiException
|
||||
*/
|
||||
function sendRequest(string $uri, array $query_params = null, bool $post = false, array $postFields = null,
|
||||
array $allowedResponseCodes = [200]): ?array
|
||||
{
|
||||
if (empty($this->public_key) || empty($this->private_key))
|
||||
return null;
|
||||
|
||||
$curl = curl_init();
|
||||
if (is_array($query_params)) {
|
||||
$uri .= '?' . http_build_query($query_params);
|
||||
}
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_RETURNTRANSFER => 1,
|
||||
CURLOPT_URL => $uri,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
"Authorization: Basic " . base64_encode($this->public_key . ':' . $this->private_key),
|
||||
'Content-Type: application/json'
|
||||
],
|
||||
]);
|
||||
if ($post === true) {
|
||||
curl_setopt_array($curl, [
|
||||
CURLOPT_POST => true,
|
||||
CURLOPT_POSTFIELDS => json_encode($postFields)
|
||||
]);
|
||||
}
|
||||
|
||||
$output = json_decode(curl_exec($curl));
|
||||
$code = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
|
||||
curl_close($curl);
|
||||
|
||||
$ret = [
|
||||
'code' => $code,
|
||||
'body' => $output,
|
||||
];
|
||||
|
||||
if (!in_array($code, $allowedResponseCodes))
|
||||
throw SendcloudApiException::fromResponse($ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
namespace Xentral\Carrier\SendCloud;
|
||||
|
||||
use Exception;
|
||||
|
||||
class SendcloudApiException extends Exception
|
||||
{
|
||||
public static function fromResponse(array $response) : SendcloudApiException {
|
||||
if (!isset($response['body']) || !is_object($response['body']))
|
||||
return new SendcloudApiException(print_r($response,true));
|
||||
|
||||
return new SendcloudApiException(
|
||||
print_r($response['body'],true),
|
||||
$response['code']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
*/
|
||||
|
||||
namespace Xentral\Modules\ShippingMethod\Model;
|
||||
|
||||
class CreateShipmentResult
|
||||
{
|
||||
public bool $Success = false;
|
||||
public array $Errors = [];
|
||||
public ?string $Label;
|
||||
public ?string $ExportDocuments;
|
||||
public ?string $TrackingNumber;
|
||||
public ?string $TrackingUrl;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
*/
|
||||
|
||||
namespace Xentral\Modules\ShippingMethod\Model;
|
||||
|
||||
class CustomsInfo
|
||||
{
|
||||
const CUSTOMS_TYPE_GIFT = 0;
|
||||
const CUSTOMS_TYPE_DOCUMENTS = 1;
|
||||
const CUSTOMS_TYPE_GOODS = 2;
|
||||
const CUSTOMS_TYPE_SAMPLE = 3;
|
||||
const CUSTOMS_TYPE_RETURN = 4;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
*/
|
||||
|
||||
namespace Xentral\Modules\ShippingMethod\Model;
|
||||
|
||||
class Product
|
||||
{
|
||||
const SERVICE_COD = 'cod';
|
||||
const SERVICE_PREMIUM = 'premium';
|
||||
|
||||
public string $Id;
|
||||
public string $Name;
|
||||
public float $LengthMin = 0;
|
||||
public float $LengthMax = 500;
|
||||
public float $WidthMin = 0;
|
||||
public float $WidthMax = 500;
|
||||
public float $HeightMin = 0;
|
||||
public float $HeightMax = 500;
|
||||
public float $WeightMin = 0;
|
||||
public float $WeightMax = 100;
|
||||
public array $AvailableServices = [];
|
||||
|
||||
public static function Create(string $id, string $name):Product {
|
||||
$obj = new Product();
|
||||
$obj->Id = $id;
|
||||
$obj->Name = $name;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
public function WithLength(float $min, float $max): Product {
|
||||
$this->LengthMin = $min;
|
||||
$this->LengthMax = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function WithWidth(float $min, float $max): Product {
|
||||
$this->WidthMin = $min;
|
||||
$this->WidthMax = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function WithHeight(float $min, float $max): Product {
|
||||
$this->HeightMin = $min;
|
||||
$this->HeightMax = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function WithWeight(float $min, float $max): Product {
|
||||
$this->WeightMin = $min;
|
||||
$this->WeightMax = $max;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function WithServices(array $services): Product {
|
||||
$this->AvailableServices = $services;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Andreas Palm
|
||||
* SPDX-FileCopyrightText: 2019 Xentral (c) Xentral ERP Software GmbH, Fuggerstrasse 11, D-86150 Augsburg, Germany
|
||||
*
|
||||
* SPDX-License-Identifier: LicenseRef-EGPL-3.1
|
||||
*/
|
||||
|
||||
var ShippingMethodCreate = function ($) {
|
||||
'use strict';
|
||||
|
||||
@@ -11,35 +18,14 @@ var ShippingMethodCreate = function ($) {
|
||||
vueElementId: '#shipment-create',
|
||||
},
|
||||
search: function (el) {
|
||||
$.ajax({
|
||||
url: 'index.php?module=versandarten&action=create&cmd=suche',
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
val: $(el).val()
|
||||
}
|
||||
let val = $(el).val().toLowerCase();
|
||||
$('.createbutton').each(function() {
|
||||
let desc = $(this).find('.tilegrid-tile-title').text();
|
||||
if (desc.toLowerCase().indexOf(val)>=0)
|
||||
$(this).show();
|
||||
else
|
||||
$(this).hide();
|
||||
})
|
||||
.done(function (data) {
|
||||
if (typeof data != 'undefined' && data != null) {
|
||||
if (typeof data.ausblenden != 'undefined' && data.ausblenden != null) {
|
||||
me.storage.hideElements = data.ausblenden.split(';');
|
||||
$.each(me.storage.hideElements, function (k, v) {
|
||||
if (v != '') {
|
||||
$('#' + v).hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
if (typeof data.anzeigen != 'undefined' && data.anzeigen != null) {
|
||||
me.storage.showElements = data.anzeigen.split(';');
|
||||
$.each(me.storage.showElements, function (k, v) {
|
||||
if (v != '') {
|
||||
$('#' + v).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
init: function () {
|
||||
if ($(me.selector.vueElementId).length === 0) {
|
||||
|
||||
Reference in New Issue
Block a user