/**
* purchase a shipment
*
* @param string $shipmentId
* @param string $rateId
* @return null
* @throws \browner12\shipping\ShippingException
*/
public function purchase($shipmentId, $rateId)
{
//try to buy label
try {
//retrieve shipment
$shipment = Shipment::retrieve($shipmentId);
//retrieve rate
$rate = Rate::retrieve($rateId);
//buy
$purchase = $shipment->buy($rate);
} catch (EasypostException $e) {
//throw shipping exception
throw new ShippingException('Unable to purchase label.' . $e->getMessage(), 0, $e);
}
//return
return $purchase;
}