Skip to content

omnibus/auspost 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/auspost:2.x-dev

Read from the package's own PHP files at the commit 19ea81336a71: 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\Auspost

  • Api class

    Australia Post's Shipping and Tracking API (basic auth with the API key and password, the account number in a header).

    3 methods · 2 properties · 2 constants

  • AuspostGatewayFactory class

    options: api_key: '%env(AUSPOST_API_KEY)%' # Shipping and Tracking API (developers.auspost.com.au) password: '%env(AUSPOST_PASSWORD)%' account_number: '%env(AUSPOST_ACCOUNT)%' # the 10-digit charge account sandbox: true rates: [...] # optional: configured prices instead of /prices/items

    10 options

  • Mapping class

    Australia Post's shapes for ours.

    4 methods · 1 constant

Omnibus\Auspost\Action

  • CancelAction class

    DELETE /shipping/v1/shipments: the shipment found by its article's tracking id, deleted before it is lodged.

    3 methods

  • GetSlipAction class

    The label of a shipment created earlier: GET /shipping/v1/shipments by tracking id gives its shipment id and product (as cancel() finds them), POST /shipping/v1/labels its PDF, as ship() asks for it.

    4 methods

  • RatingAction class

    POST /shipping/v1/prices/items: every product the account can send the items with, priced.

    3 methods

  • ShippingAction class

    POST /shipping/v1/shipments, then POST /shipping/v1/labels for its PDF: the label is generated asynchronously, so the result carries the label's link; the content is fetched when Australia Post says it is ready.

    4 methods

  • TrackingAction class

    GET /shipping/v1/track: the article's events, oldest first.

    3 methods

Omnibus\Auspost

Api class

final class Api Api.php:11

Australia Post's Shipping and Tracking API (basic auth with the API key and password, the account number in a header).

const LIVE = 'https://digitalapi.auspost.com.au'
const TEST = 'https://digitalapi.auspost.com.au/test'
public readonly string $accountNumber
public readonly bool $sandbox

Api::__construct()

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

Api::base()

public function base(): string

Api::call()

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

JSON, or ['content' => binary] for a document

AuspostGatewayFactory class

final class AuspostGatewayFactory extends GatewayFactory AuspostGatewayFactory.php:24

options: api_key: '%env(AUSPOST_API_KEY)%' # Shipping and Tracking API (developers.auspost.com.au) password: '%env(AUSPOST_PASSWORD)%' account_number: '%env(AUSPOST_ACCOUNT)%' # the 10-digit charge account sandbox: true rates: [...] # optional: configured prices instead of /prices/items

No pickup points: parcel lockers and post offices are addressed as recipient addresses.

Options

OptionDefault
sandboxfalse
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['api_key'], (string) $c['password'], (string) $…
omnibus.action.ratingstatic fn(Config $c) => $c->get('rates') ? null : new RatingAction()
omnibus.action.shippingnew ShippingAction()
omnibus.action.trackingnew TrackingAction()
omnibus.action.cancelnew CancelAction()
omnibus.action.get_slipnew GetSlipAction()
api_keyrequired
passwordrequired
account_numberrequired

Mapping class

final class Mapping Mapping.php:11

Australia Post's shapes for ours.

const PRODUCTS = ['PP' => 'Parcel Post', 'EXP' => 'Express Post', 'PTI8' => 'International Standard', 'ECM8' => 'International Express', 'AIR8' => 'International Economy Air']

Mapping::labelGroup()

public static function labelGroup(string $product, string $country): string

The label group of POST /labels for a product: International abroad, Express Post for an Express product (EXP, or a contract product named so), Parcel Post otherwise.

Mapping::party()

public static function party(Address $a, ?string $state = null): array

Mapping::item()

public static function item(Parcel $p, Shipment $s, string $product): array

Mapping::status()

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

Omnibus\Auspost\Action

CancelAction class

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

DELETE /shipping/v1/shipments: the shipment found by its article's tracking id, deleted before it is lodged.

CancelAction::__construct()

public function __construct()

CancelAction::supports()

public function supports(Request $request): bool

CancelAction::execute()

public function execute(Request $request): void

GetSlipAction class

final class GetSlipAction implements ActionInterface, ApiAwareInterface GetSlipAction.php:20

The label of a shipment created earlier: GET /shipping/v1/shipments by tracking id gives its shipment id and product (as cancel() finds them), POST /shipping/v1/labels its PDF, as ship() asks for it.

GetSlipAction::__construct()

public function __construct()

GetSlipAction::supports()

public function supports(Request $request): bool

GetSlipAction::execute()

public function execute(Request $request): void

GetSlipAction::label()

public static function label(Api $api, string $shipmentId, string $group, string $layout): array

POST /shipping/v1/labels for a shipment id, waiting for the label's URL; the PDF is fetched when Australia Post says it is AVAILABLE.

Returns

the label's URL and its content

RatingAction class

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

POST /shipping/v1/prices/items: every product the account can send the items with, priced.

Australia Post prices each item on its own: a product's rate is the sum over the parcels, and a product that does not carry every parcel is not offered.

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

POST /shipping/v1/shipments, then POST /shipping/v1/labels for its PDF: the label is generated asynchronously, so the result carries the label's link; the content is fetched when Australia Post says it is ready.

ShippingAction::__construct()

public function __construct()

ShippingAction::supports()

public function supports(Request $request): bool

ShippingAction::execute()

public function execute(Request $request): void

ShippingAction::trackingUrl()

public static function trackingUrl(string $number): string

TrackingAction class

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

GET /shipping/v1/track: the article'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