retrieve() public static method

retrieve a tracker
public static retrieve ( string $id, string $apiKey = null ) : mixed
$id string
$apiKey string
return mixed
 public function trackPackage($id)
 {
     $track = ShippingLabel::where('cart_id', $id)->first();
     $check = \EasyPost\Tracker::retrieve($track->easypost_tracking);
     if ($check->status == 'delivered') {
         Shipping::where('cart_id', $id)->update(['shipped_status' => 'DELIVERED', 'tracking_number' => $check->updated_at]);
         return redirect()->route('salesmanager.index');
     }
     Shipping::where('cart_id', $id)->update(['shipped_status' => 'SHIPPED', 'tracking_number' => $check->tracking_code]);
     return view('shipping.status', compact('check'));
 }
Beispiel #2
0
<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$tracking_code = "EZ2000000002";
$carrier = "USPS";
$tracker = \EasyPost\Tracker::create(array('tracking_code' => $tracking_code, 'carrier' => $carrier));
print_r($tracker);
$tracker2 = \EasyPost\Tracker::retrieve($tracker->id);
print_r($tracker2);
 /**
  * track a shipment
  *
  * @param string $trackingId
  * @return \EasyPost\Tracker
  * @throws \browner12\shipping\ShippingException
  */
 public function track($trackingId)
 {
     //try
     try {
         //retrieve tracker
         return $tracker = Tracker::retrieve($trackingId);
     } catch (EasyPostException $e) {
         //throw shipping exception
         throw new ShippingException('Unable to track shipment.', 0, $e);
     }
 }