mirror of
https://github.com/nullthoughts/laravel-data-sync.git
synced 2026-03-17 19:05:39 +00:00
Initial commit
This commit is contained in:
21
vendor/laravel/nexmo-notification-channel/LICENSE.txt
vendored
Normal file
21
vendor/laravel/nexmo-notification-channel/LICENSE.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) <Taylor Otwell>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
46
vendor/laravel/nexmo-notification-channel/composer.json
vendored
Normal file
46
vendor/laravel/nexmo-notification-channel/composer.json
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "laravel/nexmo-notification-channel",
|
||||
"description": "Nexmo Notification Channel for laravel.",
|
||||
"keywords": ["laravel", "notifications", "nexmo"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"nexmo/client": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"illuminate/notifications": "~5.7",
|
||||
"mockery/mockery": "^1.0",
|
||||
"phpunit/phpunit": "^7.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Notifications\\": "src/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Tests\\Notifications\\": "tests/"
|
||||
}
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
},
|
||||
"laravel": {
|
||||
"providers": [
|
||||
"Illuminate\\Notifications\\NexmoChannelServiceProvider"
|
||||
]
|
||||
}
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": true
|
||||
}
|
||||
0
vendor/laravel/nexmo-notification-channel/readme.md
vendored
Normal file
0
vendor/laravel/nexmo-notification-channel/readme.md
vendored
Normal file
64
vendor/laravel/nexmo-notification-channel/src/Channels/NexmoSmsChannel.php
vendored
Normal file
64
vendor/laravel/nexmo-notification-channel/src/Channels/NexmoSmsChannel.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Channels;
|
||||
|
||||
use Nexmo\Client as NexmoClient;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
|
||||
class NexmoSmsChannel
|
||||
{
|
||||
/**
|
||||
* The Nexmo client instance.
|
||||
*
|
||||
* @var \Nexmo\Client
|
||||
*/
|
||||
protected $nexmo;
|
||||
|
||||
/**
|
||||
* The phone number notifications should be sent from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $from;
|
||||
|
||||
/**
|
||||
* Create a new Nexmo channel instance.
|
||||
*
|
||||
* @param \Nexmo\Client $nexmo
|
||||
* @param string $from
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(NexmoClient $nexmo, $from)
|
||||
{
|
||||
$this->from = $from;
|
||||
$this->nexmo = $nexmo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the given notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @param \Illuminate\Notifications\Notification $notification
|
||||
* @return \Nexmo\Message\Message
|
||||
*/
|
||||
public function send($notifiable, Notification $notification)
|
||||
{
|
||||
if (! $to = $notifiable->routeNotificationFor('nexmo', $notification)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = $notification->toNexmo($notifiable);
|
||||
|
||||
if (is_string($message)) {
|
||||
$message = new NexmoMessage($message);
|
||||
}
|
||||
|
||||
return $this->nexmo->message()->send([
|
||||
'type' => $message->type,
|
||||
'from' => $message->from ?: $this->from,
|
||||
'to' => $to,
|
||||
'text' => trim($message->content),
|
||||
]);
|
||||
}
|
||||
}
|
||||
76
vendor/laravel/nexmo-notification-channel/src/Messages/NexmoMessage.php
vendored
Normal file
76
vendor/laravel/nexmo-notification-channel/src/Messages/NexmoMessage.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications\Messages;
|
||||
|
||||
class NexmoMessage
|
||||
{
|
||||
/**
|
||||
* The message content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $content;
|
||||
|
||||
/**
|
||||
* The phone number the message should be sent from.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $from;
|
||||
|
||||
/**
|
||||
* The message type.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $type = 'text';
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param string $content
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($content = '')
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message content.
|
||||
*
|
||||
* @param string $content
|
||||
* @return $this
|
||||
*/
|
||||
public function content($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the phone number the message should be sent from.
|
||||
*
|
||||
* @param string $from
|
||||
* @return $this
|
||||
*/
|
||||
public function from($from)
|
||||
{
|
||||
$this->from = $from;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message type.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function unicode()
|
||||
{
|
||||
$this->type = 'unicode';
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
29
vendor/laravel/nexmo-notification-channel/src/NexmoChannelServiceProvider.php
vendored
Normal file
29
vendor/laravel/nexmo-notification-channel/src/NexmoChannelServiceProvider.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Illuminate\Notifications;
|
||||
|
||||
use Nexmo\Client as NexmoClient;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Nexmo\Client\Credentials\Basic as NexmoCredentials;
|
||||
|
||||
class NexmoChannelServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
Notification::extend('nexmo', function ($app) {
|
||||
return new Channels\NexmoSmsChannel(
|
||||
new NexmoClient(new NexmoCredentials(
|
||||
$this->app['config']['services.nexmo.key'],
|
||||
$this->app['config']['services.nexmo.secret']
|
||||
)),
|
||||
$this->app['config']['services.nexmo.sms_from']
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user