src/Returns.php
public function createOpenReturn(
        array $receiver,
        array $parcel,
        array $options = []
    ) {

        $this->formatPostalCode($receiver['domestic-address']['postal-code']);
        $content = [
            'max-number-of-artifacts' => 10,
            'service-code' => $parcel['service_code'],
            'receiver' => $receiver,
            'settlement-info' => [
                'contract-id' => $this->contractId,
            ],
        ];

        if (!empty($options['option_codes'])) {
            $return_info['options']['option'] = $this->parseOptionCodes($options);
        }

        $xml = Array2XML::createXML('open-return', $content);
        $envelope = $xml->documentElement;
        $envelope->setAttribute('xmlns',
            'http://www.canadapost.ca/ws/openreturn-v2');
        $payload = $xml->saveXML();

        $response = $this->post(
            "rs/{$this->customerNumber}/{$this->customerNumber}/openreturn",
            [
                'Accept' => 'application/vnd.cpc.openreturn-v2+xml',
                'Content-Type' => 'application/vnd.cpc.openreturn-v2+xml',
            ],
            $payload,
            $options
        );
        return $response;
    }
public function createOpenReturn(
        array $receiver,
        array $parcel,
        array $options = []
    ) {

        $this->formatPostalCode($receiver['domestic-address']['postal-code']);
        $content = [
            'max-number-of-artifacts' => 10,
            'service-code' => $parcel['service_code'],
            'receiver' => $receiver,
            'settlement-info' => [
                'contract-id' => $this->contractId,
            ],
        ];

        if (!empty($options['option_codes'])) {
            $return_info['options']['option'] = $this->parseOptionCodes($options);
        }

        $xml = Array2XML::createXML('open-return', $content);
        $envelope = $xml->documentElement;
        $envelope->setAttribute('xmlns',
            'http://www.canadapost.ca/ws/openreturn-v2');
        $payload = $xml->saveXML();

        $response = $this->post(
            "rs/{$this->customerNumber}/{$this->customerNumber}/openreturn",
            [
                'Accept' => 'application/vnd.cpc.openreturn-v2+xml',
                'Content-Type' => 'application/vnd.cpc.openreturn-v2+xml',
            ],
            $payload,
            $options
        );
        return $response;
    }
public function createOpenReturn ( array $ receiver , array $ parcel , array $ options = [ ] ) { $ this -> formatPostalCode ( $ receiver [ 'domestic-address' ] [ 'postal-code' ] ) ; $ content = [ 'max-number-of-artifacts' => 10 , 'service-code' => $ parcel [ 'service_code' ] , 'receiver' => $ receiver , 'settlement-info' => [ 'contract-id' => $ this -> contractId , ] , ] ; if ( ! empty ( $ options [ 'option_codes' ] ) ) { $ return_info [ 'options' ] [ 'option' ] = $ this -> parseOptionCodes ( $ options ) ; } $ xml = Array2XML :: createXML ( 'open-return' , $ content ) ; $ envelope = $ xml -> documentElement ; $ envelope -> setAttribute ( 'xmlns' , 'http://www.canadapost.ca/ws/openreturn-v2' ) ; $ payload = $ xml -> saveXML ( ) ; $ response = $ this -> post ( "rs/{$this->customerNumber}/{$this->customerNumber}/openreturn" , [ 'Accept' => 'application/vnd.cpc.openreturn-v2+xml' , 'Content-Type' => 'application/vnd.cpc.openreturn-v2+xml' , ] , $ payload , $ options ) ; return $ response ; }
Create an open return.

@param array $receiver
The receiver info.
<code>
$receiver = [
'name'            => 'John Smith',
'company' => 'Acro Media',
'domestic-address' => [
'address-line-1'  => '123 Main St',
'city'            => 'Kelowna',
'province'      => 'BC',
'postal-code' => 'V1X 1M2',
],
]
</code>
@param array $parcel
The parcel characteristics.
<code>
$parcel = [
'weight'     => 0.500,   // in kg.
'dimensions' => [        // in cm.
'length' => 30,
'width'  => 10,
'height' => 20,
],
],
]
</code>
@param array $options
The options array.

@return \DOMDocument
@throws \GuzzleHttp\Exception\GuzzleException
Create an open return .