Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moving to vonage from nexmo #5492

Merged
merged 5 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
}
}
}