EasyPost\Shipment::create_from_tracking_code PHP Метод

create_from_tracking_code() публичный статический Метод

create a shipment from tracking code
public static create_from_tracking_code ( mixed $params = null, string $apiKey = null ) : mixed
$params mixed
$apiKey string
Результат mixed
    public static function create_from_tracking_code($params = null, $apiKey = null)
    {
        $class = get_class();
        if (!isset($params['tracking_code'])) {
            $clone = $params;
            unset($params);
            $params['tracking_code'] = $clone;
        }
        $requestor = new Requestor($apiKey);
        $url = self::classUrl($class) . '/create_from_tracking_code';
        list($response, $apiKey) = $requestor->request('post', $url, $params);
        return Util::convertToEasyPostObject($response, $apiKey);
    }

Usage Example

<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$shipment = \EasyPost\Shipment::create_from_tracking_code(array("tracking_code" => "1Z0X89330378901784", "options" => array("residential_to_address" => 1)));
print_r($shipment->rates);