diff --git a/src/TgBotLib/Objects/OrderInfo.php b/src/TgBotLib/Objects/OrderInfo.php new file mode 100644 index 0000000..ffa718c --- /dev/null +++ b/src/TgBotLib/Objects/OrderInfo.php @@ -0,0 +1,103 @@ +name; + } + + /** + * Optional. User's phone number + * + * @return string|null + */ + public function getPhoneNumber(): ?string + { + return $this->phone_number; + } + + /** + * Optional. User email + * + * @return string|null + */ + public function getEmail(): ?string + { + return $this->email; + } + + /** + * Optional. User shipping address + * + * @return ShippingAddress|null + */ + public function getShippingAddress(): ?ShippingAddress + { + return $this->shipping_address; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'name' => $this->name, + 'phone_number' => $this->phone_number, + 'email' => $this->email, + 'shipping_address' => ($this->shipping_address instanceof ShippingAddress) ? $this->shipping_address->toArray() : null, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->name = $data['name'] ?? null; + $object->phone_number = $data['phone_number'] ?? null; + $object->email = $data['email'] ?? null; + $object->shipping_address = ($data['shipping_address'] ?? null) instanceof ShippingAddress ? $data['shipping_address'] : ShippingAddress::fromArray($data['shipping_address'] ?? []); + + return $object; + } + } \ No newline at end of file