appwrite/src/Appwrite/Utopia/Response/Model/Message.php

105 lines
3.3 KiB
PHP
Raw Normal View History

<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
use Utopia\Database\DateTime;
2023-09-11 15:00:21 +00:00
class Message extends Any
{
2023-08-07 15:31:25 +00:00
public function __construct()
{
$this
->addRule('$id', [
'type' => self::TYPE_STRING,
'description' => 'Message ID.',
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('providerId', [
'type' => self::TYPE_STRING,
'description' => 'Provider ID for the message.',
'default' => '',
'example' => '5e5ea5c16897e',
])
->addRule('to', [
'type' => self::TYPE_STRING,
2023-09-14 11:04:53 +00:00
'description' => 'Message recipients.',
'default' => '',
2023-09-11 15:06:43 +00:00
'array' => true,
'example' => ['user-1'],
])
->addRule('deliveryTime', [
'type' => self::TYPE_DATETIME,
2023-10-06 13:53:46 +00:00
'description' => 'The scheduled time for message.',
'required' => false,
'default' => DateTime::now(),
'example' => self::TYPE_DATETIME_EXAMPLE,
])
2023-10-06 13:53:46 +00:00
->addRule('deliveredAt', [
'type' => self::TYPE_DATETIME,
'description' => 'The time when the message was delivered.',
'required' => false,
'default' => '',
'example' => self::TYPE_DATETIME_EXAMPLE,
])
->addRule('deliveryErrors', [
'type' => self::TYPE_STRING,
'description' => 'Delivery errors if any.',
'required' => false,
'default' => '',
2023-09-11 15:06:43 +00:00
'array' => true,
2023-09-14 11:13:38 +00:00
'example' => ['Failed to send message to target 5e5ea5c16897e: Credentials not valid.'],
])
->addRule('deliveredTo', [
'type' => self::TYPE_INTEGER,
'description' => 'Number of recipients the message was delivered to.',
'default' => 0,
'example' => 1,
])
->addRule('data', [
'type' => self::TYPE_JSON,
'description' => 'Data of the message.',
'default' => [],
'example' => [
'subject' => 'Welcome to Appwrite',
'content' => 'Hi there, welcome to Appwrite family.',
],
])
->addRule('status', [
'type' => self::TYPE_STRING,
'description' => 'Status of delivery.',
'default' => 'processing',
'example' => 'Message status can be one of the following: processing, sent, failed.',
])
->addRule('description', [
'type' => self::TYPE_STRING,
'description' => 'Message description.',
'required' => false,
'default' => '',
'example' => 'Welcome Email.',
]);
2023-08-07 15:31:25 +00:00
}
/**
* Get Name
*
* @return string
*/
2023-08-07 15:31:25 +00:00
public function getName(): string
{
return 'Message';
}
/**
* Get Type
*
* @return string
*/
2023-08-07 15:31:25 +00:00
public function getType(): string
{
return Response::MODEL_MESSAGE;
}
}