rename all instances of 'datas' to 'data'

This commit is contained in:
osaajani 2021-01-17 03:16:57 +01:00
parent 730ac8963b
commit 61d644c247
48 changed files with 316 additions and 316 deletions

View file

@ -23,9 +23,9 @@ namespace adapters;
/**
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas);
public function __construct(string $data);
/**
* Classname of the adapter.
@ -51,11 +51,11 @@ namespace adapters;
public static function meta_description(): string;
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Eachline line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array;
public static function meta_data_fields(): array;
/**
* Does the implemented service support flash smss.

View file

@ -21,9 +21,9 @@ namespace adapters;
class BenchmarkAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* API URL.
@ -33,11 +33,11 @@ namespace adapters;
/**
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = $datas;
$this->data = $data;
}
/**
@ -76,11 +76,11 @@ namespace adapters;
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Eachline line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [];
}
@ -140,7 +140,7 @@ namespace adapters;
try
{
$datas = [
$data = [
'sms_text' => $text,
'sms_destination' => $destination,
'sms_flash' => $flash,
@ -153,7 +153,7 @@ namespace adapters;
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($datas));
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
$curl_response = curl_exec($curl);
curl_close($curl);

View file

@ -21,18 +21,18 @@ namespace adapters;
class GammuAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
}
/**
@ -73,11 +73,11 @@ namespace adapters;
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[
@ -159,7 +159,7 @@ namespace adapters;
$command_parts = [
'gammu',
'--config',
escapeshellarg($this->datas['config_file']),
escapeshellarg($this->data['config_file']),
'sendsms',
'TEXT',
escapeshellarg($destination),
@ -248,7 +248,7 @@ namespace adapters;
$command_parts = [
PWD . '/bin/gammu_get_unread_sms.py',
escapeshellarg($this->datas['config_file']),
escapeshellarg($this->data['config_file']),
];
$return = $this->exec_command($command_parts);
@ -326,7 +326,7 @@ namespace adapters;
*/
private function unlock_sim(): bool
{
if (!$this->datas['pin'])
if (!$this->data['pin'])
{
return true;
}
@ -334,10 +334,10 @@ namespace adapters;
$command_parts = [
'gammu',
'--config',
escapeshellarg($this->datas['config_file']),
escapeshellarg($this->data['config_file']),
'entersecuritycode',
'PIN',
escapeshellarg($this->datas['pin']),
escapeshellarg($this->data['pin']),
];
$result = $this->exec_command($command_parts);
@ -346,7 +346,7 @@ namespace adapters;
$command_parts = [
'gammu',
'--config',
escapeshellarg($this->datas['config_file']),
escapeshellarg($this->data['config_file']),
'getsecuritystatus',
];

View file

@ -22,9 +22,9 @@ class OctopushShortcodeAdapter implements AdapterInterface
const SMS_TYPE_INTERNATIONAL = 'WWW';
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* Octopush login.
@ -50,15 +50,15 @@ class OctopushShortcodeAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
$this->login = $this->datas['login'];
$this->api_key = $this->datas['api_key'];
$this->sender = $this->datas['sender'] ?? null;
$this->login = $this->data['login'];
$this->api_key = $this->data['api_key'];
$this->sender = $this->data['sender'] ?? null;
}
/**
@ -102,11 +102,11 @@ class OctopushShortcodeAdapter implements AdapterInterface
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[
@ -187,7 +187,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
try
{
$datas = [
$data = [
'user_login' => $this->login,
'api_key' => $this->api_key,
'sms_text' => $text,
@ -198,7 +198,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
if (null !== $this->sender)
{
$datas['sms_sender'] = $this->sender;
$data['sms_sender'] = $this->sender;
}
$endpoint = $this->api_url . '/sms/json';
@ -208,7 +208,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
@ -285,12 +285,12 @@ class OctopushShortcodeAdapter implements AdapterInterface
{
$success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11)))
if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{
return false;
}
$datas = [
$data = [
'user_login' => $this->login,
'api_key' => $this->api_key,
];
@ -302,7 +302,7 @@ class OctopushShortcodeAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);

View file

@ -22,9 +22,9 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
const SMS_TYPE_INTERNATIONAL = 'WWW';
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* Octopush login.
@ -55,16 +55,16 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
$this->login = $this->datas['login'];
$this->api_key = $this->datas['api_key'];
$this->number = $this->datas['number'];
$this->formatted_number = '+' . mb_substr($this->datas['number'], 2);
$this->login = $this->data['login'];
$this->api_key = $this->data['api_key'];
$this->number = $this->data['number'];
$this->formatted_number = '+' . mb_substr($this->data['number'], 2);
}
/**
@ -108,11 +108,11 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[
@ -192,7 +192,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
try
{
$datas = [
$data = [
'user_login' => $this->login,
'api_key' => $this->api_key,
'sms_text' => $text,
@ -208,7 +208,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);
@ -285,12 +285,12 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
{
$success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11)))
if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{
return false;
}
$datas = [
$data = [
'user_login' => $this->login,
'api_key' => $this->api_key,
];
@ -302,7 +302,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $datas);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($curl);
curl_close($curl);

View file

@ -19,9 +19,9 @@ namespace adapters;
class OvhSmsShortcodeAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* OVH Api instance.
@ -32,17 +32,17 @@ namespace adapters;
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
$this->api = new Api(
$this->datas['app_key'],
$this->datas['app_secret'],
$this->data['app_key'],
$this->data['app_secret'],
'ovh-eu',
$this->datas['consumer_key']
$this->data['consumer_key']
);
}
@ -87,11 +87,11 @@ namespace adapters;
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[
@ -186,16 +186,16 @@ namespace adapters;
{
$success = true;
$endpoint = '/sms/' . $this->datas['service_name'] . '/jobs';
$endpoint = '/sms/' . $this->data['service_name'] . '/jobs';
$params = [
'message' => $text,
'receivers' => [$destination],
'senderForResponse' => true,
];
if ($this->datas['sender'])
if ($this->data['sender'])
{
$params['sender'] = $this->datas['sender'];
$params['sender'] = $this->data['sender'];
$params['senderForResponse'] = false;
}
@ -252,12 +252,12 @@ namespace adapters;
try
{
//If we use a sender we cannot receive response, no need to make queries
if ($this->datas['sended'])
if ($this->data['sended'])
{
return $response;
}
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming';
$endpoint = '/sms/' . $this->data['service_name'] . '/incoming';
$uids = $this->api->get($endpoint);
if (!\is_array($uids) || !$uids)
@ -267,7 +267,7 @@ namespace adapters;
foreach ($uids as $uid)
{
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming/' . $uid;
$endpoint = '/sms/' . $this->data['service_name'] . '/incoming/' . $uid;
$sms_details = $this->api->get($endpoint);
if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender']))
@ -282,7 +282,7 @@ namespace adapters;
];
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
$endpoint = '/sms/' . $this->datas['service_name'] . '/incoming/' . $uid;
$endpoint = '/sms/' . $this->data['service_name'] . '/incoming/' . $uid;
$this->api->delete($endpoint);
}
@ -309,13 +309,13 @@ namespace adapters;
{
$success = true;
if ($this->datas['sender'] && (mb_strlen($this->datas['sender']) < 3 || mb_strlen($this->datas['sender'] > 11)))
if ($this->data['sender'] && (mb_strlen($this->data['sender']) < 3 || mb_strlen($this->data['sender'] > 11)))
{
return false;
}
//Check service name
$endpoint = '/sms/' . $this->datas['service_name'];
$endpoint = '/sms/' . $this->data['service_name'];
$response = $this->api->get($endpoint);
return $success && (bool) $response;

View file

@ -19,9 +19,9 @@ namespace adapters;
class OvhSmsVirtualNumberAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* OVH Api instance.
@ -41,20 +41,20 @@ namespace adapters;
/**
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
$this->api = new Api(
$this->datas['app_key'],
$this->datas['app_secret'],
$this->data['app_key'],
$this->data['app_secret'],
'ovh-eu',
$this->datas['consumer_key']
$this->data['consumer_key']
);
$this->number = $this->datas['number'];
$this->number = $this->data['number'];
$this->formatted_number = str_replace('+', '00', $this->number);
}
@ -99,11 +99,11 @@ namespace adapters;
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[
@ -197,7 +197,7 @@ namespace adapters;
{
$success = true;
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/jobs';
$endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/jobs';
$params = [
'message' => $text,
'receivers' => [$destination],
@ -255,7 +255,7 @@ namespace adapters;
try
{
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming';
$endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming';
$uids = $this->api->get($endpoint);
if (!\is_array($uids) || !$uids)
@ -265,7 +265,7 @@ namespace adapters;
foreach ($uids as $uid)
{
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$sms_details = $this->api->get($endpoint);
if (!isset($sms_details['creationDatetime'], $sms_details['message'], $sms_details['sender']))
@ -280,7 +280,7 @@ namespace adapters;
];
//Remove the sms to prevent double reading as ovh do not offer a filter for unread messages only
$endpoint = '/sms/' . $this->datas['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$endpoint = '/sms/' . $this->data['service_name'] . '/virtualNumbers/' . $this->formatted_number . '/incoming/' . $uid;
$this->api->delete($endpoint);
}
@ -309,7 +309,7 @@ namespace adapters;
$success = true;
//Check service name
$endpoint = '/sms/' . $this->datas['service_name'];
$endpoint = '/sms/' . $this->data['service_name'];
$response = $this->api->get($endpoint);
$success = $success && (bool) $response;

View file

@ -21,28 +21,28 @@ namespace adapters;
class TestAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* Path for the file to read sms as a json from.
*/
private $test_file_read = PWD_DATAS . '/test_read_sms.json';
private $test_file_read = PWD_DATA . '/test_read_sms.json';
/**
* Path for the file to write sms as a json in.
*/
private $test_file_write = PWD_DATAS . '/test_write_sms.json';
private $test_file_write = PWD_DATA . '/test_write_sms.json';
/**
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = $datas;
$this->data = $data;
}
/**
@ -81,11 +81,11 @@ namespace adapters;
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Eachline line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [];
}

View file

@ -19,9 +19,9 @@ use Twilio\Rest\Client;
class TwilioVirtualNumberAdapter implements AdapterInterface
{
/**
* Datas used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
* Data used to configure interaction with the implemented service. (e.g : Api credentials, ports numbers, etc.).
*/
private $datas;
private $data;
/**
* Twilio Api client.
@ -42,19 +42,19 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
* Adapter constructor, called when instanciated by RaspiSMS.
*
* @param string $number : Phone number the adapter is used for
* @param json string $datas : JSON string of the datas to configure interaction with the implemented service
* @param json string $data : JSON string of the data to configure interaction with the implemented service
*/
public function __construct(string $datas)
public function __construct(string $data)
{
$this->datas = json_decode($datas, true);
$this->data = json_decode($data, true);
$this->client = new Client(
$this->datas['account_sid'],
$this->datas['auth_token']
$this->data['account_sid'],
$this->data['auth_token']
);
$this->number = $this->datas['number'];
$this->status_change_callback = $this->datas['status_change_callback'];
$this->number = $this->data['number'];
$this->status_change_callback = $this->data['status_change_callback'];
}
/**
@ -98,11 +98,11 @@ class TwilioVirtualNumberAdapter implements AdapterInterface
}
/**
* List of entries we want in datas for the adapter.
* List of entries we want in data for the adapter.
*
* @return array : Every line is a field as an array with keys : name, title, description, required
*/
public static function meta_datas_fields(): array
public static function meta_data_fields(): array
{
return [
[