[11/05/2025] On remplace les modules Colissimo par le combo ColissimoHomeDelivery + ColissimoPickupPoint + ColissimoLabel

This commit is contained in:
2025-05-11 23:38:10 +02:00
parent a09aa11f16
commit 49b1a63ecc
1528 changed files with 18449 additions and 62 deletions

View File

@@ -0,0 +1,119 @@
<?php
namespace ColissimoLabel\Request\Helper;
use ColissimoLabel\ColissimoLabel;
use Thelia\Model\ConfigQuery;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
abstract class APIConfiguration
{
protected $contractNumber = '';
protected $password = '';
protected $version = '2.0';
protected $wsdl = '';
protected $method = '';
public function __construct()
{
$this->setContractNumber(ColissimoLabel::getConfigValue(ColissimoLabel::CONFIG_KEY_CONTRACT_NUMBER));
$this->setPassword(ColissimoLabel::getConfigValue(ColissimoLabel::CONFIG_KEY_PASSWORD));
$this->setWsdl(ColissimoLabel::getConfigValue(ColissimoLabel::CONFIG_KEY_ENDPOINT));
}
/**
* @return string
*/
public function getContractNumber()
{
return $this->contractNumber;
}
/**
* @param string $contractNumber
* @return self
*/
public function setContractNumber($contractNumber)
{
$this->contractNumber = $contractNumber;
return $this;
}
/**
* @return string
*/
public function getPassword()
{
return $this->password;
}
/**
* @param string $password
* @return self
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* @return string
*/
public function getVersion()
{
return $this->version;
}
/**
* @param string $version
* @return self
*/
public function setVersion($version)
{
$this->version = $version;
return $this;
}
/**
* @return string
*/
public function getWsdl()
{
return $this->wsdl;
}
/**
* @param string $wsdl
* @return self
*/
public function setWsdl($wsdl)
{
$this->wsdl = $wsdl;
return $this;
}
/**
* @return string
*/
public function getMethod()
{
return $this->method;
}
/**
* @param string $method
* @return self
*/
public function setMethod($method)
{
$this->method = $method;
return $this;
}
}

View File

@@ -0,0 +1,289 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Address
{
protected $companyName ='';
protected $lastName = '';
protected $firstName = '';
protected $line0 = '';
protected $line1 = '';
protected $line2 = '';
protected $line3 = '';
protected $countryCode = '';
protected $city = '';
protected $zipCode = '';
protected $phoneNumber = '';
protected $mobileNumber = '';
protected $email = '';
protected $language = '';
/**
* @return string
*/
public function getLanguage()
{
return $this->language;
}
/**
* @param string $language
* @return Address
*/
public function setLanguage($language)
{
$this->language = $language;
return $this;
}
/**
* @return string
*/
public function getPhoneNumber()
{
return $this->phoneNumber;
}
/**
* @param string $phoneNumber
* @return Address
*/
public function setPhoneNumber($phoneNumber)
{
$this->phoneNumber = $phoneNumber;
return $this;
}
/**
* @return string
*/
public function getMobileNumber()
{
return $this->mobileNumber;
}
/**
* @param string $mobileNumber
* @return Address
*/
public function setMobileNumber($mobileNumber)
{
$this->mobileNumber = $mobileNumber;
return $this;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
* @return Address
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* @return string
*/
public function getCompanyName()
{
return $this->companyName;
}
/**
* @param string $companyName
* @return self
*/
public function setCompanyName($companyName)
{
$this->companyName = $companyName;
return $this;
}
/**
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* @param string $lastName
* @return self
*/
public function setLastName($lastName)
{
$this->lastName = $lastName;
return $this;
}
/**
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* @param string $firstName
* @return self
*/
public function setFirstName($firstName)
{
$this->firstName = $firstName;
return $this;
}
/**
* @return string
*/
public function getLine0()
{
return $this->line0;
}
/**
* @param string $line0
* @return self
*/
public function setLine0($line0)
{
$this->line0 = $line0;
return $this;
}
/**
* @return string
*/
public function getLine1()
{
return $this->line1;
}
/**
* @param string $line1
* @return self
*/
public function setLine1($line1)
{
$this->line1 = $line1;
return $this;
}
/**
* @return string
*/
public function getLine2()
{
return $this->line2;
}
/**
* @param string $line2
* @return self
*/
public function setLine2($line2)
{
$this->line2 = $line2;
return $this;
}
/**
* @return string
*/
public function getLine3()
{
return $this->line3;
}
/**
* @param string $line3
* @return self
*/
public function setLine3($line3)
{
$this->line3 = $line3;
return $this;
}
/**
* @return string
*/
public function getCountryCode()
{
return $this->countryCode;
}
/**
* @param string $countryCode
* @return self
*/
public function setCountryCode($countryCode)
{
$this->countryCode = $countryCode;
return $this;
}
/**
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* @param string $city
* @return self
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* @return string
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param string $zipCode
* @return self
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
return $this;
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Addressee
{
/** @var string */
protected $addresseeParcelRef;
/** @var Address */
protected $address;
public function __construct(Address $address)
{
$this->address = $address;
}
/**
* @return string
*/
public function getAddresseeParcelRef()
{
return $this->addresseeParcelRef;
}
/**
* @param string $addresseeParcelRef
*/
public function setAddresseeParcelRef($addresseeParcelRef)
{
$this->addresseeParcelRef = $addresseeParcelRef;
}
/**
* @return Address
*/
public function getAddress()
{
return $this->address;
}
}

View File

@@ -0,0 +1,161 @@
<?php
namespace ColissimoLabel\Request\Helper;
use ColissimoLabel\ColissimoLabel;
use Thelia\Model\CountryQuery;
use Thelia\Model\Order;
class Article
{
protected $description = '';
protected $quantity = 0;
protected $weight = 0;
protected $value = 0;
protected $hsCode = '';
protected $currency = 'EUR';
protected $authorizedCurrencies = [
'USD',
'EUR',
'CHF',
'GBP',
'CNY',
'JPY',
'CAD',
'AUD',
'HKD',
];
public function __construct($description, $quantity, $weight, $value, $hsCode, $currency)
{
$this->description = $description;
$this->quantity = $quantity;
$this->weight = (float) $weight;
$this->value = (float) $value;
$this->hsCode = $hsCode;
$this->currency = $currency;
}
/**
* @return string
*/
public function getDescription()
{
return \Transliterator::create('NFD; [:Nonspacing Mark:] Remove; NFC')->transliterate($this->description);
}
/**
* @param $description
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return int
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param $quantity
* @return $this
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* @return float|int
*/
public function getWeight()
{
return $this->weight;
}
/**
* @param float|int $weight
* @return self
*/
public function setWeight($weight)
{
$this->weight = $weight;
return $this;
}
/**
* @return float|int
*/
public function getValue()
{
return $this->value;
}
/**
* @param float|int $value
* @return $this
*/
public function setValue($value)
{
$this->value = $value;
return $this;
}
/**
* @return string
*/
public function getHsCode()
{
return $this->hsCode;
}
/**
* @param $hsCode
* @return $this
*/
public function setHsCode($hsCode)
{
$this->hsCode = $hsCode;
return $this;
}
/**
* @return string
*/
public function getOriginCountry() {
return CountryQuery::create()->findOneById(ColissimoLabel::getConfigValue(ColissimoLabel::CONFIG_KEY_FROM_COUNTRY))->getIsoalpha2();
}
/**
* @param $currency
* @return $this
*/
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
/**
* @return string
*/
public function getCurrency() {
return $this->currency;
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class BordereauRequestAPIConfiguration extends APIConfiguration
{
public function __construct()
{
parent::__construct();
$this->setMethod('generateBordereauByParcelsNumbers');
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace ColissimoLabel\Request\Helper;
class CustomsDeclarations
{
protected $includeCustomsDeclarations = false;
protected $articles = [];
protected $category = 3;
public function __construct($includeCustomsDeclarations, $category, $articles)
{
$this->includeCustomsDeclarations = $includeCustomsDeclarations;
$this->category = $category;
$this->articles = $articles;
}
/**
* @return bool|string
*/
public function getIncludeCustomsDeclarations()
{
if (!$this->includeCustomsDeclarations) {
return 'false';
}
return $this->includeCustomsDeclarations;
}
/**
* @param $includeCustomsDeclarations
* @return $this
*/
public function setIncludeCustomsDeclarations($includeCustomsDeclarations)
{
$this->includeCustomsDeclarations = $includeCustomsDeclarations;
return $this;
}
/**
* @return int
*/
public function getCategory()
{
return $this->category;
}
/**
* @param $category
* @return $this
*/
public function setCategory($category)
{
$this->category = $category;
return $this;
}
/**
* @return array
*/
public function getArticles()
{
return $this->articles;
}
/**
* @param $articles
* @return $this
*/
public function setArticles($articles)
{
$this->articles[] = $articles;
return $this;
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class LabelRequestAPIConfiguration extends APIConfiguration
{
public function __construct()
{
parent::__construct();
$this->setMethod('generateLabel');
}
}

View File

@@ -0,0 +1,78 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Letter
{
/** @var Sender */
protected $sender;
/** @var Addressee */
protected $addressee;
/** @var Parcel */
protected $parcel;
/** @var Service */
protected $service;
/** @var CustomsDeclarations */
protected $customsDeclarations;
public function __construct(
Service $service,
Sender $sender,
Addressee $addressee,
Parcel $parcel,
CustomsDeclarations $customsDeclarations
) {
$this->sender = $sender;
$this->addressee = $addressee;
$this->parcel = $parcel;
$this->service = $service;
$this->customsDeclarations = $customsDeclarations;
}
/**
* @return Service
*/
public function getService()
{
return $this->service;
}
/**
* @return Sender
*/
public function getSender()
{
return $this->sender;
}
/**
* @return Addressee
*/
public function getAddressee()
{
return $this->addressee;
}
/**
* @return Parcel
*/
public function getParcel()
{
return $this->parcel;
}
/**
* @return CustomsDeclarations
*/
public function getCustomsDeclarations()
{
return $this->customsDeclarations;
}
}

View File

@@ -0,0 +1,87 @@
<?php
namespace ColissimoLabel\Request\Helper;
use ColissimoLabel\Exception\InvalidArgumentException;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class OutputFormat
{
const OUTPUT_PRINTING_TYPE = [
0 => 'ZPL_10x15_203dpi',
1 => 'ZPL_10x15_300dpi',
2 => 'DPL_10x15_203dpi',
3 => 'DPL_10x15_300dpi',
4 => 'PDF_10x15_300dpi',
5 => 'PDF_A4_300dpi'
];
/** Default label format is : PDF_10x15_300dpi */
const OUTPUT_PRINTING_TYPE_DEFAULT = 4;
protected $x = 0;
protected $y = 0;
protected $outputPrintingType = self::OUTPUT_PRINTING_TYPE_DEFAULT;
/**
* @return int
*/
public function getX()
{
return $this->x;
}
/**
* @param int $x
* @return self
*/
public function setX($x)
{
$this->x = (int) $x;
return $this;
}
/**
* @return int
*/
public function getY()
{
return $this->y;
}
/**
* @param int $y
* @return self
*/
public function setY($y)
{
$this->y = (int) $y;
return $this;
}
/**
* @return string value of the list ColissimoAPI\Request\Helper\LabelOutputFormat::OUTPUT_PRINTING_TYPE
*/
public function getOutputPrintingType()
{
return $this->outputPrintingType;
}
/**
* @param string $outputPrintingType value of the list ColissimoAPI\Request\Helper\LabelOutputFormat::OUTPUT_PRINTING_TYPE
* @return self
*/
public function setOutputPrintingType($outputPrintingType)
{
if (\in_array($outputPrintingType, self::OUTPUT_PRINTING_TYPE)) {
new InvalidArgumentException('Invalid value "' . $outputPrintingType . '" for argument $outputPrintingType');
}
$this->outputPrintingType = $outputPrintingType;
return $this;
}
}

View File

@@ -0,0 +1,94 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Parcel
{
protected $weight = 0;
protected $signedDelivery = false;
protected $instructions = '';
protected $pickupLocationId;
public function __construct($weight)
{
$this->weight = (float) $weight;
}
/**
* @return int
*/
public function getWeight()
{
return $this->weight;
}
/**
* @param int $weight
* @return self
*/
public function setWeight($weight)
{
$this->weight = $weight;
return $this;
}
/**
* @return bool
*/
public function getSignedDelivery()
{
return $this->signedDelivery;
}
/**
* @param bool $signedDelivery
* @return self
*/
public function setSignedDelivery($signedDelivery)
{
$this->signedDelivery = $signedDelivery;
return $this;
}
/**
* @return string
*/
public function getInstructions()
{
return $this->instructions;
}
/**
* @param string $instructions
* @return self
*/
public function setInstructions($instructions)
{
$this->instructions = $instructions;
return $this;
}
/**
* @return string
*/
public function getPickupLocationId()
{
return $this->pickupLocationId;
}
/**
* @param string $pickupLocationId
* @return self
*/
public function setPickupLocationId($pickupLocationId)
{
$this->pickupLocationId = $pickupLocationId;
return $this;
}
}

View File

@@ -0,0 +1,46 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Sender
{
/** @var string */
protected $senderParcelRef;
/** @var Address */
protected $address;
public function __construct(Address $address)
{
$this->address = $address;
}
/**
* @return string
*/
public function getSenderParcelRef()
{
return $this->senderParcelRef;
}
/**
* @param string $senderParcelRef
* @return self
*/
public function setSenderParcelRef($senderParcelRef)
{
$this->senderParcelRef = $senderParcelRef;
return $this;
}
/**
* @return Address
*/
public function getAddress()
{
return $this->address;
}
}

View File

@@ -0,0 +1,234 @@
<?php
namespace ColissimoLabel\Request\Helper;
use ColissimoLabel\Exception\InvalidArgumentException;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Service
{
const PRODUCT_CODE_LIST = [
0 => 'DOM',
1 => 'COLD',
2 => 'DOS',
3 => 'COL',
4 => 'BPR',
5 => 'A2P',
6 => 'CORE',
7 => 'COLR',
8 => 'J+1 ',
9 => 'CORI',
10 => 'COM',
11 => 'CDS',
12 => 'ECO',
13 => 'CORI',
14 => 'COLI',
15 => 'ACCI',
16 => 'CMT',
17 => 'PCS',
18 => 'DOM',
19 => 'DOS',
20 => 'BDP'
];
const PRODUCT_CODE_LIST_COMMERCIAL_NAME = [
0 => 'France Colissimo Domicile - sans signature',
1 => 'France Colissimo Domicile - sans signature',
2 => 'France Colissimo Domicile - avec signature',
3 => 'France Colissimo Domicile - avec signature',
4 => 'France Colissimo - Point Retrait en Bureau de Poste ** ',
5 => 'France Colissimo - Point Retrait en relais Pickup ou en consigne Pickup Station',
6 => 'France Colissimo Retour France',
7 => 'France Colissimo Flash - sans signature',
8 => 'Colissimo Flash avec signature',
9 => 'Colissimo Retour International ',
10 => 'Outre-Mer Colissimo Domicile - sans signature ',
11 => 'Outre-Mer Colissimo Domicile - avec signature',
12 => 'Outre-Mer Colissimo Eco OM',
13 => 'Outre-Mer Colissimo Retour OM',
14 => 'International Colissimo Expert International',
15 => 'International Offre Economique Grand Export (offre en test pour la Chine pour un client Pilote)',
16 => 'International (Europe) Colissimo - Point Retrait en relais ****',
17 => 'International (Europe) Colissimo - Point Retrait Consigne Pickup Station Sauf France et Belgique',
18 => 'International (Europe) Colissimo Domicile - sans signature ****',
19 => 'International (Europe) Colissimo Domicile - avec signature ****',
20 => 'International (Europe) Colissimo Point Retrait en bureau de poste ****'
];
const EUROPE_ISOCODES = [
'040', /** Austria */
'056', /** Belgium */
'100', /** Bulgaria */
'191', /** Croatia */
'196', /** Cyprus */
'203', /** Czech Republic */
'208', /** Denmark */
'233', /** Estonia */
'246', /** Finland */
'250', /** France */
'276', /** Germany */
'300', /** Greece */
'348', /** Hungary */
'352', /** Iceland */
'372', /** Ireland */
'380', /** Italy */
'428', /** Latvia */
'440', /** Lithuania */
'442', /** Luxembourg */
'470', /** Malta */
'528', /** Netherlands */
'578', /** Norway */
'616', /** Poland */
'620', /** Portugal */
'642', /** Romania */
'703', /** Slovakia */
'705', /** Slovenia */
'724', /** Spain */
'752', /** Sweden */
'756', /** Switzerland */
'826', /** United Kingdom */
];
const DOMTOM_ISOCODES = [
'175', /** Mayotte */
'254', /** Guyane Française */
'258', /** Polynésie Française */
'312', /** Guadeloupe */
'474', /** Martinique */
'540', /** Nouvelle-Calédonie */
'638', /** Réunion(La) */
'666', /** St Pierre et Miquelon */
'876', /** Wallis et Futuna */
];
protected $productCode = '';
/** @var \DateTime */
protected $depositDate;
protected $orderNumber = '';
protected $commercialName = '';
protected $transportationAmount = '';
protected $returnTypeChoice = 3;
public function __construct($productCode, \DateTime $depositDate, $orderNumber, $transportationAmount, $returnTypeChoice)
{
if (empty($orderNumber)) {
throw new InvalidArgumentException('Invalid argument orderNumber');
}
if (empty($productCode)) {
throw new InvalidArgumentException('Invalid argument productCode');
}
$this->orderNumber = $orderNumber;
$this->depositDate = $depositDate;
$this->productCode = $productCode;
$this->transportationAmount = $transportationAmount;
$this->returnTypeChoice = $returnTypeChoice;
}
/**
* @return string
*/
public function getProductCode()
{
return $this->productCode;
}
/**
* @param string $productCode
* @return $this
*/
public function setProductCode($productCode)
{
$this->productCode = $productCode;
return $this;
}
/**
* @return \DateTime
*/
public function getDepositDate()
{
return $this->depositDate;
}
/**
* @return string
*/
public function getOrderNumber()
{
return $this->orderNumber;
}
/**
* @return string
*/
public function getCommercialName()
{
return $this->commercialName;
}
/**
* @param string $commercialName
* @return Service
*/
public function setCommercialName($commercialName)
{
$this->commercialName = $commercialName;
return $this;
}
/**
* @return string
*/
public function getTransportationAmount()
{
/** DO NOT use strict comparison here */
if ($this->transportationAmount == 0) {
return '0';
}
/** Formatting the postage price in a XXXX format (price in cents without separator), as requested by the Colissimo API */
$nbr = number_format($this->transportationAmount, 2, '.', '');
if ((float)$nbr < 10) {
$nbr = '0' . $nbr;
}
return str_pad(str_replace('.', '', $nbr), 4, '0', STR_PAD_RIGHT);
}
/**
* @param $transportationAmount
* @return $this
*/
public function setTransportationAmount($transportationAmount)
{
$this->transportationAmount = $transportationAmount;
return $this;
}
/**
* @return int
*/
public function getReturnTypeChoice()
{
return $this->returnTypeChoice;
}
/**
* @param $returnTypeChoice
* @return $this
*/
public function setReturnTypeChoice($returnTypeChoice)
{
$this->returnTypeChoice = $returnTypeChoice;
return $this;
}
}