adds from field in remaining providers
This commit is contained in:
parent
af40c63357
commit
b60cbcada5
3 changed files with 92 additions and 21 deletions
|
@ -106,12 +106,13 @@ App::post('/v1/messaging/providers/sendgrid')
|
||||||
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
||||||
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('name', '', new Text(128), 'Provider name.')
|
->param('name', '', new Text(128), 'Provider name.')
|
||||||
|
->param('from', '', new Text(256), 'Sender Email Address.')
|
||||||
|
->param('apiKey', '', new Text(0), 'Sendgrid API key.')
|
||||||
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
||||||
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('apiKey', '', new Text(0), 'Sendgrid API key.')
|
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, bool $default, bool $enabled, string $apiKey, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, string $from, string $apiKey, bool $default, bool $enabled, Database $dbForProject, Response $response) {
|
||||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||||
$provider = new Document([
|
$provider = new Document([
|
||||||
'$id' => $providerId,
|
'$id' => $providerId,
|
||||||
|
@ -120,11 +121,13 @@ App::post('/v1/messaging/providers/sendgrid')
|
||||||
'type' => 'email',
|
'type' => 'email',
|
||||||
'default' => $default,
|
'default' => $default,
|
||||||
'enabled' => $enabled,
|
'enabled' => $enabled,
|
||||||
'options' => [],
|
|
||||||
'search' => $providerId . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email',
|
'search' => $providerId . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email',
|
||||||
'credentials' => [
|
'credentials' => [
|
||||||
'apiKey' => $apiKey,
|
'apiKey' => $apiKey,
|
||||||
],
|
],
|
||||||
|
'options' => [
|
||||||
|
'from' => $from,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Check if a default provider exists, if not, set this one as default
|
// Check if a default provider exists, if not, set this one as default
|
||||||
|
@ -225,13 +228,14 @@ App::post('/v1/messaging/providers/telesign')
|
||||||
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
||||||
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('name', '', new Text(128), 'Provider name.')
|
->param('name', '', new Text(128), 'Provider name.')
|
||||||
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
->param('from', '', new Text(256), 'Sender Number.')
|
||||||
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
|
||||||
->param('username', '', new Text(0), 'Telesign username.')
|
->param('username', '', new Text(0), 'Telesign username.')
|
||||||
->param('password', '', new Text(0), 'Telesign password.')
|
->param('password', '', new Text(0), 'Telesign password.')
|
||||||
|
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
||||||
|
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, bool $default, bool $enabled, string $username, string $password, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, string $from, string $username, string $password, bool $default, bool $enabled, Database $dbForProject, Response $response) {
|
||||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||||
$provider = new Document([
|
$provider = new Document([
|
||||||
'$id' => $providerId,
|
'$id' => $providerId,
|
||||||
|
@ -245,6 +249,9 @@ App::post('/v1/messaging/providers/telesign')
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'password' => $password,
|
'password' => $password,
|
||||||
],
|
],
|
||||||
|
'options' => [
|
||||||
|
'from' => $from,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Check if a default provider exists, if not, set this one as default
|
// Check if a default provider exists, if not, set this one as default
|
||||||
|
@ -283,13 +290,14 @@ App::post('/v1/messaging/providers/textmagic')
|
||||||
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
||||||
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('name', '', new Text(128), 'Provider name.')
|
->param('name', '', new Text(128), 'Provider name.')
|
||||||
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
->param('from', '', new Text(256), 'Sender Number.')
|
||||||
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
|
||||||
->param('username', '', new Text(0), 'Textmagic username.')
|
->param('username', '', new Text(0), 'Textmagic username.')
|
||||||
->param('apiKey', '', new Text(0), 'Textmagic apiKey.')
|
->param('apiKey', '', new Text(0), 'Textmagic apiKey.')
|
||||||
|
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
||||||
|
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, bool $default, bool $enabled, string $username, string $apiKey, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, string $from, string $username, string $apiKey, bool $default, bool $enabled, Database $dbForProject, Response $response) {
|
||||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||||
$provider = new Document([
|
$provider = new Document([
|
||||||
'$id' => $providerId,
|
'$id' => $providerId,
|
||||||
|
@ -303,6 +311,9 @@ App::post('/v1/messaging/providers/textmagic')
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'apiKey' => $apiKey,
|
'apiKey' => $apiKey,
|
||||||
],
|
],
|
||||||
|
'options' => [
|
||||||
|
'from' => $from,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Check if a default provider exists, if not, set this one as default
|
// Check if a default provider exists, if not, set this one as default
|
||||||
|
@ -341,13 +352,14 @@ App::post('/v1/messaging/providers/twilio')
|
||||||
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
||||||
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('name', '', new Text(128), 'Provider name.')
|
->param('name', '', new Text(128), 'Provider name.')
|
||||||
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
->param('from', '', new Text(256), 'Sender number.')
|
||||||
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
|
||||||
->param('accountSid', '', new Text(0), 'Twilio account secret ID.')
|
->param('accountSid', '', new Text(0), 'Twilio account secret ID.')
|
||||||
->param('authToken', '', new Text(0), 'Twilio authentication token.')
|
->param('authToken', '', new Text(0), 'Twilio authentication token.')
|
||||||
|
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
||||||
|
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, bool $default, bool $enabled, string $accountSid, string $authToken, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, string $from, string $accountSid, string $authToken, bool $default, bool $enabled, Database $dbForProject, Response $response) {
|
||||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||||
$provider = new Document([
|
$provider = new Document([
|
||||||
'$id' => $providerId,
|
'$id' => $providerId,
|
||||||
|
@ -361,6 +373,9 @@ App::post('/v1/messaging/providers/twilio')
|
||||||
'accountSid' => $accountSid,
|
'accountSid' => $accountSid,
|
||||||
'authToken' => $authToken,
|
'authToken' => $authToken,
|
||||||
],
|
],
|
||||||
|
'options' => [
|
||||||
|
'from' => $from,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Check if a default provider exists, if not, set this one as default
|
// Check if a default provider exists, if not, set this one as default
|
||||||
|
@ -399,13 +414,14 @@ App::post('/v1/messaging/providers/vonage')
|
||||||
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
->label('sdk.response.model', Response::MODEL_PROVIDER)
|
||||||
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
->param('providerId', '', new CustomId(), 'Provider ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.')
|
||||||
->param('name', '', new Text(128), 'Provider name.')
|
->param('name', '', new Text(128), 'Provider name.')
|
||||||
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
->param('from', '', new Text(256), 'Sender number.')
|
||||||
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
|
||||||
->param('apiKey', '', new Text(0), 'Vonage API key.')
|
->param('apiKey', '', new Text(0), 'Vonage API key.')
|
||||||
->param('apiSecret', '', new Text(0), 'Vonage API secret.')
|
->param('apiSecret', '', new Text(0), 'Vonage API secret.')
|
||||||
|
->param('default', false, new Boolean(), 'Set as default provider.', true)
|
||||||
|
->param('enabled', true, new Boolean(), 'Set as enabled.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, bool $default, bool $enabled, string $apiKey, string $apiSecret, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, string $from, string $apiKey, string $apiSecret, bool $default, bool $enabled, Database $dbForProject, Response $response) {
|
||||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||||
$provider = new Document([
|
$provider = new Document([
|
||||||
'$id' => $providerId,
|
'$id' => $providerId,
|
||||||
|
@ -419,6 +435,9 @@ App::post('/v1/messaging/providers/vonage')
|
||||||
'apiKey' => $apiKey,
|
'apiKey' => $apiKey,
|
||||||
'apiSecret' => $apiSecret,
|
'apiSecret' => $apiSecret,
|
||||||
],
|
],
|
||||||
|
'options' => [
|
||||||
|
'from' => $from,
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Check if a default provider exists, if not, set this one as default
|
// Check if a default provider exists, if not, set this one as default
|
||||||
|
@ -713,9 +732,10 @@ App::patch('/v1/messaging/providers/sendgrid/:providerId')
|
||||||
->param('name', '', new Text(128), 'Provider name.', true)
|
->param('name', '', new Text(128), 'Provider name.', true)
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('apiKey', '', new Text(0), 'Sendgrid API key.', true)
|
->param('apiKey', '', new Text(0), 'Sendgrid API key.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Email Address.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $apiKey, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $apiKey, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -732,6 +752,12 @@ App::patch('/v1/messaging/providers/sendgrid/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'sendgrid' . ' ' . 'email');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
@ -766,9 +792,10 @@ App::patch('/v1/messaging/providers/msg91/:providerId')
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('senderId', '', new Text(0), 'Msg91 Sender ID.', true)
|
->param('senderId', '', new Text(0), 'Msg91 Sender ID.', true)
|
||||||
->param('authKey', '', new Text(0), 'Msg91 Auth Key.', true)
|
->param('authKey', '', new Text(0), 'Msg91 Auth Key.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Number.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $senderId, string $authKey, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $senderId, string $authKey, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -785,6 +812,12 @@ App::patch('/v1/messaging/providers/msg91/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'msg91' . ' ' . 'sms');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'msg91' . ' ' . 'sms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
@ -825,9 +858,10 @@ App::patch('/v1/messaging/providers/telesign/:providerId')
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('username', '', new Text(0), 'Telesign username.', true)
|
->param('username', '', new Text(0), 'Telesign username.', true)
|
||||||
->param('password', '', new Text(0), 'Telesign password.', true)
|
->param('password', '', new Text(0), 'Telesign password.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Number.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $username, string $password, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $username, string $password, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -844,6 +878,12 @@ App::patch('/v1/messaging/providers/telesign/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'telesign' . ' ' . 'sms');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'telesign' . ' ' . 'sms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
@ -884,9 +924,10 @@ App::patch('/v1/messaging/providers/textmagic/:providerId')
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('username', '', new Text(0), 'Textmagic username.', true)
|
->param('username', '', new Text(0), 'Textmagic username.', true)
|
||||||
->param('apiKey', '', new Text(0), 'Textmagic apiKey.', true)
|
->param('apiKey', '', new Text(0), 'Textmagic apiKey.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Number.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $username, string $apiKey, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $username, string $apiKey, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -903,6 +944,12 @@ App::patch('/v1/messaging/providers/textmagic/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'textmagic' . ' ' . 'sms');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'textmagic' . ' ' . 'sms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
@ -943,9 +990,10 @@ App::patch('/v1/messaging/providers/twilio/:providerId')
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('accountSid', null, new Text(0), 'Twilio account secret ID.', true)
|
->param('accountSid', null, new Text(0), 'Twilio account secret ID.', true)
|
||||||
->param('authToken', null, new Text(0), 'Twilio authentication token.', true)
|
->param('authToken', null, new Text(0), 'Twilio authentication token.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Number.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $accountSid, string $authToken, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $accountSid, string $authToken, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -962,6 +1010,12 @@ App::patch('/v1/messaging/providers/twilio/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'twilio' . ' ' . 'sms');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'twilio' . ' ' . 'sms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
@ -1002,9 +1056,10 @@ App::patch('/v1/messaging/providers/vonage/:providerId')
|
||||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||||
->param('apiKey', '', new Text(0), 'Vonage API key.', true)
|
->param('apiKey', '', new Text(0), 'Vonage API key.', true)
|
||||||
->param('apiSecret', '', new Text(0), 'Vonage API secret.', true)
|
->param('apiSecret', '', new Text(0), 'Vonage API secret.', true)
|
||||||
|
->param('from', '', new Text(256), 'Sender Number.', true)
|
||||||
->inject('dbForProject')
|
->inject('dbForProject')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->action(function (string $providerId, string $name, ?bool $enabled, string $apiKey, string $apiSecret, Database $dbForProject, Response $response) {
|
->action(function (string $providerId, string $name, ?bool $enabled, string $apiKey, string $apiSecret, string $from, Database $dbForProject, Response $response) {
|
||||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||||
|
|
||||||
if ($provider->isEmpty()) {
|
if ($provider->isEmpty()) {
|
||||||
|
@ -1021,6 +1076,12 @@ App::patch('/v1/messaging/providers/vonage/:providerId')
|
||||||
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'vonage' . ' ' . 'sms');
|
$provider->setAttribute('search', $provider->getId() . ' ' . $name . ' ' . 'vonage' . ' ' . 'sms');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!empty($from)) {
|
||||||
|
$provider->setAttribute('options', [
|
||||||
|
'from' => $from,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
if ($enabled === true || $enabled === false) {
|
if ($enabled === true || $enabled === false) {
|
||||||
$provider->setAttribute('enabled', $enabled);
|
$provider->setAttribute('enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ class MessagingTest extends Scope
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Sengrid1',
|
'name' => 'Sengrid1',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
|
'from' => 'sender-email@my-domain',
|
||||||
],
|
],
|
||||||
'Mailgun' => [
|
'Mailgun' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
@ -35,18 +36,21 @@ class MessagingTest extends Scope
|
||||||
'name' => 'Twilio1',
|
'name' => 'Twilio1',
|
||||||
'accountSid' => 'my-accountSid',
|
'accountSid' => 'my-accountSid',
|
||||||
'authToken' => 'my-authToken',
|
'authToken' => 'my-authToken',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'Telesign' => [
|
'Telesign' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Telesign1',
|
'name' => 'Telesign1',
|
||||||
'username' => 'my-username',
|
'username' => 'my-username',
|
||||||
'password' => 'my-password',
|
'password' => 'my-password',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'Textmagic' => [
|
'Textmagic' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Textmagic1',
|
'name' => 'Textmagic1',
|
||||||
'username' => 'my-username',
|
'username' => 'my-username',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'Msg91' => [
|
'Msg91' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
@ -60,6 +64,7 @@ class MessagingTest extends Scope
|
||||||
'name' => 'Vonage1',
|
'name' => 'Vonage1',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
'apiSecret' => 'my-apisecret',
|
'apiSecret' => 'my-apisecret',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'Fcm' => [
|
'Fcm' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
|
|
@ -15,6 +15,7 @@ trait MessagingBase
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Sengrid1',
|
'name' => 'Sengrid1',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
|
'from' => 'sender-email@my-domain',
|
||||||
],
|
],
|
||||||
'mailgun' => [
|
'mailgun' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
@ -28,18 +29,21 @@ trait MessagingBase
|
||||||
'name' => 'Twilio1',
|
'name' => 'Twilio1',
|
||||||
'accountSid' => 'my-accountSid',
|
'accountSid' => 'my-accountSid',
|
||||||
'authToken' => 'my-authToken',
|
'authToken' => 'my-authToken',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'telesign' => [
|
'telesign' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Telesign1',
|
'name' => 'Telesign1',
|
||||||
'username' => 'my-username',
|
'username' => 'my-username',
|
||||||
'password' => 'my-password',
|
'password' => 'my-password',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'textmagic' => [
|
'textmagic' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
'name' => 'Textmagic1',
|
'name' => 'Textmagic1',
|
||||||
'username' => 'my-username',
|
'username' => 'my-username',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'msg91' => [
|
'msg91' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
@ -53,6 +57,7 @@ trait MessagingBase
|
||||||
'name' => 'Vonage1',
|
'name' => 'Vonage1',
|
||||||
'apiKey' => 'my-apikey',
|
'apiKey' => 'my-apikey',
|
||||||
'apiSecret' => 'my-apisecret',
|
'apiSecret' => 'my-apisecret',
|
||||||
|
'from' => '+123456789',
|
||||||
],
|
],
|
||||||
'fcm' => [
|
'fcm' => [
|
||||||
'providerId' => ID::unique(),
|
'providerId' => ID::unique(),
|
||||||
|
|
Loading…
Reference in a new issue