Skip to content

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

Read from the package's own PHP files at the commit 0ef29af09877: 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\Canpar

  • Api class

    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.

    3 methods · 3 properties · 5 constants

  • CanparGatewayFactory class

    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

    10 options

  • Mapping class

    Canpar's XML for ours. Services: 1 Ground, 2 Select, 3 Overnight, 4 USA, 5 Select USA, 6 International.

    4 methods · 1 constant

Omnibus\Canpar\Action

  • CancelAction class

    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).

    3 methods

  • GetSlipAction class

    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).

    4 methods

  • RatingAction class

    rateShipment, once per service (option services: the service types to price; by default Ground, Select and Overnight, or International).

    3 methods

  • ShippingAction class

    processShipment, then getLabels for its label (PDF; thermal ZPL with option label_format).

    4 methods

  • TrackingAction class

    trackByBarcode: 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 $userId
public readonly string $shipperNumber
public 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): \SimpleXMLElement

One 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): string

CanparGatewayFactory 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

OptionDefault
sandboxfalse
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['user_id'], (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()
user_idrequired
passwordrequired
shipper_numberrequired

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): string

Mapping::package()

public static function package(Parcel $p): string

Mapping::shipment()

public static function shipment(Shipment $s, string $shipperNumber): string

Mapping::status()

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

Omnibus\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): bool

CancelAction::execute()

public function execute(Request $request): void

GetSlipAction 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): bool

GetSlipAction::execute()

public function execute(Request $request): void

GetSlipAction::fetch()

public static function fetch(Api $api, string $id, bool $thermal): ?string

getLabels 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): bool

RatingAction::execute()

public function execute(Request $request): void

ShippingAction 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): 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:17

trackByBarcode: the events, oldest first.

TrackingAction::__construct()

public function __construct()

TrackingAction::supports()

public function supports(Request $request): bool

TrackingAction::execute()

public function execute(Request $request): void