Skip to content

omnibus/dhl API reference

Floor
Provider · Omnibus
Version
2.x
Conformance suite
runs, no CI read
Verified for real
Its README does not say
Licence
MIT
composer require omnibus/dhl:2.x-dev

Read from the package's own PHP files at the commit 19040f83af96: 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\Dhl

  • Api class

    DHL Express's MyDHL API (basic auth, API key and secret), and DHL's location finder (its own key).

    3 methods · 3 properties · 3 constants

  • DhlGatewayFactory class

    options: api_key: '%env(DHL_API_KEY)%' # a MyDHL API app (developer.dhl.com) api_secret: '%env(DHL_API_SECRET)%' account_number: '%env(DHL_ACCOUNT)%' # the export account sandbox: true location_api_key: null # optional, DHL's Location Finder (service points) rates: [...] # optional: configured prices instead of the rates API

    10 options

  • Mapping class

    MyDHL's shapes for ours.

    3 methods

Omnibus\Dhl\Action

  • PickupAction class

    DHL's Location Finder: service points near an address (its own API key).

    3 methods

  • RatingAction class

    POST /rates: every product DHL Express offers for the shipment, priced with the account's rates.

    3 methods

  • ShippingAction class

    POST /shipments: the shipment booked with the product chosen (service: a product code, "P" by default), its label as PDF.

    3 methods

  • TrackingAction class

    GET /shipments/{id}/tracking: the shipment's events, oldest first.

    3 methods

Omnibus\Dhl

Api class

final class Api Api.php:11

DHL Express's MyDHL API (basic auth, API key and secret), and DHL's location finder (its own key).

const LIVE = 'https://express.api.dhl.com/mydhlapi'
const TEST = 'https://express.api.dhl.com/mydhlapi/test'
const LOCATIONS = 'https://api.dhl.com/location-finder/v1/find-by-address'
public readonly string $accountNumber
public readonly bool $sandbox
public readonly ?string $locationApiKey

Api::__construct()

public function __construct(readonly HttpClientInterface $http, readonly string $apiKey, readonly string $apiSecret, public readonly string $accountNumber, public readonly bool $sandbox = false, public readonly ?string $locationApiKey = null, readonly int $timeout = 20)

Api::call()

public function call(string $method, string $path, ?array $body = null, array $query = []): array

Api::locations()

public function locations(array $query): array

DhlGatewayFactory class

final class DhlGatewayFactory extends GatewayFactory DhlGatewayFactory.php:22

options: api_key: '%env(DHL_API_KEY)%' # a MyDHL API app (developer.dhl.com) api_secret: '%env(DHL_API_SECRET)%' account_number: '%env(DHL_ACCOUNT)%' # the export account sandbox: true location_api_key: null # optional, DHL's Location Finder (service points) rates: [...] # optional: configured prices instead of the rates API

Options

OptionDefault
sandboxfalse
location_api_keynull
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['api_key'], (string) $c['api_secret'], (string)…
omnibus.action.ratingstatic fn(Config $c) => $c->get('rates') ? null : new RatingAction()
omnibus.action.shippingnew ShippingAction()
omnibus.action.trackingnew TrackingAction()
omnibus.action.pickupstatic fn(Config $c) => $c['location_api_key'] ? new PickupAction() : null
api_keyrequired
api_secretrequired
account_numberrequired

Mapping class

final class Mapping Mapping.php:10

MyDHL's shapes for ours.

Mapping::details()

public static function details(Address $a): array

Mapping::package()

public static function package(Parcel $p): array

Mapping::status()

public static function status(?string $code): TrackingStatus

Omnibus\Dhl\Action

PickupAction class

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

DHL's Location Finder: service points near an address (its own API key).

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

POST /rates: every product DHL Express offers for the shipment, priced with the account's rates.

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

POST /shipments: the shipment booked with the product chosen (service: a product code, "P" by default), its label as PDF.

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

GET /shipments/{id}/tracking: the shipment's events, oldest first.

TrackingAction::__construct()

public function __construct()

TrackingAction::supports()

public function supports(Request $request): bool

TrackingAction::execute()

public function execute(Request $request): void