mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-24 04:46:48 +00:00
Removed deprecated ReplyKeyboardAttachment #27
This commit is contained in:
+2
-12
@@ -29,7 +29,6 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\FileAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\InlineKeyboardAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\LocationAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\PhotoAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\ReplyKeyboardAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\ShareAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\StickerAttachment;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\VideoAttachment;
|
||||
@@ -242,14 +241,6 @@ readonly class ModelFactory
|
||||
public function createAttachment(array $data): AbstractAttachment
|
||||
{
|
||||
$attachmentType = AttachmentType::tryFrom($data['type'] ?? '');
|
||||
if ($attachmentType === AttachmentType::ReplyKeyboard
|
||||
&& isset($data['buttons']) && is_array($data['buttons'])) {
|
||||
$data['buttons'] = array_map(
|
||||
fn($rowOfButtons) => array_map([$this, 'createReplyButton'], $rowOfButtons),
|
||||
$data['buttons'],
|
||||
);
|
||||
}
|
||||
|
||||
if ($attachmentType === AttachmentType::InlineKeyboard
|
||||
&& isset($data['payload']['buttons']) && is_array($data['payload']['buttons'])) {
|
||||
$data['payload']['buttons'] = array_map(
|
||||
@@ -259,8 +250,6 @@ readonly class ModelFactory
|
||||
}
|
||||
|
||||
return match ($attachmentType) {
|
||||
AttachmentType::Data => DataAttachment::fromArray($data),
|
||||
AttachmentType::Share => ShareAttachment::fromArray($data),
|
||||
AttachmentType::Image => PhotoAttachment::fromArray($data),
|
||||
AttachmentType::Video => VideoAttachment::fromArray($data),
|
||||
AttachmentType::Audio => AudioAttachment::fromArray($data),
|
||||
@@ -268,8 +257,9 @@ readonly class ModelFactory
|
||||
AttachmentType::Sticker => StickerAttachment::fromArray($data),
|
||||
AttachmentType::Contact => ContactAttachment::fromArray($data),
|
||||
AttachmentType::InlineKeyboard => InlineKeyboardAttachment::fromArray($data),
|
||||
AttachmentType::ReplyKeyboard => ReplyKeyboardAttachment::fromArray($data),
|
||||
AttachmentType::Location => LocationAttachment::fromArray($data),
|
||||
AttachmentType::Share => ShareAttachment::fromArray($data),
|
||||
AttachmentType::Data => DataAttachment::fromArray($data),
|
||||
default => throw new LogicException('Unknown or unsupported attachment type: ' . ($data['type'] ?? 'none')),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user