Updated ShippingQuery
This commit is contained in:
parent
20cd2aeacf
commit
ac8b629dc5
1 changed files with 16 additions and 32 deletions
|
@ -8,25 +8,10 @@
|
||||||
|
|
||||||
class ShippingQuery implements ObjectTypeInterface
|
class ShippingQuery implements ObjectTypeInterface
|
||||||
{
|
{
|
||||||
/**
|
private string $id;
|
||||||
* @var string
|
private User $from;
|
||||||
*/
|
private string $invoice_payload;
|
||||||
private $id;
|
private ShippingAddress $shipping_address;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var User
|
|
||||||
*/
|
|
||||||
private $from;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $invoice_payload;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ShippingAddress
|
|
||||||
*/
|
|
||||||
private $shipping_address;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique query identifier
|
* Unique query identifier
|
||||||
|
@ -69,34 +54,33 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an array representation of the object
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function toArray(): array
|
public function toArray(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'from' => ($this->from instanceof User) ? $this->from->toArray() : $this->from,
|
'from' => $this->from?->toArray(),
|
||||||
'invoice_payload' => $this->invoice_payload,
|
'invoice_payload' => $this->invoice_payload,
|
||||||
'shipping_address' => ($this->shipping_address instanceof ShippingAddress) ? $this->shipping_address->toArray() : $this->shipping_address,
|
'shipping_address' => $this->shipping_address?->toArray()
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs object from an array representation
|
* @inheritDoc
|
||||||
*
|
|
||||||
* @param array $data
|
|
||||||
* @return ShippingQuery
|
|
||||||
*/
|
*/
|
||||||
public static function fromArray(array $data): self
|
public static function fromArray(?array $data): ?ShippingQuery
|
||||||
{
|
{
|
||||||
$object = new self();
|
if($data === null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$object = new self();
|
||||||
$object->id = $data['id'] ?? null;
|
$object->id = $data['id'] ?? null;
|
||||||
$object->from = isset($data['from']) && is_array($data['from']) ? User::fromArray($data['from']) : $data['from'];
|
$object->from = isset($data['from']) ? User::fromArray($data['from']) : null;
|
||||||
$object->invoice_payload = $data['invoice_payload'] ?? null;
|
$object->invoice_payload = $data['invoice_payload'] ?? null;
|
||||||
$object->shipping_address = isset($data['shipping_address']) && is_array($data['shipping_address']) ? ShippingAddress::fromArray($data['shipping_address']) : $data['shipping_address'];
|
$object->shipping_address = isset($data['shipping_address']) ? ShippingAddress::fromArray($data['shipping_address']) : null;
|
||||||
|
|
||||||
return $object;
|
return $object;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue