Initial commit

This commit is contained in:
2020-10-07 10:37:15 +02:00
commit ce5f440392
28157 changed files with 4429172 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
<?php
/**
* Class AbstractColissimoRequest
*/
abstract class AbstractColissimoRequest
{
/** @var array $request */
protected $request;
/** @var string $xmlLocation */
protected $xmlLocation;
/** @var string $forceEndpoint */
public $forceEndpoint;
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
*/
abstract public function buildResponse($responseHeader, $responseBody);
/**
* @return mixed
*/
abstract public function buildRequest();
/**
* AbstractColissimoRequest constructor.
* @param array $credentials
* @throws Exception
*/
public function __construct(array $credentials)
{
if (!isset($credentials['contract_number']) || !isset($credentials['password'])) {
throw new Exception('Bad credentials.');
}
$this->setIdentification($credentials);
$this->xmlLocation = dirname(__FILE__).'/../xml/';
}
/**
* @param array $credentials
*/
final private function setIdentification(array $credentials)
{
$this->request = array();
$this->request['contractNumber'] = $credentials['contract_number'];
$this->request['password'] = $credentials['password'];
if (isset($credentials['force_endpoint'])) {
$this->forceEndpoint = $credentials['force_endpoint'];
}
}
/**
* @param bool $obfuscatePassword
* @return array|string
*/
public function getRequest($obfuscatePassword = false)
{
if ($obfuscatePassword) {
$request = $this->request;
$request['password'] = '*****';
$request['contractNumber'] = '*****';
return json_encode($request);
}
return json_encode($this->request);
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
* Class ColissimoCheckGenerateLabelRequest
*/
class ColissimoCheckGenerateLabelRequest extends ColissimoGenerateLabelRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/sls-ws/SlsServiceWSRest/2.0/checkGenerateLabel?';
const WS_CONTENT_TYPE = 'application/json';
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoCheckGenerateLabelResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,87 @@
<?php
/**
* Class ColissimoGenerateBordereauRequest
*/
class ColissimoGenerateBordereauRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'SOAP';
const WS_METHOD = 'generateBordereauByParcelsNumbers';
const WS_CONTENT_TYPE = 'application/xml';
/** @var SimpleXMLElement $xml */
public $xml;
/**
* ColissimoGenerateBordereauRequest constructor.
* @param array $credentials
* @throws Exception
*/
public function __construct(array $credentials)
{
parent::__construct($credentials);
$this->xml = simplexml_load_file($this->xmlLocation.self::WS_METHOD.'.xml');
$this->xml->registerXPathNamespace('sls', 'http://sls.ws.coliposte.fr');
$this->setCredentials();
}
/**
* @param array $numbers
*/
public function setParcelsNumbers(array $numbers)
{
$list = $this->xml->xpath('soapenv:Body/sls:generateBordereauByParcelsNumbers/generateBordereauParcelNumberList');
foreach ($numbers as $number) {
$list[0]->addChild('parcelsNumbers', $number);
}
}
/**
*
*/
public function setCredentials()
{
$parcels = $this->xml->xpath('soapenv:Body/sls:generateBordereauByParcelsNumbers');
$parcels[0]->contractNumber = $this->request['contractNumber'];
$parcels[0]->password = $this->request['password'];
}
/**
* @return mixed|void
*/
public function buildRequest()
{
return;
}
/**
* @param bool $obfuscatePassword
* @return string
*/
public function getRequest($obfuscatePassword = false)
{
if ($obfuscatePassword) {
$requestXml = new SimpleXMLElement($this->xml->asXML());
$requestXml->registerXPathNamespace('sls', 'http://sls.ws.coliposte.fr');
$parcels = $requestXml->xpath('soapenv:Body/sls:generateBordereauByParcelsNumbers');
$parcels[0]->password = '****';
$parcels[0]->contractNumber = '****';
$requestJsonString = json_encode($parcels);
return $requestJsonString;
}
return $this->xml->asXML();
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoGenerateBordereauResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,142 @@
<?php
/**
* Class ColissimoGenerateLabelRequest
*/
class ColissimoGenerateLabelRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/sls-ws/SlsServiceWSRest/2.0/generateLabel?';
const WS_CONTENT_TYPE = 'application/json';
/** @var array $output */
protected $output;
/** @var array $senderAddress */
protected $senderAddress;
/** @var array $addresseeAddress */
protected $addresseeAddress;
/** @var array $shipmentOptions */
protected $shipmentOptions;
/** @var array $shipmentServices */
protected $shipmentServices;
/** @var array $customsOptions */
protected $customsOptions;
/** @var array $fields */
protected $fields;
/**
* @param array $output
* @return ColissimoGenerateLabelRequest
*/
public function setOutput($output)
{
$this->output = $output;
return $this;
}
/**
* @param array $senderAddress
* @return ColissimoGenerateLabelRequest
*/
public function setSenderAddress($senderAddress)
{
$this->senderAddress = $senderAddress;
return $this;
}
/**
* @param array $addresseeAddress
* @return ColissimoGenerateLabelRequest
*/
public function setAddresseeAddress($addresseeAddress)
{
$this->addresseeAddress = $addresseeAddress;
return $this;
}
/**
* @param array $shipmentOptions
* @return ColissimoGenerateLabelRequest
*/
public function setShipmentOptions($shipmentOptions)
{
$this->shipmentOptions = $shipmentOptions;
return $this;
}
/**
* @param array $shipmentServices
* @return ColissimoGenerateLabelRequest
*/
public function setShipmentServices($shipmentServices)
{
$this->shipmentServices = $shipmentServices;
return $this;
}
/**
* @param array $customsOptions
* @return ColissimoGenerateLabelRequest
*/
public function setCustomsOptions($customsOptions)
{
$this->customsOptions = $customsOptions;
return $this;
}
/**
* @param array $customField
* @return ColissimoGenerateLabelRequest
*/
public function addCustomField($customField)
{
foreach ($customField as $key => $field) {
$this->fields['customField'][$key] = array(
'key' => $field['key'],
'value' => $field['value'],
);
}
return $this;
}
/**
* @return mixed|void
*/
public function buildRequest()
{
$this->request['outputFormat'] = $this->output;
$this->request['letter']['service'] = $this->shipmentServices;
$this->request['letter']['parcel'] = $this->shipmentOptions;
if (!empty($this->customsOptions)) {
$this->request['letter']['customsDeclarations'] = $this->customsOptions;
}
$this->request['letter']['sender'] = $this->senderAddress;
$this->request['letter']['addressee'] = $this->addresseeAddress;
$this->request['fields'] = $this->fields;
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoGenerateLabelResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Class ColissimoMailboxDetailsRequest
*/
class ColissimoMailboxDetailsRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/sls-ws/SlsServiceWSRest/2.0/getListMailBoxPickingDates?';
const WS_CONTENT_TYPE = 'application/json';
/** @var array $senderAddress */
protected $senderAddress;
/**
* @param mixed $senderAddress
* @return ColissimoMailboxDetailsRequest
*/
public function setSenderAddress($senderAddress)
{
$this->senderAddress = $senderAddress;
return $this;
}
/**
* @return void
*/
public function buildRequest()
{
$this->request['sender'] = $this->senderAddress;
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoMailboxDetailsResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,74 @@
<?php
/**
* Class ColissimoPlanPickupRequest
*/
class ColissimoPlanPickupRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/sls-ws/SlsServiceWSRest/2.0/planPickup?';
const WS_CONTENT_TYPE = 'application/json';
/** @var string $parcelNumber */
protected $parcelNumber;
/** @var string $mailboxPickingDate */
protected $mailboxPickingDate;
/** @var array $senderAddress */
protected $senderAddress;
/**
* @param string $parcelNumber
* @return ColissimoPlanPickupRequest
*/
public function setParcelNumber($parcelNumber)
{
$this->parcelNumber = $parcelNumber;
return $this;
}
/**
* @param string $mailboxPickingDate
* @return ColissimoPlanPickupRequest
*/
public function setMailboxPickingDate($mailboxPickingDate)
{
$this->mailboxPickingDate = $mailboxPickingDate;
return $this;
}
/**
* @param array $senderAddress
* @return ColissimoPlanPickupRequest
*/
public function setSenderAddress($senderAddress)
{
$this->senderAddress = $senderAddress;
return $this;
}
/**
* @return void
*/
public function buildRequest()
{
$this->request['parcelNumber'] = $this->parcelNumber;
$this->request['mailBoxPickingDate'] = $this->mailboxPickingDate;
$this->request['sender'] = $this->senderAddress;
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoPlanPickupResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* Class ColissimoTrackingEnrichiRequest
*/
class ColissimoTrackingEnrichiRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/tracking-unified-ws/TrackingUnifiedServiceWSRest/tracking/getTrackingMessagePickupAdressAndDeliveryDate?';
const WS_CONTENT_TYPE = 'application/json';
const TRACKING_SUBMISSION_CONTACT = 'TRACKING_PARTNER';
/** @var string $lang */
protected $lang;
/** @var string $ip */
protected $ip;
/** @var string $parcelNumber */
protected $parcelNumber;
/**
* ColissimoTrackingEnrichiRequest constructor.
* @param array $credentials
* @throws Exception
*/
public function __construct(array $credentials)
{
parent::__construct($credentials);
$this->request['login'] = $this->request['contractNumber'];
unset($this->request['contractNumber']);
}
/**
* @param mixed $lang
* @return ColissimoTrackingEnrichiRequest
*/
public function setLang($lang)
{
$this->lang = $lang;
return $this;
}
/**
* @param mixed $ip
* @return ColissimoTrackingEnrichiRequest
*/
public function setIp($ip)
{
$this->ip = $ip;
return $this;
}
/**
* @param mixed $parcelNumber
* @return ColissimoTrackingEnrichiRequest
*/
public function setParcelNumber($parcelNumber)
{
$this->parcelNumber = $parcelNumber;
return $this;
}
/**
* @return void
*/
public function buildRequest()
{
$this->request['parcelNumber'] = $this->parcelNumber;
$this->request['ip'] = $this->ip;
$this->request['lang'] = $this->lang;
$this->request['parcelNumber'] = $this->parcelNumber;
$this->request['profil'] = self::TRACKING_SUBMISSION_CONTACT;
return;
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoTrackingEnrichiResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* Class ColissimoTrackingSimpleRequest
*/
class ColissimoTrackingSimpleRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/tracking-chargeur-cxf/TrackingServiceWS/track';
const WS_CONTENT_TYPE = 'application/xml;charset=UTF-8';
/** @var SimpleXMLElement $xml */
public $xml;
/**
* ColissimoTrackingSimpleRequest constructor.
* @param array $credentials
* @throws Exception
*/
public function __construct(array $credentials)
{
parent::__construct($credentials);
$this->xml = simplexml_load_file($this->xmlLocation.'track.xml');
$this->xml->registerXPathNamespace('char', 'http://chargeur.tracking.geopost.com');
$this->setCredentials();
}
/**
*
*/
public function setCredentials()
{
$track = $this->xml->xpath('soapenv:Body/char:track');
$track[0]->accountNumber = $this->request['contractNumber'];
$track[0]->password = $this->request['password'];
}
public function setSkybillNumber($skybillNumber)
{
$track = $this->xml->xpath('soapenv:Body/char:track');
$track[0]->skybillNumber = $skybillNumber;
}
/**
* @return mixed|void
*/
public function buildRequest()
{
return;
}
/**
* @param bool $obfuscatePassword
* @return string
*/
public function getRequest($obfuscatePassword = false)
{
if ($obfuscatePassword) {
$requestXml = new SimpleXMLElement($this->xml->asXML());
$requestXml->registerXPathNamespace('char', 'http://chargeur.tracking.geopost.com');
$track = $requestXml->xpath('soapenv:Body/char:track');
$track[0]->password = '****';
$track[0]->accountNumber = '****';
$requestJsonString = json_encode($track);
return $requestJsonString;
}
return $this->xml->asXML();
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoTrackingSimpleResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,44 @@
<?php
/**
* Class ColissimoTrackingTimelineRequest
*/
class ColissimoTrackingTimelineRequest extends ColissimoTrackingEnrichiRequest
{
const WS_PATH = '/tracking-timeline-ws/rest/tracking/timeline';
const TRACKING_PROFILE = 'TRACKING_BNUM';
/** @var string $lang */
protected $lang;
/** @var string $ip */
protected $ip;
/** @var string $parcelNumber */
protected $parcelNumber;
/**
* @return void
*/
public function buildRequest()
{
$this->request['parcelNumber'] = $this->parcelNumber;
$this->request['ip'] = $this->ip;
$this->request['lang'] = $this->lang;
$this->request['parcelNumber'] = $this->parcelNumber;
$this->request['profil'] = self::TRACKING_PROFILE;
return;
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoTrackingTimelineResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,58 @@
<?php
/**
* Class ColissimoWidgetAuthenticationRequest
*/
class ColissimoWidgetAuthenticationRequest extends AbstractColissimoRequest
{
const WS_TYPE = 'CURL';
const WS_PATH = '/widget-point-retrait/rest/authenticate.rest';
const WS_CONTENT_TYPE = 'application/x-www-form-urlencoded';
/**
* ColissimoWidgetAuthenticationRequest constructor.
* @param array $credentials
* @throws Exception
*/
public function __construct(array $credentials)
{
parent::__construct($credentials);
$this->request['login'] = $this->request['contractNumber'];
unset($this->request['contractNumber']);
}
/**
* @return void
*/
public function buildRequest()
{
return;
}
/**
* @param bool $obfuscatePassword
* @return array|string
*/
public function getRequest($obfuscatePassword = false)
{
if ($obfuscatePassword) {
$request = $this->request;
$request['password'] = '****';
return json_encode($request);
}
return http_build_query($this->request);
}
/**
* @param mixed $responseHeader
* @param mixed $responseBody
* @return mixed
* @throws Exception
*/
public function buildResponse($responseHeader, $responseBody)
{
return ColissimoWidgetAuthenticationResponse::buildFromResponse($responseHeader, $responseBody);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2020 PrestaShop SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;