From b256812da6754e3dcce2adff43c03ca298bc2dbe Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 30 Sep 2024 14:03:29 -0400 Subject: [PATCH] Added PaidMediaInfo Object --- CHANGELOG.md | 1 + .../Objects/Telegram/PaidMediaInfo.php | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/TgBotLib/Objects/Telegram/PaidMediaInfo.php diff --git a/CHANGELOG.md b/CHANGELOG.md index e2229bd..967b0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Added `can_connect_to_business` & `has_main_web_app` to User object * Added LinkPreviewOptions object * Added PaidMedia, PaidMediaPhoto, PaidMediaPreview, PaidMediaVideo & PaidMediaType Enum + * Added PaidMediaInfo Object ### Changed * Refactored the way HTTP requests are handled & methods are called diff --git a/src/TgBotLib/Objects/Telegram/PaidMediaInfo.php b/src/TgBotLib/Objects/Telegram/PaidMediaInfo.php new file mode 100644 index 0000000..0fd02bd --- /dev/null +++ b/src/TgBotLib/Objects/Telegram/PaidMediaInfo.php @@ -0,0 +1,59 @@ +star_count; + } + + /** + * Information about the paid media + * + * @return PaidMedia[] + */ + public function getPaidMedia(): array + { + return $this->paid_media; + } + + /** + * @inheritDoc + */ + public function toArray(): array + { + return [ + 'star_count' => $this->star_count, + 'paid_media' => array_map(fn(PaidMedia $paid_media) => $paid_media->toArray(), $this->paid_media), + ]; + } + + /** + * @inheritDoc + */ + public static function fromArray(array $data): PaidMediaInfo + { + $object = new self(); + + $object->star_count = $data['star_count']; + $object->paid_media = array_map(fn(array $paid_media) => PaidMedia::fromArray($paid_media), $data['paid_media']); + + return $object; + } +} \ No newline at end of file