mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
use correct model and fix style
This commit is contained in:
parent
e21b89cc7c
commit
e957c9feb7
29 changed files with 105 additions and 111 deletions
|
@ -35,7 +35,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
private $api_key;
|
||||
|
||||
/**
|
||||
* Octopush SMS type
|
||||
* Octopush SMS type.
|
||||
*/
|
||||
private $sms_type;
|
||||
|
||||
|
@ -45,11 +45,10 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
private $api_url = 'https://api.octopush.com/v1/public';
|
||||
|
||||
/**
|
||||
* Octopush phone number
|
||||
* Octopush phone number.
|
||||
*/
|
||||
private $number;
|
||||
|
||||
|
||||
/**
|
||||
* Adapter constructor, called when instanciated by RaspiSMS.
|
||||
*
|
||||
|
@ -65,7 +64,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
$this->number = $this->data['number'];
|
||||
|
||||
$this->sms_type = self::SMS_TYPE_LOWCOST;
|
||||
if (($this->data['sms_type'] ?? false) && $this->data['sms_type'] === 'premium')
|
||||
if (($this->data['sms_type'] ?? false) && 'premium' === $this->data['sms_type'])
|
||||
{
|
||||
$this->sms_type = self::SMS_TYPE_PREMIUM;
|
||||
}
|
||||
|
@ -118,7 +117,6 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
Envoi de SMS avec un numéro virtuel en utilisant <a target="_blank" href="https://www.octopush.com/">Octopush</a>. Pour trouver vos clés API Octopush <a target="_blank" href="' . $credentials_url . '">cliquez ici.</a><br/>
|
||||
Pour plus d\'information sur l\'utilisation de ce téléphone, reportez-vous à <a href="https://documentation.raspisms.fr/users/adapters/octopush_virtual_number.html" target="_blank">la documentation sur les téléphones "Octopush Numéro Virtuel".</a>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -154,7 +152,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
'description' => 'Type de SMS à employer coté Octopush, rentrez "low cost" ou "premium" selon le type de SMS que vous souhaitez employer. Laissez vide pour utiliser par défaut des SMS low cost.',
|
||||
'required' => false,
|
||||
],
|
||||
];
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,16 +231,15 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
|
||||
$data = [
|
||||
'text' => $text,
|
||||
'recipients' => [['phone_number' => $destination]],
|
||||
'recipients' => [['phone_number' => $destination]],
|
||||
'sms_type' => $this->sms_type,
|
||||
'purpose' => 'alert',
|
||||
'sender' => $this->number,
|
||||
'with_replies' => "True",
|
||||
'with_replies' => 'True',
|
||||
];
|
||||
|
||||
$data = json_encode($data);
|
||||
|
||||
|
||||
$endpoint = $this->api_url . '/sms-campaign/send';
|
||||
|
||||
$curl = curl_init();
|
||||
|
@ -252,7 +249,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
|
||||
|
||||
$curl_response = curl_exec($curl);
|
||||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
|
@ -325,7 +322,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$headers = [
|
||||
'api-login: ' . $this->login,
|
||||
'api-key: ' . $this->api_key,
|
||||
|
@ -343,7 +340,7 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
$http_code = (int) curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
||||
curl_close($curl);
|
||||
|
||||
if ($http_code !== 200)
|
||||
if (200 !== $http_code)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -362,14 +359,13 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
header('Content-Encoding: none');
|
||||
header('Content-Length: 0');
|
||||
|
||||
|
||||
$input = file_get_contents('php://input');
|
||||
$content = json_decode($input, true);
|
||||
if (null === $content)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
$uid = $content['message_id'] ?? false;
|
||||
$status = $content['status'] ?? false;
|
||||
|
||||
|
@ -378,7 +374,6 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
switch ($status)
|
||||
{
|
||||
case 'DELIVERED':
|
||||
|
@ -413,14 +408,14 @@ class OctopushVirtualNumberAdapter implements AdapterInterface
|
|||
header('Connection: close');
|
||||
header('Content-Encoding: none');
|
||||
header('Content-Length: 0');
|
||||
|
||||
|
||||
$input = file_get_contents('php://input');
|
||||
$content = json_decode($input, true);
|
||||
if (null === $content)
|
||||
{
|
||||
$response['error'] = true;
|
||||
$response['error_message'] = 'Cannot read input data from callback request.';
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue