Skip to content

omnibus/chronopost API reference

Floor
Provider · Omnibus
Version
2.x
Conformance suite
runs, no CI read
Verified for real
Verified in part
Licence
MIT
composer require omnibus/chronopost:2.x-dev

Read from the package's own PHP files at the commit 5a1fd7eb65b4: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnibus\Chronopost

  • Api class

    Chronopost's web services (SOAP 1.1, ws.chronopost.fr): Quickcost for prices, ShippingServiceWS for labels, TrackingServiceWS for events, PointRelaisServiceWS for Pickup points. The account number and password travel inside each request's body.

    4 methods · 3 properties · 5 constants

  • ChronopostGatewayFactory class

    options: account_number: '%env(CHRONOPOST_ACCOUNT)%' # the 8-digit contract number password: '%env(CHRONOPOST_PASSWORD)%' # its web services password sub_account: null # optional, 3 digits rates: [...] # optional: configured prices instead of Quickcost

    9 options · 2 constants

  • Mapping class

    Chronopost's XML for ours. Products: 01 Chrono 13, 02 Chrono 10, 16 Chrono 18, 86 Chrono Relais 13, 17 Chrono Classic (international), 44 Chrono Express.

    4 methods · 3 constants

Omnibus\Chronopost\Action

  • CancelAction class

    TrackingServiceWS's cancelSkybill: a skybill not yet picked up, cancelled.

    3 methods

  • PickupAction class

    PointRelaisServiceWS's recherchePointChronopostInter: Pickup relays near an address.

    3 methods

  • RatingAction class

    Quickcost's calculateProducts: every product for the lane, with the contract's prices (option products: the codes to keep).

    3 methods

  • ShippingAction class

    ShippingServiceWS's shippingMultiParcelV4: the label (PDF; "ZPL" with option label_format) for a product (service: 01 Chrono 13 by default; a pickupPoint makes it a Relais product, and its id the recipient reference, which is how Chronopost knows the point).

    3 methods

  • TrackingAction class

    TrackingServiceWS's trackSkybillV2: the events, oldest first.

    3 methods

Omnibus\Chronopost

Api class

final class Api Api.php:16

Chronopost's web services (SOAP 1.1, ws.chronopost.fr): Quickcost for prices, ShippingServiceWS for labels, TrackingServiceWS for events, PointRelaisServiceWS for Pickup points. The account number and password travel inside each request's body.

const BASE = 'https://ws.chronopost.fr'
const QUICKCOST = ['/quickcost-cxf/QuickcostServiceWS', 'http://cxf.quickcost.soap.chronopost.fr/']
const SHIPPING = ['/shipping-cxf/ShippingServiceWS', 'http://cxf.shipping.soap.chronopost.fr/']
const TRACKING = ['/tracking-cxf/TrackingServiceWS', 'http://cxf.tracking.soap.chronopost.fr/']
const RELAIS = ['/recherchebt-ws-cxf/PointRelaisServiceWS', 'http://cxf.rechercherbt.soap.chronopost.fr/']
public readonly string $accountNumber
public readonly string $password
public readonly ?string $subAccount

Api::__construct()

public function __construct(readonly HttpClientInterface $http, public readonly string $accountNumber, public readonly string $password, public readonly ?string $subAccount = null, readonly int $timeout = 20)

Api::call()

public function call(array $service, string $operation, string $params): \SimpleXMLElement

One SOAP call: the operation and its parameters as inner XML; back as the <return> element.

Api::e()

public static function e(string $s): string

Api::civility()

public static function civility(\Omnibus\Model\Address $a): string

Chronopost's civility code for a party: E for a company (Entreprise), M for a person.

ChronopostGatewayFactory class

final class ChronopostGatewayFactory extends GatewayFactory ChronopostGatewayFactory.php:23

options: account_number: '%env(CHRONOPOST_ACCOUNT)%' # the 8-digit contract number password: '%env(CHRONOPOST_PASSWORD)%' # its web services password sub_account: null # optional, 3 digits rates: [...] # optional: configured prices instead of Quickcost

Chronopost has no sandbox: the test account 19869502 / 255562 is the published one.

Options

OptionDefault
sub_accountnull
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['account_number'], (string) $c['password'], $c[…
omnibus.action.ratingstatic fn(Config $c) => $c->get('rates') ? null : new RatingAction()
omnibus.action.shippingnew ShippingAction()
omnibus.action.trackingnew TrackingAction()
omnibus.action.pickupnew PickupAction()
omnibus.action.cancelnew CancelAction()
account_numberrequired
passwordrequired
const TEST_ACCOUNT = '19869502'

Chronopost's test account, published in its web services' documentation, the same for everyone: test identifiers, not a secret.

const TEST_PASSWORD = '255562'

Mapping class

final class Mapping Mapping.php:9

Chronopost's XML for ours. Products: 01 Chrono 13, 02 Chrono 10, 16 Chrono 18, 86 Chrono Relais 13, 17 Chrono Classic (international), 44 Chrono Express.

const PRODUCTS = [ '01' => 'Chrono 13', '02' => 'Chrono 10', '16' => 'Chrono 18', '86' => 'Chrono Relais 13', '5X' => 'Chrono Relais Europe', '17' => …
const RANGES = [ 'fresh' => ['2R', '6S'], // 0 to 4 °C 'freeze' => ['2S', null], // -18 °C: no relay 'ambient' => ['5M', '5Q'], ]

The Chronofresh ranges a shipment asks for with its product option, at home and (where there is one) to a relay.

const CHILLED = ['2R', '6S', '2S']

The products that travel cold: Chronopost delivers them only with a use-by date, not yet passed.

Mapping::product()

public static function product(?string $service, ?string $range, bool $toPickupPoint): string

The product code of a shipment: the service it names, else its product range (fresh, freeze, ambient) at home or to a relay, else Chrono 13 (Chrono Relais 13 to a pickup point).

Mapping::day()

public static function day(\DateTimeInterface|string|null $date): ?string

A use-by date as Chronopost reads it (yyyy-mm-dd), from a date or a string.

Mapping::valueXml()

public static function valueXml(string $prefix, Address $a): string

Mapping::status()

public static function status(?string $code, ?string $label = null): TrackingStatus

Omnibus\Chronopost\Action

CancelAction class

final class CancelAction implements ActionInterface, ApiAwareInterface CancelAction.php:13

TrackingServiceWS's cancelSkybill: a skybill not yet picked up, cancelled.

CancelAction::__construct()

public function __construct()

CancelAction::supports()

public function supports(Request $request): bool

CancelAction::execute()

public function execute(Request $request): void

PickupAction class

final class PickupAction implements ActionInterface, ApiAwareInterface PickupAction.php:15

PointRelaisServiceWS's recherchePointChronopostInter: Pickup relays near an address.

PickupAction::__construct()

public function __construct()

PickupAction::supports()

public function supports(Request $request): bool

PickupAction::execute()

public function execute(Request $request): void

RatingAction class

final class RatingAction implements ActionInterface, ApiAwareInterface RatingAction.php:15

Quickcost's calculateProducts: every product for the lane, with the contract's prices (option products: the codes to keep).

RatingAction::__construct()

public function __construct()

RatingAction::supports()

public function supports(Request $request): bool

RatingAction::execute()

public function execute(Request $request): void

ShippingAction class

final class ShippingAction implements ActionInterface, ApiAwareInterface ShippingAction.php:26

ShippingServiceWS's shippingMultiParcelV4: the label (PDF; "ZPL" with option label_format) for a product (service: 01 Chrono 13 by default; a pickupPoint makes it a Relais product, and its id the recipient reference, which is how Chronopost knows the point).

Chronofresh: the shipment's product option (fresh, freeze, ambient) picks the range's code (2R, 6S to a relay, 2S, 5M, 5Q) and use_by the parcel's use-by date (scheduledValue: expirationDate, sellByDate - sell_by when it differs); saturday asks a Saturday delivery (service 6).

ShippingAction::__construct()

public function __construct()

ShippingAction::supports()

public function supports(Request $request): bool

ShippingAction::execute()

public function execute(Request $request): void

TrackingAction class

final class TrackingAction implements ActionInterface, ApiAwareInterface TrackingAction.php:17

TrackingServiceWS's trackSkybillV2: the events, oldest first.

TrackingAction::__construct()

public function __construct()

TrackingAction::supports()

public function supports(Request $request): bool

TrackingAction::execute()

public function execute(Request $request): void