generated from laravel-notification-channels/skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d3686f
commit 456af6c
Showing
17 changed files
with
394 additions
and
243 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ composer.phar | |
composer.lock | ||
.DS_Store | ||
.phpunit.result.cache | ||
.idea |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) :author_name <:author_email> | ||
Copyright (c) René Roscher <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,91 @@ | ||
Please see [this repo](https://github.com/laravel-notification-channels/channels) for instructions on how to submit a channel proposal. | ||
|
||
# A Boilerplate repo for contributions | ||
|
||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/:package_name.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/:package_name) | ||
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) | ||
[![Build Status](https://img.shields.io/travis/laravel-notification-channels/:package_name/master.svg?style=flat-square)](https://travis-ci.org/laravel-notification-channels/:package_name) | ||
[![StyleCI](https://styleci.io/repos/:style_ci_id/shield)](https://styleci.io/repos/:style_ci_id) | ||
[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/:sensio_labs_id.svg?style=flat-square)](https://insight.sensiolabs.com/projects/:sensio_labs_id) | ||
[![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/:package_name.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/:package_name) | ||
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/:package_name/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/:package_name/?branch=master) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/:package_name.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/:package_name) | ||
|
||
This package makes it easy to send notifications using [:service_name](link to service) with Laravel 5.5+, 6.x and 7.x | ||
|
||
**Note:** Replace ```:channel_namespace``` ```:service_name``` ```:author_name``` ```:author_username``` ```:author_website``` ```:author_email``` ```:package_name``` ```:package_description``` ```:style_ci_id``` ```:sensio_labs_id``` with their correct values in [README.md](README.md), [CHANGELOG.md](CHANGELOG.md), [CONTRIBUTING.md](CONTRIBUTING.md), [LICENSE.md](LICENSE.md), [composer.json](composer.json) and other files, then delete this line. | ||
**Tip:** Use "Find in Path/Files" in your code editor to find these keywords within the package directory and replace all occurences with your specified term. | ||
|
||
This is where your description should go. Add a little code example so build can understand real quick how the package can be used. Try and limit it to a paragraph or two. | ||
|
||
|
||
|
||
## Contents | ||
|
||
- [Installation](#installation) | ||
- [Setting up the :service_name service](#setting-up-the-:service_name-service) | ||
- [Usage](#usage) | ||
- [Available Message methods](#available-message-methods) | ||
- [Changelog](#changelog) | ||
- [Testing](#testing) | ||
- [Security](#security) | ||
- [Contributing](#contributing) | ||
- [Credits](#credits) | ||
- [License](#license) | ||
# Laravel ClickSend Notification Channel | ||
|
||
This Laravel package integrates ClickSend for sending SMS and voice messages within Laravel applications, leveraging ClickSend's capabilities for notifications. | ||
|
||
## Installation | ||
|
||
Please also include the steps for any third-party service setup that's required for this package. | ||
|
||
### Setting up the :service_name service | ||
|
||
Optionally include a few steps how users can set up the service. | ||
|
||
## Usage | ||
|
||
Some code examples, make it clear how to use the package | ||
|
||
### Available Message methods | ||
|
||
A list of all available options | ||
|
||
## Changelog | ||
Install via composer: | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. | ||
|
||
## Testing | ||
|
||
``` bash | ||
$ composer test | ||
``` | ||
composer require rene-roscher/clicksend-laravel | ||
``` | ||
|
||
## Security | ||
## Configuration | ||
|
||
If you discover any security related issues, please email :author_email instead of using the issue tracker. | ||
Add ClickSend credentials in `.env` and in `config/services.php`: | ||
|
||
## Contributing | ||
.env | ||
``` | ||
CLICKSEND_USERNAME=username | ||
CLICKSEND_PASSWORD=password | ||
``` | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
config/services.php | ||
``` | ||
'clicksend' => [ | ||
'username' => env('CLICKSEND_USERNAME'), | ||
'password' => env('CLICKSEND_PASSWORD'), | ||
], | ||
``` | ||
|
||
## Credits | ||
## Usage | ||
|
||
- [:author_name](https://github.com/:author_username) | ||
- [All Contributors](../../contributors) | ||
### SMS Notification | ||
|
||
Simply create a new notification and use the preferred class to send a notification. | ||
|
||
Note: Make sure to replace all spaces in the phone number with an empty string. | ||
|
||
```php | ||
class TestNotificationClickSend extends Notification | ||
{ | ||
/** | ||
* Get the notification's delivery channels. | ||
* | ||
* @return array<int, string> | ||
*/ | ||
public function via(object $notifiable): array | ||
{ | ||
return ['clicksend-voice', 'clicksend-sms']; // All channels are automatically registered by default | ||
} | ||
|
||
/** | ||
* Get the mail representation of the notification. | ||
*/ | ||
public function toClicksendVoice(object $notifiable) // Voice | ||
{ | ||
return ClickSendVoiceMessage::create( | ||
message: 'Your Verification Code is: 1234 - I repeat: 1234 - Goodbye!', | ||
to: $notifiable->phone_number | ||
); | ||
// Or | ||
return 'Your Verification Code is: 1234 - I repeat: 1234 - Goodbye!'; | ||
} | ||
|
||
public function toClicksendSms(object $notifiable) // SMS | ||
{ | ||
// Default | ||
return ClickSendSmsMessage::create( | ||
message: 'Your Verification was approved. Thank you! 🎉', | ||
to: $notifiable->phone_number | ||
); | ||
|
||
// Or a single message | ||
return 'Your Verification was approved. Thank you! 🎉'; | ||
|
||
// Or multiple messages at once | ||
return ClickSendSmsMessage::create( | ||
message: 'Your Verification was approved. Thank you! 🎉', | ||
to: $notifiable->phone_number | ||
)->addMessage( | ||
message: 'Welcome to our platform! 🎉', | ||
to: $notifiable->phone_number | ||
); | ||
} | ||
|
||
} | ||
``` | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
Licensed under the MIT license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
{ | ||
"name": "laravel-notification-channels/:package_name", | ||
"description": ":package_description", | ||
"homepage": "https://github.com/laravel-notification-channels/:package_name", | ||
"name": "rene-roscher/clicksend-laravel", | ||
"description": "A Laravel package to create SMS messages & Voice calls using ClickSend", | ||
"homepage": "https://github.com/rene-roscher/clicksend-laravel", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": ":author_name", | ||
"email": ":author_email", | ||
"homepage": ":author_website", | ||
"name": "René Roscher", | ||
"email": "[email protected]", | ||
"homepage": "https://livck.com", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.2", | ||
"illuminate/notifications": "~6.0 || ~7.0 || ~8.0", | ||
"illuminate/support": "~6.0 || ~7.0 || ~8.0" | ||
"php": ">=8.2", | ||
"illuminate/notifications": "~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0 || ~10.0", | ||
"illuminate/support": "~5.0 || ~6.0 || ~7.0 || ~8.0 || ~9.0 || ~10.0", | ||
"clicksend/clicksend-php": "^5.0" | ||
}, | ||
"require-dev": { | ||
"mockery/mockery": "^1.0", | ||
"phpunit/phpunit": "^9.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"NotificationChannels\\:channel_namespace\\": "src" | ||
"NotificationChannels\\ClickSend\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"NotificationChannels\\:channel_namespace\\Test\\": "tests" | ||
"NotificationChannels\\ClickSend\\Test\\": "tests" | ||
} | ||
}, | ||
"scripts": { | ||
|
@@ -36,5 +37,12 @@ | |
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"NotificationChannels\\ClickSend\\ClickSendServiceProvider" | ||
] | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace NotificationChannels\ClickSend; | ||
|
||
use ClickSend\Configuration; | ||
use Illuminate\Support\Facades\Notification; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class ClickSendServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap the application services. | ||
*/ | ||
public function boot() | ||
{ | ||
$this->app->singleton(Configuration::class, function ($app) { | ||
$config = $app['config']['services.clicksend']; | ||
|
||
if (empty($config['username']) && empty($config['api_key'])) { | ||
throw new \InvalidArgumentException('ClickSend configuration requires either "username" and "password" or "api_key".'); | ||
} | ||
|
||
$configuration = new Configuration(); | ||
|
||
if (!empty($config['username']) && !empty($config['password'])) { | ||
$configuration->setUsername($config['username']) | ||
->setPassword($config['password']); | ||
} | ||
|
||
if (!empty($config['api_key'])) { | ||
$configuration->setApiKey('Authorization', 'Bearer ' . $config['api_key']); | ||
} | ||
|
||
return $configuration; | ||
}); | ||
|
||
// Extending Laravel's Notification Channels | ||
Notification::extend('clicksend-sms', function ($app) { | ||
return $app->make(ClickSendSmsChannel::class); | ||
}); | ||
Notification::extend('clicksend-voice', function ($app) { | ||
return $app->make(ClickSendVoiceChannel::class); | ||
}); | ||
} | ||
|
||
/** | ||
* Register the application services. | ||
*/ | ||
public function register() | ||
{ | ||
} | ||
} |
Oops, something went wrong.