public function __construct($data = [], $connection = null) { $this->connection = $connection; foreach (['id', 'order_reference', 'shop_system', 'customer_number', 'service_point_reference', 'weight_in_g'] as $prop) { if (isset($data[$prop])) { $this->{$prop} = $data[$prop]; } } foreach (['recipient', 'billing_contact'] as $prop) { $this->{$prop} = isset($data[$prop]) ? new Address($data[$prop]) : null; } foreach (['subtotal', 'shipping_cost', 'tax_value'] as $prop) { $this->{$prop} = isset($data[$prop]) ? Money::import($data[$prop]) : null; } $this->product = isset($data['product']) ? new Product($data['product'], $this->connection) : null; if (isset($data['items'])) { $this->items = []; foreach ($data['items'] as $item_data) { $this->items[] = new Item($item_data); } } if (isset($data['shipments'])) { $this->shipments = []; foreach ($data['shipments'] as $url) { $this->shipments[] = Shipment::import($url, $this->connection); } } }
public function __construct($data = []) { foreach (['id', 'description', 'sku', 'weight_in_g', 'quantity'] as $prop) { if (isset($data[$prop])) { $this->{$prop} = $data[$prop]; } } $this->value = isset($data['value']) ? Money::import($data['value']) : null; }
public function __construct($data = [], $connection = null) { $this->connection = $connection; foreach (['code', 'name'] as $prop) { if (isset($data[$prop])) { $this->{$prop} = $data[$prop]; } } if (isset($data['carrier'])) { $this->carrier = new Carrier($data['carrier']); } if (isset($data['price'])) { $this->price = Money::import($data['price']); } if (isset($data['cost_price'])) { $this->cost_price = Money::import($data['cost_price']); } if (isset($data['service_points'])) { $this->service_points = []; foreach ($data['service_points'] as $service_point_data) { $this->service_points[] = new ServicePoint($service_point_data); } } }