Lue dans les fichiers PHP du paquet au commit 0ef29af09877 : 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é.
ApiclassCanpar's CanShip web services (SOAP 1.1): every request carries the account's user id and password inside its body; rating, shipping and tracking are three endpoints.
3 methods · 3 properties · 5 constants
CanparGatewayFactoryclassoptions: user_id: '%env(CANPAR_USER)%' # the CanShip web services login password: '%env(CANPAR_PASSWORD)%' shipper_number: '%env(CANPAR_SHIPPER)%' # the account number sandbox: true rates: [...] # optional: configured prices instead of rateShipment
10 options
MappingclassCanpar's XML for ours. Services: 1 Ground, 2 Select, 3 Overnight, 4 USA, 5 Select USA, 6 International.
4 methods · 1 constant
CancelActionclassvoidShipment: Canpar takes the shipment id, which the label's tracking number maps back to through the option kept at shipping (shipment id = the barcode's shipment).
3 methods
GetSlipActionclassThe label of a shipment processed earlier: trackByBarcode gives the barcode's shipment id (as cancel() finds it), getLabels its label (PDF; thermal ZPL when asked for).
4 methods
RatingActionclassrateShipment, once per service (option services: the service types to price; by default Ground, Select and Overnight, or International).
3 methods
ShippingActionclassprocessShipment, then getLabels for its label (PDF; thermal ZPL with option label_format).
4 methods
TrackingActionclasstrackByBarcode: the events, oldest first.
3 methods
Omnibus\Canpar
Api class
final class Api Api.php:15
Canpar's CanShip web services (SOAP 1.1): every request carries the account's user id and password inside its body; rating, shipping and tracking are three endpoints.
const LIVE = 'https://canship.canpar.com/canshipws/services'const TEST = 'https://sandbox.canpar.com/canshipws/services'const RATING = 'CanparRatingService'const SHIPPING = 'CanparAddonsService'const TRACKING = 'CanparTrackingService'public readonly string $userIdpublic readonly string $shipperNumberpublic readonly bool $sandbox
Api::__construct()
public function __construct(readonly HttpClientInterface $http, public readonly string $userId, readonly string $password, public readonly string $shipperNumber, public readonly bool $sandbox = false, readonly int $timeout = 20)Api::call()
public function call(string $service, string $operation, string $request): \SimpleXMLElementOne SOAP call: the operation, the <request> element's inner XML; back as the result element without namespaces.
Api::e()
public static function e(string $s): stringCanparGatewayFactory class
final class CanparGatewayFactory extends GatewayFactory CanparGatewayFactory.php:24
options: user_id: '%env(CANPAR_USER)%' # the CanShip web services login password: '%env(CANPAR_PASSWORD)%' shipper_number: '%env(CANPAR_SHIPPER)%' # the account number sandbox: true rates: [...] # optional: configured prices instead of rateShipment
No pickup points: Canpar delivers to the door.
Options
| Option | Default | |
|---|---|---|
sandbox | false | |
omnibus.api | function (Config $c) {
$http = $this->http ?? HttpClient::create();
return new Api($http, (string) $c['user_id'], (string) $c['password'], (string) $… | |
omnibus.action.rating | static fn(Config $c) => $c->get('rates') ? null : new RatingAction() | |
omnibus.action.shipping | new ShippingAction() | |
omnibus.action.tracking | new TrackingAction() | |
omnibus.action.cancel | new CancelAction() | |
omnibus.action.get_slip | new GetSlipAction() | |
user_id | required | |
password | required | |
shipper_number | required |
Mapping class
final class Mapping Mapping.php:11
Canpar's XML for ours. Services: 1 Ground, 2 Select, 3 Overnight, 4 USA, 5 Select USA, 6 International.
const SERVICES = ['1' => 'Canpar Ground', '2' => 'Select', '3' => 'Overnight', '4' => 'USA', '5' => 'Select USA', '6' => 'International', '7' => 'Select Letter', '8' => 'Over…
Mapping::address()
public static function address(string $tag, Address $a, ?string $province): stringMapping::package()
public static function package(Parcel $p): stringMapping::shipment()
public static function shipment(Shipment $s, string $shipperNumber): stringMapping::status()
public static function status(?string $code, ?string $description = null): TrackingStatusOmnibus\Canpar\Action
CancelAction class
final class CancelAction implements ActionInterface, ApiAwareInterface CancelAction.php:13
voidShipment: Canpar takes the shipment id, which the label's tracking number maps back to through the option kept at shipping (shipment id = the barcode's shipment).
CancelAction::__construct()
public function __construct()CancelAction::supports()
public function supports(Request $request): boolCancelAction::execute()
public function execute(Request $request): voidGetSlipAction class
final class GetSlipAction implements ActionInterface, ApiAwareInterface GetSlipAction.php:18
The label of a shipment processed earlier: trackByBarcode gives the barcode's shipment id (as cancel() finds it), getLabels its label (PDF; thermal ZPL when asked for).
GetSlipAction::__construct()
public function __construct()GetSlipAction::supports()
public function supports(Request $request): boolGetSlipAction::execute()
public function execute(Request $request): voidGetSlipAction::fetch()
public static function fetch(Api $api, string $id, bool $thermal): ?stringgetLabels for a shipment id: its first label, base64-decoded, or null when Canpar sends none.
RatingAction class
final class RatingAction implements ActionInterface, ApiAwareInterface RatingAction.php:15
rateShipment, once per service (option services: the service types to price; by default Ground, Select and Overnight, or International).
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
processShipment, then getLabels for its label (PDF; thermal ZPL with option label_format).
ShippingAction::__construct()
public function __construct()ShippingAction::supports()
public function supports(Request $request): boolShippingAction::execute()
public function execute(Request $request): voidShippingAction::trackingUrl()
public static function trackingUrl(string $number): stringTrackingAction class
final class TrackingAction implements ActionInterface, ApiAwareInterface TrackingAction.php:17
trackByBarcode: the events, oldest first.
TrackingAction::__construct()
public function __construct()TrackingAction::supports()
public function supports(Request $request): boolTrackingAction::execute()
public function execute(Request $request): void