Aller au contenu

omnibus/tnt Référence de l’API

Étage
Fournisseur · Omnibus
Version
2.x
Suite de conformité
branchée, CI non lue
Vérifié en réel
Son README ne le dit pas
Licence
MIT
composer require omnibus/tnt:2.x-dev

Lue dans les fichiers PHP du paquet au commit a39c55f15574 : ses espaces de noms, classes, interfaces et énumérations, leurs constantes, propriétés et méthodes publiques avec leur PHPDoc, et les options que prennent ses fabriques. Rien n’en est exécuté.

Omnibus\Tnt

  • Api class

    TNT's ExpressConnect (express.tnt.com): XML documents posted as form fields, basic auth for pricing and tracking, the login inside the document for shipping. Still answered for existing accounts since TNT joined FedEx; new accounts get FedEx's APIs instead.

    3 methods · 3 properties · 3 constants

  • Mapping class

    ExpressConnect's XML for ours.

    2 methods · 1 constant

  • TntGatewayFactory class

    options: username: '%env(TNT_USERNAME)%' # the ExpressConnect login password: '%env(TNT_PASSWORD)%' account_number: '%env(TNT_ACCOUNT)%' sender: { name, company, street: [], postcode, city, country, phone, email } # optional: the account's collection address when it is not the shipment's sender rates: [...] # optional: configured prices instead of ExpressConnect Pricing

    8 options

Omnibus\Tnt\Action

  • RatingAction class

    ExpressConnect Pricing's priceCheck: every service on the lane, with the account's prices.

    3 methods

  • ShippingAction class

    ExpressConnect Shipping: the consignment posted (an access code comes back), then its result and label fetched with that code. The service is TNT's product code (15N Express by default).

    3 methods

  • TrackingAction class

    ExpressConnect Tracking: the consignment's status events, oldest first.

    3 methods

Omnibus\Tnt

Api class

final class Api Api.php:16

TNT's ExpressConnect (express.tnt.com): XML documents posted as form fields, basic auth for pricing and tracking, the login inside the document for shipping. Still answered for existing accounts since TNT joined FedEx; new accounts get FedEx's APIs instead.

const PRICING = 'https://express.tnt.com/expressconnect/pricing/getprice'
const SHIPPING = 'https://express.tnt.com/expressconnect/shipping/ship'
const TRACKING = 'https://express.tnt.com/expressconnect/track.do'
public readonly string $username
public readonly string $password
public readonly string $accountNumber

Api::__construct()

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

Api::call()

public function call(string $url, string $field, string $xml, bool $auth = true): \SimpleXMLElement

One XML document posted; back as the parsed answer.

Api::e()

public static function e(string $s): string

Mapping class

final class Mapping Mapping.php:9

ExpressConnect's XML for ours.

const SERVICES = ['15N' => 'Express', '09N' => '9:00 Express', '10N' => '10:00 Express', '12N' => '12:00 Express', '48N' => 'Economy Express', '15D' => 'Express Documents', '…

Mapping::address()

public static function address(Address $a): string

Mapping::status()

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

TntGatewayFactory class

final class TntGatewayFactory extends GatewayFactory TntGatewayFactory.php:25

options: username: '%env(TNT_USERNAME)%' # the ExpressConnect login password: '%env(TNT_PASSWORD)%' account_number: '%env(TNT_ACCOUNT)%' sender: { name, company, street: [], postcode, city, country, phone, email } # optional: the account's collection address when it is not the shipment's sender rates: [...] # optional: configured prices instead of ExpressConnect Pricing

No pickup points, no cancellation: ExpressConnect offers neither; TNT Depots are addressed by phone. ExpressConnect has no sandbox: a test account is one TNT marks as such.

Options

OptionDefault
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['username'], (string) $c['password'], (string) …
omnibus.action.ratingstatic fn(Config $c) => $c->get('rates') ? null : new RatingAction()
sendernull
omnibus.action.shippingstatic fn(Config $c) => new ShippingAction(self::collection($c['sender']))
omnibus.action.trackingnew TrackingAction()
usernamerequired
passwordrequired
account_numberrequired

Omnibus\Tnt\Action

RatingAction class

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

ExpressConnect Pricing's priceCheck: every service on the lane, with the account's prices.

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:21

ExpressConnect Shipping: the consignment posted (an access code comes back), then its result and label fetched with that code. The service is TNT's product code (15N Express by default).

ShippingAction::__construct()

public function __construct(readonly ?Address $collection = null)
$collection

the account's collection address, when it is not the shipment's sender (option "sender")

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

ExpressConnect Tracking: the consignment's status events, oldest first.

TrackingAction::__construct()

public function __construct()

TrackingAction::supports()

public function supports(Request $request): bool

TrackingAction::execute()

public function execute(Request $request): void