EasyPost\Order::create PHP Метод

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

create an order
public static create ( mixed $params = null, string $apiKey = null ) : mixed
$params mixed
$apiKey string
Результат mixed
    public static function create($params = null, $apiKey = null)
    {
        if (!isset($params['order']) || !is_array($params['order'])) {
            $clone = $params;
            unset($params);
            $params['order'] = $clone;
        }
        return self::_create(get_class(), $params, $apiKey);
    }

Usage Example

Пример #1
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
\EasyPost\EasyPost::setApiBase('http://*****:*****@example.com");
$order = \EasyPost\Order::create(array("from_address" => $sf, "to_address" => $maryland, "shipments" => array(array("parcel" => array("length" => 12.0, "width" => 10.5, "height" => 6.8, "weight" => 12), "options" => array("cod_amount" => 14.99)), array("parcel" => array("length" => 11.9, "width" => 10.0, "height" => 7.3, "weight" => 18), "options" => array("cod_amount" => 9.56)))));
$order->buy(array("carrier" => "UPS", "service" => "Ground"));
print_r($order);