From ce945857526ce04e566be09383ad787919fd02f4 Mon Sep 17 00:00:00 2001 From: Netkas Date: Sun, 23 Apr 2023 14:48:55 -0400 Subject: [PATCH] Added object `\TgBotLib\Objects\Telegram > InputLocationMessageContent` to represent the content of a location message to be sent as the result of an inline query. --- CHANGELOG.md | 1 + .../Telegram/InputLocationMessageContent.php | 139 ++++++++++++++++++ 2 files changed, 140 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/InputLocationMessageContent.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 113a7c3..62d5320 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This update accompanies the release of the [Telegram Bot API 6.7](https://core.t ### Added * Added object `\TgBotLib\Objects\Telegram > InputTextMessageContent` to represent the content of a text message to be sent as the result of an inline query. + * Added object `\TgBotLib\Objects\Telegram > InputLocationMessageContent` to represent the content of a location message to be sent as the result of an inline query. diff --git a/src/TgBotLib/Objects/Telegram/InputLocationMessageContent.php b/src/TgBotLib/Objects/Telegram/InputLocationMessageContent.php new file mode 100644 index 0000000..f3d5776 --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/InputLocationMessageContent.php @@ -0,0 +1,139 @@ +latitude; + } + + /** + * Longitude of the location in degrees + * + * @return float + */ + public function getLongitude(): float + { + return $this->longitude; + } + + /** + * Optional. The radius of uncertainty for the location, measured in meters; 0-1500 + * + * @return float|null + */ + public function getHorizontalAccuracy(): ?float + { + return $this->horizontal_accuracy; + } + + /** + * Optional. Period in seconds for which the location can be updated, should be between 60 and 86400. + * + * @return int|null + */ + public function getLivePeriod(): ?int + { + return $this->live_period; + } + + /** + * Optional. For live locations, a direction in which the user is moving, in degrees. + * Must be between 1 and 360 if specified. + * + * @return int|null + */ + public function getHeading(): ?int + { + return $this->heading; + } + + /** + * Optional. For live locations, a maximum distance for proximity alerts about approaching another chat member, + * in meters. Must be between 1 and 100000 if specified. + * + * @return int|null + */ + public function getProximityAlertRadius(): ?int + { + return $this->proximity_alert_radius; + } + + /** + * Returns an array representation of the object + * + * @return array + */ + public function toArray(): array + { + return [ + 'latitude' => $this->latitude, + 'longitude' => $this->longitude, + 'horizontal_accuracy' => $this->horizontal_accuracy, + 'live_period' => $this->live_period, + 'heading' => $this->heading, + 'proximity_alert_radius' => $this->proximity_alert_radius, + ]; + } + + /** + * Constructs object from an array representation + * + * @param array $data + * @return ObjectTypeInterface + */ + public static function fromArray(array $data): ObjectTypeInterface + { + $object = new self(); + + $object->latitude = (float)$data['latitude'] ?? null; + $object->longitude = (float)$data['longitude'] ?? null; + $object->horizontal_accuracy = (float)$data['horizontal_accuracy'] ?? null; + $object->live_period = (int)$data['live_period'] ?? null; + $object->heading = (int)$data['heading'] ?? null; + $object->proximity_alert_radius = (int)$data['proximity_alert_radius'] ?? null; + + return $object; + } + } \ No newline at end of file