public function buy($params = null)
{
$requestor = new Requestor($this->_apiKey);
$url = $this->instanceUrl() . '/buy';
if (isset($params['id']) && (!isset($params['rate']) || !is_array($params['rate']))) {
$clone = $params;
unset($params);
$params['rate'] = $clone;
}
list($response, $apiKey) = $requestor->request('post', $url, $params);
$this->refreshFrom($response, $apiKey, true);
return $this;
}
/** * @param string $shipmentExternalId * @param string $rateExternalId * @return ShipmentTracker */ public function buy($shipmentExternalId, $rateExternalId) { $shipment = new EasyPost\Shipment($shipmentExternalId); $shipment->buy(['rate' => ['id' => $rateExternalId]]); return $this->getShipmentTrackerFromEasyPostShipment($shipment); }