diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d60e0..7ba2b2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Telegram Bot API for PHP Change Log +## 0.2.1 under development + +- New #91: Add `TransactionPartnerTelegramAds` type. + ## 0.2.0 June 29, 2024 - New #16: Add `sendContact` method. diff --git a/src/Method/SendDocument.php b/src/Method/SendDocument.php index 2f97006..f188e4c 100644 --- a/src/Method/SendDocument.php +++ b/src/Method/SendDocument.php @@ -18,7 +18,7 @@ /** * @see https://core.telegram.org/bots/api#senddocument */ -final readonly class SendDocument implements TelegramRequestWithResultPreparingInterface +final readonly class SendDocument implements TelegramRequestWithResultPreparingInterface { /** * @param MessageEntity[]|null $captionEntities diff --git a/src/Type/Payment/TransactionPartnerFactory.php b/src/Type/Payment/TransactionPartnerFactory.php index dfc1efd..26b4bbe 100644 --- a/src/Type/Payment/TransactionPartnerFactory.php +++ b/src/Type/Payment/TransactionPartnerFactory.php @@ -14,6 +14,7 @@ public static function fromTelegramResult(mixed $result): TransactionPartner ValueHelper::assertArrayResult($result); return match (ValueHelper::getString($result, 'type')) { 'fragment' => TransactionPartnerFragment::fromTelegramResult($result), + 'telegram_ads' => TransactionPartnerTelegramAds::fromTelegramResult($result), 'user' => TransactionPartnerUser::fromTelegramResult($result), 'other' => TransactionPartnerOther::fromTelegramResult($result), default => throw new TelegramParseResultException('Unknown transaction partner type.'), diff --git a/src/Type/Payment/TransactionPartnerTelegramAds.php b/src/Type/Payment/TransactionPartnerTelegramAds.php new file mode 100644 index 0000000..91ad7f2 --- /dev/null +++ b/src/Type/Payment/TransactionPartnerTelegramAds.php @@ -0,0 +1,24 @@ + 'fragment', ], ], + [ + TransactionPartnerTelegramAds::class, + [ + 'type' => 'telegram_ads', + ], + ], [ TransactionPartnerUser::class, [ diff --git a/tests/Type/Payment/TransactionPartnerTelegramAdsTest.php b/tests/Type/Payment/TransactionPartnerTelegramAdsTest.php new file mode 100644 index 0000000..41e6c3e --- /dev/null +++ b/tests/Type/Payment/TransactionPartnerTelegramAdsTest.php @@ -0,0 +1,35 @@ +assertSame('telegram_ads', $object->getType()); + } + + public function testFromTelegramResult(): void + { + $object = TransactionPartnerTelegramAds::fromTelegramResult([ + 'type' => 'telegram_ads', + ]); + + $this->assertSame('telegram_ads', $object->getType()); + } + + public function testFromTelegramResultWithInvalidResult(): void + { + $this->expectException(TelegramParseResultException::class); + $this->expectExceptionMessage('Expected result as array. Got "string".'); + TransactionPartnerTelegramAds::fromTelegramResult('hello'); + } +}