-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
TransactionPartnerTelegramAds
type (#91)
- Loading branch information
Showing
6 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Type\Payment; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#transactionpartnertelegramads | ||
*/ | ||
final readonly class TransactionPartnerTelegramAds implements TransactionPartner | ||
{ | ||
public function getType(): string | ||
{ | ||
return 'telegram_ads'; | ||
} | ||
|
||
public static function fromTelegramResult(mixed $result): self | ||
{ | ||
ValueHelper::assertArrayResult($result); | ||
return new self(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Type\Payment; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vjik\TelegramBot\Api\ParseResult\TelegramParseResultException; | ||
use Vjik\TelegramBot\Api\Type\Payment\TransactionPartnerTelegramAds; | ||
|
||
final class TransactionPartnerTelegramAdsTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$object = new TransactionPartnerTelegramAds(); | ||
|
||
$this->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'); | ||
} | ||
} |