Added Story object
This commit is contained in:
parent
b256812da6
commit
aae9e737da
2 changed files with 150 additions and 0 deletions
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* Added LinkPreviewOptions object
|
||||
* Added PaidMedia, PaidMediaPhoto, PaidMediaPreview, PaidMediaVideo & PaidMediaType Enum
|
||||
* Added PaidMediaInfo Object
|
||||
* Added Story object
|
||||
|
||||
### Changed
|
||||
* Refactored the way HTTP requests are handled & methods are called
|
||||
|
|
149
src/TgBotLib/Objects/Telegram/Story.php
Normal file
149
src/TgBotLib/Objects/Telegram/Story.php
Normal file
|
@ -0,0 +1,149 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\Telegram;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
|
||||
class Story implements ObjectTypeInterface
|
||||
{
|
||||
private string $file_id;
|
||||
private string $file_unique_id;
|
||||
private int $width;
|
||||
private int $height;
|
||||
private int $duration;
|
||||
private ?PhotoSize $thumbnail;
|
||||
private ?string $file_name;
|
||||
private ?string $mime_type;
|
||||
private ?int $file_size;
|
||||
|
||||
/**
|
||||
* Identifier for this file, which can be used to download or reuse the file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileId(): string
|
||||
{
|
||||
return $this->file_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unique identifier for this file, which is supposed to be the same over time
|
||||
* and for different bots. Can't be used to download or reuse the file.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFileUniqueId(): string
|
||||
{
|
||||
return $this->file_unique_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Video width as defined by the sender
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth(): int
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Video height as defined by the sender
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight(): int
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Duration of the video in seconds as defined by the sender
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getDuration(): int
|
||||
{
|
||||
return $this->duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Video thumbnail
|
||||
*
|
||||
* @return PhotoSize|null
|
||||
*/
|
||||
public function getThumbnail(): ?PhotoSize
|
||||
{
|
||||
return $this->thumbnail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. Original filename as defined by the sender
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFileName(): ?string
|
||||
{
|
||||
return $this->file_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. MIME type of the file as defined by the sender
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getMimeType(): ?string
|
||||
{
|
||||
return $this->mime_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have
|
||||
* difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a signed 64-bit
|
||||
* integer or double-precision float type are safe for storing this value.
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getFileSize(): ?int
|
||||
{
|
||||
return $this->file_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'file_id' => $this->file_id,
|
||||
'file_unique_id' => $this->file_unique_id,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'duration' => $this->duration,
|
||||
'thumbnail' => $this->thumbnail ? $this->thumbnail->toArray() : null,
|
||||
'file_name' => $this->file_name,
|
||||
'mime_type' => $this->mime_type,
|
||||
'file_size' => $this->file_size,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(array $data): ObjectTypeInterface
|
||||
{
|
||||
$object = new self();
|
||||
|
||||
$object->file_id = $data['file_id'];
|
||||
$object->file_unique_id = $data['file_unique_id'];
|
||||
$object->width = $data['width'];
|
||||
$object->height = $data['height'];
|
||||
$object->duration = $data['duration'];
|
||||
$object->thumbnail = isset($data['thumbnail']) ? PhotoSize::fromArray($data['thumbnail']) : null;
|
||||
$object->file_name = $data['file_name'] ?? null;
|
||||
$object->mime_type = $data['mime_type'] ?? null;
|
||||
$object->file_size = $data['file_size'] ?? null;
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue