src/NCShipment.php
public function getNCShipments(
        $from = '',
        $to = '',
        $tracking_pin = '',
        array $options = []
    ) {
        if (!isset($from) && !isset($tracking_pin)) {
            $message = 'You must include either a $from date or a $tracking_pin.';
            throw new \InvalidArgumentException($message);
        }
        if (empty($to)) {
            $to = date('YmdHs');
        }
        $this->verifyDates($from, $to);
        $query_params = "from={$from}&to{$to}";

        if (!empty($tracking_pin)) {
            $query_params = "trackingPIN={$tracking_pin}";
        }

        $endpoint = sprintf(
            'rs/%s/ncshipment?%s',
            $this->config['customer_number'],
            $query_params
        );
        $response = $this->get(
            $endpoint,
            ['Accept' => 'application/vnd.cpc.ncshipment-v4+xml'],
            $options
        );
        return $response;
    }
public function getNCShipments(
        $from = '',
        $to = '',
        $tracking_pin = '',
        array $options = []
    ) {
        if (!isset($from) && !isset($tracking_pin)) {
            $message = 'You must include either a $from date or a $tracking_pin.';
            throw new \InvalidArgumentException($message);
        }
        if (empty($to)) {
            $to = date('YmdHs');
        }
        $this->verifyDates($from, $to);
        $query_params = "from={$from}&to{$to}";

        if (!empty($tracking_pin)) {
            $query_params = "trackingPIN={$tracking_pin}";
        }

        $endpoint = sprintf(
            'rs/%s/ncshipment?%s',
            $this->config['customer_number'],
            $query_params
        );
        $response = $this->get(
            $endpoint,
            ['Accept' => 'application/vnd.cpc.ncshipment-v4+xml'],
            $options
        );
        return $response;
    }
public function getNCShipments ( $ from = '' , $ to = '' , $ tracking_pin = '' , array $ options = [ ] ) { if ( ! isset ( $ from ) && ! isset ( $ tracking_pin ) ) { $ message = 'You must include either a $from date or a $tracking_pin.' ; throw new \ InvalidArgumentException ( $ message ) ; } if ( empty ( $ to ) ) { $ to = date ( 'YmdHs' ) ; } $ this -> verifyDates ( $ from , $ to ) ; $ query_params = "from={$from}&to{$to}" ; if ( ! empty ( $ tracking_pin ) ) { $ query_params = "trackingPIN={$tracking_pin}" ; } $ endpoint = sprintf ( 'rs/%s/ncshipment?%s' , $ this -> config [ 'customer_number' ] , $ query_params ) ; $ response = $ this -> get ( $ endpoint , [ 'Accept' => 'application/vnd.cpc.ncshipment-v4+xml' ] , $ options ) ; return $ response ; }
Get NCShipments from Canada Post within the specified range.

If you supply a tracking PIN, the from/to dates will be ignored.

@param string $from
The beginning range. YmdHs format, eg. 201808282359.
@param string $to
The end range, defaults to current time. YmdHs format, eg. 201808282359.
@param string $tracking_pin
The Tracking PIN of the shipment to retrieve.
@param array $options
The options array.

@see https://www.canadapost.ca/cpo/mc/business/productsservices/developers/services/onestepshipping/onestepshipments.jsf
@return \DOMDocument|\Psr\Http\Message\StreamInterface
@throws \GuzzleHttp\Exception\GuzzleException
Get NCShipments from Canada Post within the specified range .