Fix msg91 params
This commit is contained in:
parent
536c67f54d
commit
2d03fc1ce0
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -313,24 +313,23 @@ App::post('/v1/messaging/providers/msg91')
|
|||
->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('name', '', new Text(128), 'Provider name.')
|
||||
->param('from', '', new Phone(), 'Sender Phone number. Format this number with a leading \'+\' and a country code, e.g., +16175551212.', true)
|
||||
->param('senderId', '', new Text(0), 'Msg91 Sender ID.', true)
|
||||
->param('authKey', '', new Text(0), 'Msg91 Auth Key.', true)
|
||||
->param('templateId', '', new Text(0), 'Msg91 template ID', true)
|
||||
->param('senderId', '', new Text(0), 'Msg91 sender ID.', true)
|
||||
->param('authKey', '', new Text(0), 'Msg91 auth key.', true)
|
||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||
->inject('queueForEvents')
|
||||
->inject('dbForProject')
|
||||
->inject('response')
|
||||
->action(function (string $providerId, string $name, string $from, string $senderId, string $authKey, ?bool $enabled, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
->action(function (string $providerId, string $name, string $templateId, string $senderId, string $authKey, ?bool $enabled, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
$providerId = $providerId == 'unique()' ? ID::unique() : $providerId;
|
||||
|
||||
$options = [];
|
||||
|
||||
if (!empty($from)) {
|
||||
$options['from'] = $from;
|
||||
}
|
||||
|
||||
$credentials = [];
|
||||
|
||||
if (!empty($templateId)) {
|
||||
$credentials['templateId'] = $templateId;
|
||||
}
|
||||
|
||||
if (!empty($senderId)) {
|
||||
$credentials['senderId'] = $senderId;
|
||||
}
|
||||
|
@ -1330,13 +1329,13 @@ App::patch('/v1/messaging/providers/msg91/:providerId')
|
|||
->param('providerId', '', new UID(), 'Provider ID.')
|
||||
->param('name', '', new Text(128), 'Provider name.', true)
|
||||
->param('enabled', null, new Boolean(), 'Set as enabled.', true)
|
||||
->param('senderId', '', new Text(0), 'Msg91 Sender ID.', true)
|
||||
->param('authKey', '', new Text(0), 'Msg91 Auth Key.', true)
|
||||
->param('from', '', new Text(256), 'Sender number.', true)
|
||||
->param('templateId', '', new Text(0), 'Msg91 template ID.', true)
|
||||
->param('senderId', '', new Text(0), 'Msg91 sender ID.', true)
|
||||
->param('authKey', '', new Text(0), 'Msg91 auth key.', true)
|
||||
->inject('queueForEvents')
|
||||
->inject('dbForProject')
|
||||
->inject('response')
|
||||
->action(function (string $providerId, string $name, ?bool $enabled, string $senderId, string $authKey, string $from, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
->action(function (string $providerId, string $name, ?bool $enabled, string $templateId, string $senderId, string $authKey, Event $queueForEvents, Database $dbForProject, Response $response) {
|
||||
$provider = $dbForProject->getDocument('providers', $providerId);
|
||||
|
||||
if ($provider->isEmpty()) {
|
||||
|
@ -1352,14 +1351,12 @@ App::patch('/v1/messaging/providers/msg91/:providerId')
|
|||
$provider->setAttribute('name', $name);
|
||||
}
|
||||
|
||||
if (!empty($from)) {
|
||||
$provider->setAttribute('options', [
|
||||
'from' => $from,
|
||||
]);
|
||||
}
|
||||
|
||||
$credentials = $provider->getAttribute('credentials');
|
||||
|
||||
if (!empty($templateId)) {
|
||||
$credentials['templateId'] = $templateId;
|
||||
}
|
||||
|
||||
if (!empty($senderId)) {
|
||||
$credentials['senderId'] = $senderId;
|
||||
}
|
||||
|
@ -1375,7 +1372,7 @@ App::patch('/v1/messaging/providers/msg91/:providerId')
|
|||
if (
|
||||
\array_key_exists('senderId', $credentials) &&
|
||||
\array_key_exists('authKey', $credentials) &&
|
||||
\array_key_exists('from', $provider->getAttribute('options'))
|
||||
\array_key_exists('templateId', $credentials)
|
||||
) {
|
||||
$provider->setAttribute('enabled', true);
|
||||
} else {
|
||||
|
|
|
@ -409,7 +409,8 @@ class Messaging extends Action
|
|||
],
|
||||
'msg91' => [
|
||||
'senderId' => $user,
|
||||
'authKey' => $password
|
||||
'authKey' => $password,
|
||||
'templateId' => $smsDSN->getParam('templateId'),
|
||||
],
|
||||
'vonage' => [
|
||||
'apiKey' => $user,
|
||||
|
|
|
@ -1852,8 +1852,8 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$CREATE_MSG91_PROVIDER:
|
||||
return 'mutation createMsg91Provider($providerId: String!, $name: String!, $from: String!, $senderId: String!, $authKey: String!, $enabled: Boolean) {
|
||||
messagingCreateMsg91Provider(providerId: $providerId, name: $name, from: $from, senderId: $senderId, authKey: $authKey, enabled: $enabled) {
|
||||
return 'mutation createMsg91Provider($providerId: String!, $name: String!, $templateId: String!, $senderId: String!, $authKey: String!, $enabled: Boolean) {
|
||||
messagingCreateMsg91Provider(providerId: $providerId, name: $name, templateId: $templateId, senderId: $senderId, authKey: $authKey, enabled: $enabled) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
|
@ -1976,8 +1976,8 @@ trait Base
|
|||
}
|
||||
}';
|
||||
case self::$UPDATE_MSG91_PROVIDER:
|
||||
return 'mutation updateMsg91Provider($providerId: String!, $name: String!, $senderId: String!, $authKey: String!) {
|
||||
messagingUpdateMsg91Provider(providerId: $providerId, name: $name, senderId: $senderId, authKey: $authKey) {
|
||||
return 'mutation updateMsg91Provider($providerId: String!, $name: String!, $templateId: String!, $senderId: String!, $authKey: String!) {
|
||||
messagingUpdateMsg91Provider(providerId: $providerId, name: $name, templateId: $templateId, senderId: $senderId, authKey: $authKey) {
|
||||
_id
|
||||
name
|
||||
provider
|
||||
|
|
|
@ -71,7 +71,7 @@ trait MessagingBase
|
|||
'name' => 'Ms91-1',
|
||||
'senderId' => 'my-senderid',
|
||||
'authKey' => 'my-authkey',
|
||||
'from' => '+123456789'
|
||||
'templateId' => '123456'
|
||||
],
|
||||
'vonage' => [
|
||||
'providerId' => ID::unique(),
|
||||
|
@ -1376,9 +1376,9 @@ trait MessagingBase
|
|||
|
||||
$smsDSN = new DSN(App::getEnv('_APP_MESSAGE_SMS_TEST_DSN'));
|
||||
$to = $smsDSN->getParam('to');
|
||||
$from = $smsDSN->getParam('from');
|
||||
$senderId = $smsDSN->getUser();
|
||||
$authKey = $smsDSN->getPassword();
|
||||
$templateId = $smsDSN->getParam('templateId');
|
||||
|
||||
if (empty($to) || empty($from) || empty($senderId) || empty($authKey)) {
|
||||
$this->markTestSkipped('SMS provider not configured');
|
||||
|
@ -1394,7 +1394,7 @@ trait MessagingBase
|
|||
'name' => 'Msg91Sender',
|
||||
'senderId' => $senderId,
|
||||
'authKey' => $authKey,
|
||||
'from' => $from,
|
||||
'templateId' => $templateId,
|
||||
'enabled' => true,
|
||||
]);
|
||||
|
||||
|
|
Loading…
Reference in a new issue