Ajout des modules ColissimoWs et ColissimoLabel.php

Ne pas oublier de vérifier si les tables nécessaires sont bien créées en BDD.
This commit is contained in:
2020-05-07 11:45:31 +02:00
parent 28b21af6c8
commit 649c92e52f
114 changed files with 21550 additions and 8312 deletions

View File

@@ -0,0 +1,118 @@
<?php
namespace ColissimoLabel\Request\Helper;
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(ConfigQuery::read('colissimo.api.contract.number'));
$this->setPassword(ConfigQuery::read('colissimo.api.password'));
$this->setWsdl('https://ws.colissimo.fr/sls-ws/SlsServiceWS/2.0?wsdl');
}
/**
* @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,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,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,65 @@
<?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;
public function __construct(
Service $service,
Sender $sender,
Addressee $addressee,
Parcel $parcel
) {
$this->sender = $sender;
$this->addressee = $addressee;
$this->parcel = $parcel;
$this->service = $service;
}
/**
* @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;
}
}

View File

@@ -0,0 +1,86 @@
<?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'
];
const OUTPUT_PRINTING_TYPE_DEFAULT = self::OUTPUT_PRINTING_TYPE[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,74 @@
<?php
namespace ColissimoLabel\Request\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class Parcel
{
protected $weight = 0;
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 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,136 @@
<?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 ****'
];
protected $productCode = '';
/** @var \DateTime */
protected $depositDate;
protected $orderNumber = '';
protected $commercialName = '';
public function __construct($productCode, \DateTime $depositDate, $orderNumber)
{
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;
}
/**
* @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;
}
}