Added PaidMediaInfo Object
This commit is contained in:
parent
cb383d3183
commit
b256812da6
2 changed files with 60 additions and 0 deletions
|
@ -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 `can_connect_to_business` & `has_main_web_app` to User object
|
||||||
* Added LinkPreviewOptions object
|
* Added LinkPreviewOptions object
|
||||||
* Added PaidMedia, PaidMediaPhoto, PaidMediaPreview, PaidMediaVideo & PaidMediaType Enum
|
* Added PaidMedia, PaidMediaPhoto, PaidMediaPreview, PaidMediaVideo & PaidMediaType Enum
|
||||||
|
* Added PaidMediaInfo Object
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
* Refactored the way HTTP requests are handled & methods are called
|
* Refactored the way HTTP requests are handled & methods are called
|
||||||
|
|
59
src/TgBotLib/Objects/Telegram/PaidMediaInfo.php
Normal file
59
src/TgBotLib/Objects/Telegram/PaidMediaInfo.php
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TgBotLib\Objects\Telegram;
|
||||||
|
|
||||||
|
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||||
|
|
||||||
|
class PaidMediaInfo implements ObjectTypeInterface
|
||||||
|
{
|
||||||
|
private int $star_count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var PaidMedia[]
|
||||||
|
*/
|
||||||
|
private array $paid_media;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The number of Telegram Stars that must be paid to buy access to the media
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getStarCount(): int
|
||||||
|
{
|
||||||
|
return $this->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;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue