. * */ namespace Friendica\Object\Api\Mastodon; use Friendica\BaseDataTransferObject; use Friendica\Util\DateTimeFormat; /** * Class Notification * * @see https://docs.joinmastodon.org/entities/notification/ */ class Notification extends BaseDataTransferObject { /** @var string */ protected $id; /** @var string (Enumerable oneOf) */ protected $type; /** @var string (Datetime) */ protected $created_at; /** @var Account */ protected $account; /** @var Status|null */ protected $status = null; /** * Creates a notification record * * @param array $item * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public function __construct(int $id, string $type, string $created_at, Account $account = null, Status $status = null) { $this->id = (string)$id; $this->type = $type; $this->created_at = DateTimeFormat::utc($created_at, DateTimeFormat::ATOM); $this->account = $account->toArray(); if (!empty($status)) { $this->status = $status->toArray(); } } /** * Returns the current entity as an array * * @return array */ public function toArray(): array { $notification = parent::toArray(); if (!$notification['status']) { unset($notification['status']); } return $notification; } }