Merge branch 'feat-add-messaging-response-models' into feat-messages-event-config
This commit is contained in:
commit
cc1311b723
6 changed files with 252 additions and 252 deletions
|
@ -8,88 +8,88 @@ use Utopia\Database\DateTime;
|
||||||
|
|
||||||
class Message extends Model
|
class Message extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected bool $public = false;
|
protected bool $public = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->addRule('$id', [
|
->addRule('$id', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Message ID.',
|
'description' => 'Message ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '5e5ea5c16897e',
|
'example' => '5e5ea5c16897e',
|
||||||
])
|
])
|
||||||
->addRule('providerId', [
|
->addRule('providerId', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Provider Id for the message.',
|
'description' => 'Provider Id for the message.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '5e5ea5c16897e',
|
'example' => '5e5ea5c16897e',
|
||||||
])
|
])
|
||||||
->addRule('data', [
|
->addRule('data', [
|
||||||
'type' => self::TYPE_JSON,
|
'type' => self::TYPE_JSON,
|
||||||
'description' => 'Message Data.',
|
'description' => 'Message Data.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'example' => '',
|
'example' => '',
|
||||||
])
|
])
|
||||||
->addRule('to', [
|
->addRule('to', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Recipient of message.',
|
'description' => 'Recipient of message.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => ['user-1'],
|
'example' => ['user-1'],
|
||||||
])
|
])
|
||||||
->addRule('deliveryTime', [
|
->addRule('deliveryTime', [
|
||||||
'type' => self::TYPE_DATETIME,
|
'type' => self::TYPE_DATETIME,
|
||||||
'description' => 'Recipient of message.',
|
'description' => 'Recipient of message.',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'default' => DateTime::now(),
|
'default' => DateTime::now(),
|
||||||
'example' => DateTime::now(),
|
'example' => DateTime::now(),
|
||||||
])
|
])
|
||||||
->addRule('deliveryError', [
|
->addRule('deliveryError', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Delivery error if any.',
|
'description' => 'Delivery error if any.',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'Provider not valid.',
|
'example' => 'Provider not valid.',
|
||||||
])
|
])
|
||||||
->addRule('deliveredTo', [
|
->addRule('deliveredTo', [
|
||||||
'type' => self::TYPE_INTEGER,
|
'type' => self::TYPE_INTEGER,
|
||||||
'description' => 'Number of recipients the message was delivered to.',
|
'description' => 'Number of recipients the message was delivered to.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 1,
|
'example' => 1,
|
||||||
])
|
])
|
||||||
->addRule('delivered', [
|
->addRule('delivered', [
|
||||||
'type' => self::TYPE_BOOLEAN,
|
'type' => self::TYPE_BOOLEAN,
|
||||||
'description' => 'Status of delivery.',
|
'description' => 'Status of delivery.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => true,
|
'example' => true,
|
||||||
])
|
])
|
||||||
->addRule('search', [
|
->addRule('search', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Field that can be used for searching message.',
|
'description' => 'Field that can be used for searching message.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'Hello everyone',
|
'example' => 'Hello everyone',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Name
|
* Get Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Message';
|
return 'Message';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Type
|
* Get Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return Response::MODEL_MESSAGE;
|
return Response::MODEL_MESSAGE;
|
||||||
|
|
|
@ -7,55 +7,55 @@ use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
class Provider extends Model
|
class Provider extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected bool $public = false;
|
protected bool $public = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->addRule('$id', [
|
->addRule('$id', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Provider ID.',
|
'description' => 'Provider ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '5e5ea5c16897e',
|
'example' => '5e5ea5c16897e',
|
||||||
])
|
])
|
||||||
->addRule('name', [
|
->addRule('name', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'The user-given name for the provider instance.',
|
'description' => 'The user-given name for the provider instance.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'Mailgun',
|
'example' => 'Mailgun',
|
||||||
])
|
])
|
||||||
->addRule('provider', [
|
->addRule('provider', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Provider name setup in Utopia.',
|
'description' => 'Provider name setup in Utopia.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'mailgun',
|
'example' => 'mailgun',
|
||||||
])
|
])
|
||||||
->addRule('type', [
|
->addRule('type', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Type of provider.',
|
'description' => 'Type of provider.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'sms',
|
'example' => 'sms',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Name
|
* Get Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Provider';
|
return 'Provider';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Type
|
* Get Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return Response::MODEL_PROVIDER;
|
return Response::MODEL_PROVIDER;
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Appwrite\Utopia\Response\Model;
|
|
||||||
|
|
||||||
use Appwrite\Utopia\Response;
|
|
||||||
use Appwrite\Utopia\Response\Model;
|
|
||||||
|
|
||||||
class Subscriber extends Model
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
protected bool $public = false;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
$this
|
|
||||||
->addRule('$id', [
|
|
||||||
'type' => self::TYPE_STRING,
|
|
||||||
'description' => 'Subscriber ID.',
|
|
||||||
'default' => '',
|
|
||||||
'example' => '259125845563242502',
|
|
||||||
])
|
|
||||||
->addRule('userId', [
|
|
||||||
'type' => self::TYPE_STRING,
|
|
||||||
'description' => 'User ID.',
|
|
||||||
'default' => '',
|
|
||||||
'example' => '259125845563242502',
|
|
||||||
])
|
|
||||||
->addRule('targetId', [
|
|
||||||
'type' => self::TYPE_STRING,
|
|
||||||
'description' => 'Target ID.',
|
|
||||||
'default' => '',
|
|
||||||
'example' => '259125845563242502',
|
|
||||||
])
|
|
||||||
->addRule('topicId', [
|
|
||||||
'type' => self::TYPE_STRING,
|
|
||||||
'description' => 'Topic ID.',
|
|
||||||
'default' => '',
|
|
||||||
'example' => '259125845563242502',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
|
||||||
{
|
|
||||||
return 'Subscriber';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Type
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getType(): string
|
|
||||||
{
|
|
||||||
return Response::MODEL_SUBSCRIBER;
|
|
||||||
}
|
|
||||||
}
|
|
63
src/Appwrite/Utopia/Response/Model/Subscriber.php
Normal file
63
src/Appwrite/Utopia/Response/Model/Subscriber.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
use Appwrite\Utopia\Response;
|
||||||
|
use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
|
class Subscriber extends Model
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected bool $public = false;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addRule('$id', [
|
||||||
|
'type' => self::TYPE_STRING,
|
||||||
|
'description' => 'Subscriber ID.',
|
||||||
|
'default' => '',
|
||||||
|
'example' => '259125845563242502',
|
||||||
|
])
|
||||||
|
->addRule('userId', [
|
||||||
|
'type' => self::TYPE_STRING,
|
||||||
|
'description' => 'User ID.',
|
||||||
|
'default' => '',
|
||||||
|
'example' => '259125845563242502',
|
||||||
|
])
|
||||||
|
->addRule('targetId', [
|
||||||
|
'type' => self::TYPE_STRING,
|
||||||
|
'description' => 'Target ID.',
|
||||||
|
'default' => '',
|
||||||
|
'example' => '259125845563242502',
|
||||||
|
])
|
||||||
|
->addRule('topicId', [
|
||||||
|
'type' => self::TYPE_STRING,
|
||||||
|
'description' => 'Topic ID.',
|
||||||
|
'default' => '',
|
||||||
|
'example' => '259125845563242502',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName(): string
|
||||||
|
{
|
||||||
|
return 'Subscriber';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Type
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getType(): string
|
||||||
|
{
|
||||||
|
return Response::MODEL_SUBSCRIBER;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,62 +7,62 @@ use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
class Target extends Model
|
class Target extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected bool $public = false;
|
protected bool $public = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->addRule('$id', [
|
->addRule('$id', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Target ID.',
|
'description' => 'Target ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '259125845563242502',
|
'example' => '259125845563242502',
|
||||||
])
|
])
|
||||||
->addRule('userId', [
|
->addRule('userId', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'User ID.',
|
'description' => 'User ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '259125845563242502',
|
'example' => '259125845563242502',
|
||||||
])
|
])
|
||||||
->addRule('providerId', [
|
->addRule('providerId', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Provider ID.',
|
'description' => 'Provider ID.',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '259125845563242502',
|
'example' => '259125845563242502',
|
||||||
])
|
])
|
||||||
->addRule('providerType', [
|
->addRule('providerType', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'The type of provider supported by this target.',
|
'description' => 'The type of provider supported by this target.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'sms',
|
'example' => 'sms',
|
||||||
])
|
])
|
||||||
->addRule('identifier', [
|
->addRule('identifier', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'The target identifier.',
|
'description' => 'The target identifier.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'token',
|
'example' => 'token',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Name
|
* Get Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Target';
|
return 'Target';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Type
|
* Get Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return Response::MODEL_TARGET;
|
return Response::MODEL_TARGET;
|
||||||
|
|
|
@ -7,56 +7,56 @@ use Appwrite\Utopia\Response\Model;
|
||||||
|
|
||||||
class Topic extends Model
|
class Topic extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected bool $public = false;
|
protected bool $public = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this
|
$this
|
||||||
->addRule('$id', [
|
->addRule('$id', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Topic ID.',
|
'description' => 'Topic ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '259125845563242502',
|
'example' => '259125845563242502',
|
||||||
])
|
])
|
||||||
->addRule('providerId', [
|
->addRule('providerId', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Provider ID.',
|
'description' => 'Provider ID.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => '259125845563242502',
|
'example' => '259125845563242502',
|
||||||
])
|
])
|
||||||
->addRule('name', [
|
->addRule('name', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'The name of the topic.',
|
'description' => 'The name of the topic.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'example' => 'events',
|
'example' => 'events',
|
||||||
])
|
])
|
||||||
->addRule('description', [
|
->addRule('description', [
|
||||||
'type' => self::TYPE_STRING,
|
'type' => self::TYPE_STRING,
|
||||||
'description' => 'Description of the topic.',
|
'description' => 'Description of the topic.',
|
||||||
'default' => '',
|
'default' => '',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'example' => 'All events related messages will be sent to this topic.',
|
'example' => 'All events related messages will be sent to this topic.',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Name
|
* Get Name
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'Topic';
|
return 'Topic';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Type
|
* Get Type
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getType(): string
|
public function getType(): string
|
||||||
{
|
{
|
||||||
return Response::MODEL_TOPIC;
|
return Response::MODEL_TOPIC;
|
||||||
|
|
Loading…
Reference in a new issue