|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Phptg\BotApi\Method; |
| 6 | + |
| 7 | +use Phptg\BotApi\ParseResult\ValueProcessor\ObjectValue; |
| 8 | +use Phptg\BotApi\Transport\HttpMethod; |
| 9 | +use Phptg\BotApi\MethodInterface; |
| 10 | +use Phptg\BotApi\Type\OwnedGifts; |
| 11 | + |
| 12 | +/** |
| 13 | + * @see https://core.telegram.org/bots/api#getchatgifts |
| 14 | + * |
| 15 | + * @template-implements MethodInterface<OwnedGifts> |
| 16 | + * |
| 17 | + * @api |
| 18 | + */ |
| 19 | +final readonly class GetChatGifts implements MethodInterface |
| 20 | +{ |
| 21 | + public function __construct( |
| 22 | + private int|string $chatId, |
| 23 | + private ?bool $excludeUnsaved = null, |
| 24 | + private ?bool $excludeSaved = null, |
| 25 | + private ?bool $excludeUnlimited = null, |
| 26 | + private ?bool $excludeLimitedUpgradable = null, |
| 27 | + private ?bool $excludeLimitedNonUpgradable = null, |
| 28 | + private ?bool $excludeFromBlockchain = null, |
| 29 | + private ?bool $excludeUnique = null, |
| 30 | + private ?bool $sortByPrice = null, |
| 31 | + private ?string $offset = null, |
| 32 | + private ?int $limit = null, |
| 33 | + ) {} |
| 34 | + |
| 35 | + public function getHttpMethod(): HttpMethod |
| 36 | + { |
| 37 | + return HttpMethod::GET; |
| 38 | + } |
| 39 | + |
| 40 | + public function getApiMethod(): string |
| 41 | + { |
| 42 | + return 'getChatGifts'; |
| 43 | + } |
| 44 | + |
| 45 | + public function getData(): array |
| 46 | + { |
| 47 | + return array_filter([ |
| 48 | + 'chat_id' => $this->chatId, |
| 49 | + 'exclude_unsaved' => $this->excludeUnsaved, |
| 50 | + 'exclude_saved' => $this->excludeSaved, |
| 51 | + 'exclude_unlimited' => $this->excludeUnlimited, |
| 52 | + 'exclude_limited_upgradable' => $this->excludeLimitedUpgradable, |
| 53 | + 'exclude_limited_non_upgradable' => $this->excludeLimitedNonUpgradable, |
| 54 | + 'exclude_from_blockchain' => $this->excludeFromBlockchain, |
| 55 | + 'exclude_unique' => $this->excludeUnique, |
| 56 | + 'sort_by_price' => $this->sortByPrice, |
| 57 | + 'offset' => $this->offset, |
| 58 | + 'limit' => $this->limit, |
| 59 | + ], static fn($value) => $value !== null); |
| 60 | + } |
| 61 | + |
| 62 | + public function getResultType(): ObjectValue |
| 63 | + { |
| 64 | + return new ObjectValue(OwnedGifts::class); |
| 65 | + } |
| 66 | +} |
0 commit comments