mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-24 07:26:49 +00:00
44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BushlanovDev\MaxMessengerBot\Models\Attachments\Requests;
|
|
|
|
use BushlanovDev\MaxMessengerBot\Enums\AttachmentType;
|
|
use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\ShareAttachmentRequestPayload;
|
|
|
|
/**
|
|
* Request to attach a media preview of an external URL.
|
|
*/
|
|
final readonly class ShareAttachmentRequest extends AbstractAttachmentRequest
|
|
{
|
|
/**
|
|
* Creates a request to attach a URL preview.
|
|
*
|
|
* @param string $url The URL to generate a preview for.
|
|
*
|
|
* @return ShareAttachmentRequest
|
|
*/
|
|
public static function fromUrl(string $url): self
|
|
{
|
|
return new self(new ShareAttachmentRequestPayload(url: $url));
|
|
}
|
|
|
|
/**
|
|
* Creates a request to re-send a URL preview using its token.
|
|
*
|
|
* @param string $token The token of a previously generated preview.
|
|
*
|
|
* @return ShareAttachmentRequest
|
|
*/
|
|
public static function fromToken(string $token): self
|
|
{
|
|
return new self(new ShareAttachmentRequestPayload(token: $token));
|
|
}
|
|
|
|
private function __construct(ShareAttachmentRequestPayload $payload)
|
|
{
|
|
parent::__construct(AttachmentType::Share, $payload);
|
|
}
|
|
}
|