diff --git a/src/Enums/InlineButtonType.php b/src/Enums/InlineButtonType.php index ae73749..a20ef80 100644 --- a/src/Enums/InlineButtonType.php +++ b/src/Enums/InlineButtonType.php @@ -13,4 +13,5 @@ enum InlineButtonType: string case OpenApp = 'open_app'; case Message = 'message'; case Chat = 'chat'; + case Clipboard = 'clipboard'; } diff --git a/src/ModelFactory.php b/src/ModelFactory.php index 9e8aa67..9c1c08a 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -14,6 +14,7 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\AbstractInlineButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\CallbackButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\ChatButton; +use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\ClipboardButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\LinkButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\MessageButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\OpenAppButton; @@ -300,6 +301,7 @@ public function createInlineButton(array $data): AbstractInlineButton InlineButtonType::RequestGeoLocation => RequestGeoLocationButton::fromArray($data), InlineButtonType::Chat => ChatButton::fromArray($data), InlineButtonType::OpenApp => OpenAppButton::fromArray($data), + InlineButtonType::Clipboard => ClipboardButton::fromArray($data), InlineButtonType::Message => MessageButton::fromArray($data), default => throw new LogicException( 'Unknown or unsupported inline button type: ' . ($data['type'] ?? 'none') diff --git a/src/Models/Attachments/Buttons/Inline/ClipboardButton.php b/src/Models/Attachments/Buttons/Inline/ClipboardButton.php new file mode 100644 index 0000000..2f39ebf --- /dev/null +++ b/src/Models/Attachments/Buttons/Inline/ClipboardButton.php @@ -0,0 +1,27 @@ +payload = $payload; + } +} diff --git a/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php b/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php new file mode 100644 index 0000000..2b67ddc --- /dev/null +++ b/tests/Models/Attachments/Buttons/Inline/ClipboardButtonTest.php @@ -0,0 +1,50 @@ + 'display', + 'payload' => 'copy', + 'type' => InlineButtonType::Clipboard->value, + + ]; + + $resultArray = $button->toArray(); + + $this->assertSame($expectedArray, $resultArray); + } + + #[Test] + public function fromArrayHydratesCorrectly(): void + { + $data = [ + 'type' => 'clipboard', + 'text' => 'display', + 'payload' => 'copy' + ]; + + $button = ClipboardButton::fromArray($data); + + $this->assertInstanceOf(ClipboardButton::class, $button); + $this->assertSame(InlineButtonType::Clipboard, $button->type); + $this->assertSame('display', $button->text); + $this->assertSame('copy', $button->payload); + } +}