mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
rename all instances of 'datas' to 'data'
This commit is contained in:
parent
730ac8963b
commit
61d644c247
48 changed files with 316 additions and 316 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue