|
| 1 | +# ClickSend notifications channel for Laravel |
| 2 | +<!-- |
| 3 | +[](https://packagist.org/packages/laravel-notification-channels/clicksend) |
| 4 | +[](LICENSE.md) |
| 5 | +[](https://travis-ci.org/laravel-notification-channels/clicksend) |
| 6 | +[](https://styleci.io/repos/:style_ci_id) |
| 7 | +[](https://insight.sensiolabs.com/projects/:sensio_labs_id) |
| 8 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/clicksend) |
| 9 | +[](https://scrutinizer-ci.com/g/laravel-notification-channels/clicksend/?branch=master) |
| 10 | +[](https://packagist.org/packages/laravel-notification-channels/clicksend) |
| 11 | +--> |
| 12 | +This package makes it easy to send notification via [SMS using ClickSend API](https://developers.clicksend.com/docs/rest/v3/?php) with Laravel 5.5+, 6.x, 7.x, 8.x & 9.x |
| 13 | + |
| 14 | +## Contents |
| 15 | + |
| 16 | +- [Installation](#installation) |
| 17 | + - [Setting up a ClickSend account](#set-up-a-clicksend-account) |
| 18 | + - [Install the package via composer](#install-the-package-via-composer) |
| 19 | + - [Configuration env](#configuration-env) |
| 20 | +- [Usage](#usage) |
| 21 | + - [Available Message methods](#available-message-methods) |
| 22 | +- [Changelog](#changelog) |
| 23 | +- [Testing](#testing) |
| 24 | +- [Security](#security) |
| 25 | +- [Contributing](#contributing) |
| 26 | +- [Credits](#credits) |
| 27 | +- [License](#license) |
| 28 | + |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +### Set up a ClickSend account |
| 33 | + |
| 34 | +You'll need a ClickSend account. Head over to their [website](https://clicksend.com/) and create or login to your account. |
| 35 | + |
| 36 | +From the dashboard, in the sidebar... `Developers` then `API Credentials` to find your API credentials. |
| 37 | + |
| 38 | +### Install the package via composer |
| 39 | + |
| 40 | +```bash |
| 41 | +composer require laravel-notification-channels/clicksend |
| 42 | +``` |
| 43 | +### Configuration env |
| 44 | +Add your ClickSend API credentials to your .env file: |
| 45 | + |
| 46 | +```php |
| 47 | + |
| 48 | +CLICK_SEND_KEY=YOUR-API-KEY-FROM-CLICKSEND |
| 49 | +CLICK_SEND_FROM=8885551212 |
| 50 | +``` |
| 51 | +OR, use your ClickSend account credentials... |
| 52 | +```php |
| 53 | + |
| 54 | +CLICK_SEND_ACCOUNT_PASSWORD=your_clicksend_account_password |
| 55 | +CLICK_SEND_FROM=8885551212 |
| 56 | +``` |
| 57 | + |
| 58 | +## Usage |
| 59 | + |
| 60 | +You can use the channel in your `via()` method inside the notification: |
| 61 | + |
| 62 | +```php |
| 63 | +use Illuminate\Notifications\Notification; |
| 64 | +use \NotificationChannels\ClickSend\ClickSendMessage; |
| 65 | +use \NotificationChannels\ClickSend\ClickSendChannel; |
| 66 | + |
| 67 | +class AccountApproved extends Notification |
| 68 | +{ |
| 69 | + public function via($notifiable) |
| 70 | + { |
| 71 | + return [ClickSendChannel::class]; |
| 72 | + } |
| 73 | + |
| 74 | + public function toClickSend($notifiable) |
| 75 | + { |
| 76 | + return (new ClickSendMessage) |
| 77 | + ->content("{$notifiable->name}, your account was approved!"); |
| 78 | + } |
| 79 | +} |
| 80 | +``` |
| 81 | +In your notifiable model, make sure to include a `routeNotificationForClickSend()` method, |
| 82 | +provide the number in [international format](https://help.clicksend.com/article/hpkm4oco32-what-format-does-the-recipient-phone-number-need-to-be-in) |
| 83 | +or ClickSend with automatically format it using your accounts [default country](https://dashboard.clicksend.com/messaging-settings/sms/general). |
| 84 | + |
| 85 | +```php |
| 86 | +public function routeNotificationForClickSend() |
| 87 | +{ |
| 88 | + return $this->phone; // 6142345678 |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +### Available methods |
| 93 | + |
| 94 | +`from('')`: Accepts your sender id (ClickSend from number) |
| 95 | + |
| 96 | +`content('')`: Accepts a string value for the notification body. |
| 97 | + |
| 98 | +`reference('')`: Accepts a reference string, it's a [custom_string used in ClickSend](https://help.clicksend.com/article/qj7wj57leq-what-is-the-custom-string-used-for) delivery reports. |
| 99 | + |
| 100 | +## Changelog |
| 101 | + |
| 102 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 103 | + |
| 104 | +## Testing |
| 105 | + |
| 106 | +``` bash |
| 107 | +$ composer test |
| 108 | +``` |
| 109 | + |
| 110 | +## Security |
| 111 | + |
| 112 | +If you discover any security related issues, please email [email protected] instead of using the issue tracker. |
| 113 | + |
| 114 | +## Contributing |
| 115 | + |
| 116 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 117 | + |
| 118 | +## Credits |
| 119 | + |
| 120 | +- [Robert Wayne](https://github.com/webrobert) |
| 121 | +- [All Contributors](../../contributors) |
| 122 | + |
| 123 | +## License |
| 124 | + |
| 125 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
0 commit comments