function testAllWithLimit()
 {
     $result = Postmaster_Shipment::all(array("limit" => 3));
     $this->assertTrue(is_array($result));
     $this->assertEquals(3, count($result));
     $this->assertTrue($result[0] instanceof Postmaster_Shipment);
 }
 public static function retrieve($id)
 {
     $instance = new Postmaster_Shipment($id);
     $instance->refresh();
     return $instance;
 }
$result = Postmaster_Shipment::create(array("to" => array("company" => "Postmaster Inc.", "contact" => "Joe Smith", "line1" => "701 Brazos St. Suite 1616", "city" => "Austin", "state" => "TX", "zip_code" => "78701", "phone_no" => "512-693-4040"), "from" => array("company" => "Postmaster Inc.", "contact" => "Joe Smith", "line1" => "701 Brazos St. Suite 1616", "city" => "Austin", "state" => "TX", "zip_code" => "78701", "phone_no" => "512-693-4040"), "carrier" => "fedex", "service" => "2DAY", "package" => array("weight" => 1.5, "length" => 10, "width" => 6, "height" => 8)));
//var_dump($result);
/* store in your DB shipment ID for later use */
$shipment_id = $result->id;
/* anytime you can extract shipment data */
$sm = Postmaster_Shipment::retrieve($shipment_id);
//var_dump($sm);
/* or check delivery status */
$result = $sm->track();
//var_dump($result);
/* you can cancel shipment, but only before being picked up by the carrier */
$result = $sm->void();
//var_dump($result);
/* list all shipments */
$result = Postmaster_Shipment::all();
//var_dump($result);
/* list 3 newest shipments */
$result = Postmaster_Shipment::all(array("limit" => 3));
//var_dump($result);
/* monitor external package */
$result = Postmaster_Tracking::monitor_external(array("tracking_no" => "1ZW470V80310800043", "url" => "http://example.com/your-http-post-listener", "events" => ["Delivered", "Exception"]));
//var_dump($result);
/* create box example */
$result = Postmaster_Package::create(array("width" => 10, "height" => 12, "length" => 8, "name" => 'My Box'));
var_dump($result);
/* list boxes example */
$result = Postmaster_Package::all(array("limit" => 2));
var_dump($result);
/* fit items in box example */
$result = Postmaster_Package::fit(array("items" => array(array("width" => 2.2, "length" => 3, "height" => 1, "count" => 2)), "packages" => array(array("width" => 6, "length" => 6, "height" => 6, "sku" => "123ABC"), array("width" => 12, "length" => 12, "height" => 12, "sku" => "456XYZ"))));
var_dump($result);