Lue dans les fichiers PHP du paquet au commit 4c3a6421dad4 : 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é.
ApiclassThe USPS APIs v3 (apis.usps.com) on an OAuth2 client-credentials token.
4 methods · 4 properties · 2 constants
MappingclassUSPS's shapes for ours: pounds and inches, two-letter states, ZIP codes.
4 methods · 1 constant
UspsGatewayFactoryclassoptions: client_id: '%env(USPS_CLIENT_ID)%' # an app in the USPS Developer Portal client_secret: '%env(USPS_CLIENT_SECRET)%' sandbox: true # apis-tem.usps.com crid: '%env(USPS_CRID)%' # for labels: the payer's Customer Registration ID, mid: '%env(USPS_MID)%' # Mailer ID and account: '%env(USPS_EPS_ACCOUNT)%' # Enterprise Payment System account rates: [...] # optional: configured prices instead of the Prices API
11 options
PickupActionclassThe Locations API: post offices and drop-off points near an address.
3 methods
RatingActionclassThe Prices API: the base rate of each mail class for the parcel, from ZIP to ZIP (domestic) or to a country (international), one call a class.
3 methods
ShippingActionclassThe Labels API: a domestic label (international labels need customs forms: not offered here), paid through the payment authorization.
3 methods
TrackingActionclassThe Tracking API: the package's events, oldest first.
3 methods
Omnibus\Usps
Api class
final class Api Api.php:15
The USPS APIs v3 (apis.usps.com) on an OAuth2 client-credentials token.
Labels are paid for through a payment authorization token, asked once per session from the Payments API with the CRID, MID and EPS account.
const LIVE = 'https://apis.usps.com'const TEST = 'https://apis-tem.usps.com'public readonly bool $sandboxpublic readonly ?string $cridpublic readonly ?string $midpublic readonly ?string $account
Api::__construct()
public function __construct(readonly HttpClientInterface $http, readonly string $clientId, readonly string $clientSecret, public readonly bool $sandbox = false, public readonly ?string $crid = null, public readonly ?string $mid = null, public readonly ?string $account = null, readonly int $timeout = 20)Api::base()
public function base(): stringApi::call()
public function call(string $method, string $path, ?array $body = null, array $query = [], array $headers = []): arrayApi::paymentToken()
public function paymentToken(): stringThe X-Payment-Authorization-Token a label needs: who pays (option crid, mid, account).
Mapping class
final class Mapping Mapping.php:9
USPS's shapes for ours: pounds and inches, two-letter states, ZIP codes.
const CLASSES = ['USPS_GROUND_ADVANTAGE' => 'USPS Ground Advantage', 'PRIORITY_MAIL' => 'Priority Mail', 'PRIORITY_MAIL_EXPRESS' => 'Priority Mail Express', 'FIRST-CLASS_PAC…
Mapping::pounds()
public static function pounds(int $grams): floatMapping::inches()
public static function inches(?int $cm): ?floatMapping::address()
public static function address(Address $a, array $extra = []): arrayMapping::status()
public static function status(?string $category, ?string $eventType = null): TrackingStatusUspsGatewayFactory class
final class UspsGatewayFactory extends GatewayFactory UspsGatewayFactory.php:23
options: client_id: '%env(USPS_CLIENT_ID)%' # an app in the USPS Developer Portal client_secret: '%env(USPS_CLIENT_SECRET)%' sandbox: true # apis-tem.usps.com crid: '%env(USPS_CRID)%' # for labels: the payer's Customer Registration ID, mid: '%env(USPS_MID)%' # Mailer ID and account: '%env(USPS_EPS_ACCOUNT)%' # Enterprise Payment System account rates: [...] # optional: configured prices instead of the Prices API
Options
| Option | Default | |
|---|---|---|
sandbox | false | |
crid | null | |
mid | null | |
account | null | |
omnibus.api | function (Config $c) {
$http = $this->http ?? HttpClient::create();
return new Api($http, (string) $c['client_id'], (string) $c['client_secret'], (bo… | |
omnibus.action.rating | static fn(Config $c) => $c->get('rates') ? null : new RatingAction() | |
omnibus.action.shipping | static fn(Config $c) => $c['crid'] && $c['mid'] && $c['account'] ? new ShippingAction() : null | |
omnibus.action.tracking | new TrackingAction() | a label needs its payer |
omnibus.action.pickup | new PickupAction() | |
client_id | required | |
client_secret | required |
Omnibus\Usps\Action
PickupAction class
final class PickupAction implements ActionInterface, ApiAwareInterface PickupAction.php:15
The Locations API: post offices and drop-off points near an address.
PickupAction::__construct()
public function __construct()PickupAction::supports()
public function supports(Request $request): boolPickupAction::execute()
public function execute(Request $request): voidRatingAction class
final class RatingAction implements ActionInterface, ApiAwareInterface RatingAction.php:18
The Prices API: the base rate of each mail class for the parcel, from ZIP to ZIP (domestic) or to a country (international), one call a class.
RatingAction::__construct()
public function __construct()RatingAction::supports()
public function supports(Request $request): boolRatingAction::execute()
public function execute(Request $request): voidShippingAction class
final class ShippingAction implements ActionInterface, ApiAwareInterface ShippingAction.php:16
The Labels API: a domestic label (international labels need customs forms: not offered here), paid through the payment authorization.
ShippingAction::__construct()
public function __construct()ShippingAction::supports()
public function supports(Request $request): boolShippingAction::execute()
public function execute(Request $request): voidTrackingAction class
final class TrackingAction implements ActionInterface, ApiAwareInterface TrackingAction.php:16
The Tracking API: the package's events, oldest first.
TrackingAction::__construct()
public function __construct()TrackingAction::supports()
public function supports(Request $request): boolTrackingAction::execute()
public function execute(Request $request): void