EasyPost\Rate::retrieve PHP Method

retrieve() public static method

retrieve a rate
public static retrieve ( string $id, string $apiKey = null ) : mixed
$id string
$apiKey string
return mixed
    public static function retrieve($id, $apiKey = null)
    {
        return self::_retrieve(get_class(), $id, $apiKey);
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of EasyPost\Rate::retrieve