Skip to content

Commit

Permalink
Merge pull request #5492 from ChurchCRM/build/vonage-sms
Browse files Browse the repository at this point in the history
moving to vonage from nexmo
  • Loading branch information
DawoudIO authored Nov 9, 2020
2 parents 26b50c4 + 09d9f26 commit a98ca7b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 34 deletions.
62 changes: 30 additions & 32 deletions src/ChurchCRM/dto/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,54 @@

namespace ChurchCRM\dto;

use ChurchCRM\Person;
use ChurchCRM\dto\SystemConfig;

use ChurchCRM\Emails\NotificationEmail;
use Nexmo\Client;
use Nexmo\Client\Credentials\Basic as NexmoBasicCred;
use ChurchCRM\dto\OpenLPNotification;
use Vonage\Client;
use Vonage\Client\Credentials\Basic;

class Notification
{

protected $projectorText;
protected $recipients;
protected $person;

public function __construct()
{

}

public function setRecipients($recipients)
{
$this->recipients = $recipients;

}

public function setSMSText($text)
{

}

public function setEmailText($text)
{

}

public function setPerson(\ChurchCRM\Person $Person)
{
$this->person = $Person;
}

public function setProjectorText($text)
{
$this->projectorText=$text;
}

private function sendEmail()
{
$emailaddresses = [];
Foreach ($this->recipients as $recipient)
{
{
array_push($emailaddresses,$recipient->getEmail());
}
try
Expand All @@ -62,19 +60,19 @@ private function sendEmail()
} catch (Exception $ex) {
return false;
}

}

private function sendSMS()
{
try
{
$client = new Client(New NexmoBasicCred(SystemConfig::getValue("sNexmoAPIKey"),SystemConfig::getValue("sNexmoAPISecret")));

$client = new Client(new Basic(SystemConfig::getValue("sNexmoAPIKey"),SystemConfig::getValue("sNexmoAPISecret")));

Foreach ($this->recipients as $recipient)
{
$message = $client->message()->send([
$message = $client->message()->sendText([
'to' => $recipient->getNumericCellPhone(),
'from' => SystemConfig::getValue("sNexmoFromNumber"),
'text' => gettext('Notification for') . " " . $this->person->getFullName()
Expand All @@ -84,9 +82,9 @@ private function sendSMS()
} catch (Exception $ex) {
return false;
}

}

private function sendProjector()
{
try
Expand All @@ -99,12 +97,12 @@ private function sendProjector()
} catch (Exception $ex) {
return false;
}

}

public function send()
{

$methods = [];
if(SystemConfig::hasValidMailServerSettings())
{
Expand All @@ -125,9 +123,9 @@ public function send()
"status"=>"",
"methods"=>$methods
];

return json_encode($sendStatus);

}

}
4 changes: 2 additions & 2 deletions src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"geocoder-php/google-maps-provider": "4.5.0",
"geocoder-php/bing-maps-provider": "4.0.0",
"mustache/mustache": "v2.13.0",
"nexmo/client": "@beta",
"vonage/client": "^2.4",
"slim/http-cache": "^1.0.0",
"azuyalabs/yasumi": "^1.8.1",
"defuse/php-encryption": "^2.2.1",
Expand All @@ -71,4 +71,4 @@
"type": "composer"
}
}
}
}

0 comments on commit a98ca7b

Please sign in to comment.