Added PaidMediaPurchased
This commit is contained in:
parent
c4d7fc0f41
commit
6839980fdb
1 changed files with 60 additions and 0 deletions
60
src/TgBotLib/Objects/Payments/PaidMediaPurchased.php
Normal file
60
src/TgBotLib/Objects/Payments/PaidMediaPurchased.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace TgBotLib\Objects\Payments;
|
||||
|
||||
use TgBotLib\Interfaces\ObjectTypeInterface;
|
||||
use TgBotLib\Objects\User;
|
||||
|
||||
class PaidMediaPurchased implements ObjectTypeInterface
|
||||
{
|
||||
private User $from;
|
||||
private string $paid_media_payload;
|
||||
|
||||
/**
|
||||
* User who purchased the media
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function getFrom(): User
|
||||
{
|
||||
return $this->from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bot-specified paid media payload
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPaidMediaPayload(): string
|
||||
{
|
||||
return $this->paid_media_payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function toArray(): ?array
|
||||
{
|
||||
return [
|
||||
'from' => $this->from->toArray(),
|
||||
'paid_media_payload' => $this->paid_media_payload,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function fromArray(?array $data): ?PaidMediaPurchased
|
||||
{
|
||||
if (is_null($data))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = new self();
|
||||
$object->from = isset($data['from']) ? User::fromArray($data['from']) : null;
|
||||
$object->paid_media_payload = $data['paid_media_payload'];
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue