Esempio n. 1
0
 public static function fromJson($json)
 {
     $r = new Checkout();
     $r->setItems(array_map(function ($json) {
         return CheckoutItem::fromJson($json);
     }, $json->items));
     $r->setTotal(Price::fromJson($json->total));
     return $r;
 }
Esempio n. 2
0
 public static function fromJson($json)
 {
     $r = new CheckoutItem();
     $r->setCount($json->count);
     $r->setName(isset($json->name) ? $json->name : null);
     $r->setSku($json->sku);
     $r->setExternalId(isset($json->external_id) ? $json->external_id : null);
     $r->setPrice(Price::fromJson($json->price));
     $r->setTotal(Price::fromJson($json->total));
     return $r;
 }
Esempio n. 3
0
 public static function fromJson($json)
 {
     if (!isset($json->item) && !isset($json->checkout)) {
         throw new \Exception('both checkout and item are null');
     }
     if (isset($json->item) && isset($json->checkout)) {
         throw new \Exception('both checkout and item are non-null, only expected one of checkout or item');
     }
     $r = new Transaction();
     $r->setId($json->id);
     $r->setExternalId(isset($json->external_id) ? $json->external_id : null);
     $r->setCreated($json->created);
     $r->setState($json->state);
     $r->setRevisionNumber($json->revision_number);
     $r->setProject($json->project);
     $r->setItem(isset($json->item) ? Item::fromJson($json->item) : null);
     $r->setCheckout(isset($json->checkout) ? Checkout::fromJson($json->checkout) : null);
     $r->setCustomer(Customer::fromJson($json->customer));
     $r->setPrice(Price::fromJson($json->price));
     $r->setPaymentMethod($json->payment_method);
     $r->setTest(isset($json->test) ? $json->test : false);
     return $r;
 }