Add uid for uniq identification by adapter of a sended sms. Usefull for tracking status

This commit is contained in:
osaajani 2020-01-06 23:35:55 +01:00
parent d8839a57d0
commit 89459a0285
5 changed files with 58 additions and 10 deletions

View File

@ -51,9 +51,9 @@
* @param string $destination : Phone number to send the sms to
* @param string $text : Text of the SMS to send
* @param bool $flash : Is the SMS a Flash SMS
* @return bool : True if send, False else
* @return mixed Uid of the sended message if send, False else
*/
public function send (string $destination, string $text, boolean $flash) : boolean;
public function send (string $destination, string $text, boolean $flash) : mixed;
/**

View File

@ -66,11 +66,11 @@
* @param string $destination : Phone number to send the sms to
* @param string $text : Text of the SMS to send
* @param bool $flash : Is the SMS a Flash SMS
* @return bool : True if send, False else
* @return mixed Uid of the sended message if send, False else
*/
public function send (string $destination, string $text, boolean $flash) : boolean
public function send (string $destination, string $text, boolean $flash) : mixed
{
return true;
return uniqid();
}

View File

@ -66,11 +66,11 @@
* @param string $destination : Phone number to send the sms to
* @param string $text : Text of the SMS to send
* @param bool $flash : Is the SMS a Flash SMS
* @return bool : True if send, False else
* @return mixed Uid of the sended message if send, False else
*/
public function send (string $destination, string $text, boolean $flash) : boolean
public function send (string $destination, string $text, boolean $flash) : mixed
{
return true;
return uniqid();
}

View File

@ -31,17 +31,21 @@ namespace controllers\internals;
* @param $text : Text of the message
* @param string $origin : Number of the sender
* @param string $destination : Number of the receiver
* @param string $uid : Uid of the sms on the adapter service used
* @param string $adapter : Name of the adapter service used to send the message
* @param bool $flash : Is the sms a flash
* @param string $status : Status of a the sms. By default 'unknown'
* @return bool : false on error, new sended id else
*/
public function create ($at, string $text, string $origin, string $destination, bool $flash = false, ?string $status = 'unknown') : bool
public function create ($at, string $text, string $origin, string $destination, string $uid, string $adapter, bool $flash = false, ?string $status = 'unknown') : bool
{
$sended = [
'at' => $at,
'text' => $text,
'origin' => $origin,
'destination' => $destination,
'uid' => $uid,
'adapter' => $adapter,
'flash' => $flash,
'status' => $status,
];
@ -58,17 +62,21 @@ namespace controllers\internals;
* @param $text : Text of the message
* @param string $origin : Number of the sender
* @param string $destination : Number of the receiver
* @param string $uid : Uid of the sms on the adapter service used
* @param string $adapter : Name of the adapter service used to send the message
* @param bool $flash : Is the sms a flash
* @param ?string $status : Status of a the sms. By default null -> unknown
* @return bool : false on error, true on success
*/
public function update_for_user (int $id_user, int $id_sended, $at, string $text, string $origin, string $destination, bool $flash = false, ?string $status = null) : bool
public function update_for_user (int $id_user, int $id_sended, $at, string $text, string $origin, string $destination, string $uid, string $adapter, bool $flash = false, ?string $status = null) : bool
{
$sended = [
'at' => $at,
'text' => $text,
'origin' => $origin,
'destination' => $destination,
'uid' => $uid,
'adapter' => $adapter,
'flash' => $flash,
'status' => $status,
];

View File

@ -0,0 +1,40 @@
<?php
use Phinx\Migration\AbstractMigration;
class AddSenderAndUidForSended extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* addCustomColumn
* renameColumn
* addIndex
* addForeignKey
*
* Any other destructive changes will result in an error when trying to
* rollback the migration.
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$table = $this->table('sended');
$table->addColumn('uid', 'string', ['limit' => 500])
->addColumn('adapter', 'string', ['limit' => 50])
->update();
}
}