diff --git a/src/Models/Attachments/Buttons/Inline/OpenAppButton.php b/src/Models/Attachments/Buttons/Inline/OpenAppButton.php index 4d5c2a1..fd671df 100644 --- a/src/Models/Attachments/Buttons/Inline/OpenAppButton.php +++ b/src/Models/Attachments/Buttons/Inline/OpenAppButton.php @@ -13,17 +13,20 @@ { public ?string $webApp; public ?int $contactId; + public ?string $payload; /** * @param string $text Visible button text (1 to 128 characters). * @param string|null $webApp The public name (username) of the bot or a link to it, whose mini-application should be launched. * @param int|null $contactId The ID of the bot whose mini-app should be launched. + * @param string|null $payload Init param which would be passed in mini-application initData (1 to 512 characters, allowed A-Z, a-z, 0-9, _(underscore) , - (minus) ). */ - public function __construct(string $text, ?string $webApp = null, ?int $contactId = null) + public function __construct(string $text, ?string $webApp = null, ?int $contactId = null, ?string $payload = null) { parent::__construct(InlineButtonType::OpenApp, $text); $this->webApp = $webApp; $this->contactId = $contactId; + $this->payload = $payload; } } diff --git a/tests/Models/Attachments/Buttons/Inline/OpenAppButtonTest.php b/tests/Models/Attachments/Buttons/Inline/OpenAppButtonTest.php index 0801cdc..3a1e8f0 100644 --- a/tests/Models/Attachments/Buttons/Inline/OpenAppButtonTest.php +++ b/tests/Models/Attachments/Buttons/Inline/OpenAppButtonTest.php @@ -16,11 +16,12 @@ final class OpenAppButtonTest extends TestCase #[Test] public function toArraySerializesCorrectly(): void { - $button = new OpenAppButton('Test Button', 'MyWebApp', 123); + $button = new OpenAppButton('Test Button', 'MyWebApp', 123, 'somePayload'); $expectedArray = [ 'web_app' => 'MyWebApp', 'contact_id' => 123, + 'payload' => 'somePayload', 'type' => InlineButtonType::OpenApp->value, 'text' => 'Test Button', ]; @@ -38,6 +39,7 @@ public function fromArrayHydratesCorrectly(): void 'text' => 'Launch', 'web_app' => 'SomeApp', 'contact_id' => 456, + 'payload' => 'somePayload' ]; $button = OpenAppButton::fromArray($data); @@ -47,5 +49,6 @@ public function fromArrayHydratesCorrectly(): void $this->assertSame('Launch', $button->text); $this->assertSame('SomeApp', $button->webApp); $this->assertSame(456, $button->contactId); + $this->assertSame('somePayload', $button->payload); } }