Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Models/Attachments/Buttons/Inline/OpenAppButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
Expand All @@ -38,6 +39,7 @@ public function fromArrayHydratesCorrectly(): void
'text' => 'Launch',
'web_app' => 'SomeApp',
'contact_id' => 456,
'payload' => 'somePayload'
];

$button = OpenAppButton::fromArray($data);
Expand All @@ -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);
}
}