Skip to content

Commit 2af1079

Browse files
committed
initial commit
0 parents  commit 2af1079

24 files changed

+1145
-0
lines changed

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; This file is for unifying the coding style for different editors and IDEs.
2+
; More information at http://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
indent_size = 4
9+
indent_style = space
10+
end_of_line = lf
11+
insert_final_newline = true
12+
trim_trailing_whitespace = true
13+
14+
[*.md]
15+
trim_trailing_whitespace = false

.github/workflows/tests.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: PHPUnit tests
2+
3+
on:
4+
- push
5+
- pull_request
6+
7+
jobs:
8+
tests:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
php: [7.2, 7.3, 7.4, 8.0]
14+
15+
name: Tests on PHP ${{ matrix.php }} - ${{ matrix.stability }}
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: Setup PHP
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
tools: composer:v2
26+
coverage: none
27+
28+
- name: Install dependencies
29+
run: composer update --prefer-source --no-interaction --no-progress
30+
31+
- name: Execute tests
32+
run: vendor/bin/phpunit --verbose

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
**/.DS_Store
2+
/vendor
3+
composer.lock
4+
/phpunit.xml
5+
.phpunit.result.cache
6+
/.idea

.lando.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: clicksend-channel
2+
recipe: lamp
3+
config:
4+
webroot: src
5+
php: '8.1'

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: laravel

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to `clicksend` will be documented in this file
4+
5+
## 1.0.0 - 2023-01-26
6+
7+
- initial release

CONTRIBUTING.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Contributing
2+
3+
Contributions are **welcome** and will be fully **credited**.
4+
5+
Please read and understand the contribution guide before creating an issue or pull request.
6+
7+
## Etiquette
8+
9+
This project is open source, and as such, the maintainers give their free time to build and maintain the source code
10+
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
11+
extremely unfair for them to suffer abuse or anger for their hard work.
12+
13+
Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
14+
world that developers are civilized and selfless people.
15+
16+
It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
17+
quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
18+
19+
## Viability
20+
21+
When requesting or submitting new features, first consider whether it might be useful to others. Open
22+
source projects are used by many developers, who may have entirely different needs to your own. Think about
23+
whether or not your feature is likely to be used by other users of the project.
24+
25+
## Procedure
26+
27+
Before filing an issue:
28+
29+
- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
30+
- Check to make sure your feature suggestion isn't already present within the project.
31+
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
32+
- Check the pull requests tab to ensure that the feature isn't already in progress.
33+
34+
Before submitting a pull request:
35+
36+
- Check the codebase to ensure that your feature doesn't already exist.
37+
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
38+
39+
## Requirements
40+
41+
If the project maintainer has any additional requirements, you will find them listed here.
42+
43+
- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](http://pear.php.net/package/PHP_CodeSniffer).
44+
45+
- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
46+
47+
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
48+
49+
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
50+
51+
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
52+
53+
- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
54+
55+
**Happy coding**!

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License (MIT)
2+
3+
Copyright (c) Robert Wayne <[email protected]>
4+
5+
> Permission is hereby granted, free of charge, to any person obtaining a copy
6+
> of this software and associated documentation files (the "Software"), to deal
7+
> in the Software without restriction, including without limitation the rights
8+
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
> copies of the Software, and to permit persons to whom the Software is
10+
> furnished to do so, subject to the following conditions:
11+
>
12+
> The above copyright notice and this permission notice shall be included in
13+
> all copies or substantial portions of the Software.
14+
>
15+
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
> THE SOFTWARE.

README.md

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# ClickSend notifications channel for Laravel
2+
<!--
3+
[![Latest Version on Packagist](https://img.shields.io/packagist/v/laravel-notification-channels/clicksend.svg?style=flat-square)](https://packagist.org/packages/laravel-notification-channels/clicksend)
4+
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
5+
[![Build Status](https://img.shields.io/travis/laravel-notification-channels/clicksend/master.svg?style=flat-square)](https://travis-ci.org/laravel-notification-channels/clicksend)
6+
[![StyleCI](https://styleci.io/repos/:style_ci_id/shield)](https://styleci.io/repos/:style_ci_id)
7+
[![SensioLabsInsight](https://img.shields.io/sensiolabs/i/:sensio_labs_id.svg?style=flat-square)](https://insight.sensiolabs.com/projects/:sensio_labs_id)
8+
[![Quality Score](https://img.shields.io/scrutinizer/g/laravel-notification-channels/clicksend.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/clicksend)
9+
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/laravel-notification-channels/clicksend/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/laravel-notification-channels/clicksend/?branch=master)
10+
[![Total Downloads](https://img.shields.io/packagist/dt/laravel-notification-channels/clicksend.svg?style=flat-square)](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.

build/report.junit.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites>
3+
<testsuite name="" tests="9" assertions="13" errors="0" warnings="0" failures="0" skipped="0" time="1.167195">
4+
<testsuite name="Unit" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.218702">
5+
<testsuite name="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" tests="6" assertions="9" errors="0" warnings="0" failures="0" skipped="0" time="0.218702">
6+
<testcase name="testSmsIsSentViaClickSend" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="22" assertions="1" time="0.217510"/>
7+
<testcase name="testSmsIsSentViaClickSendWithCustomClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="47" assertions="2" time="0.000376"/>
8+
<testcase name="testSmsIsSentViaClickSendWithCustomFrom" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="75" assertions="1" time="0.000161"/>
9+
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndClient" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="100" assertions="2" time="0.000275"/>
10+
<testcase name="testSmsIsSentViaClickSendWithCustomFromAndCustomString" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="129" assertions="1" time="0.000183"/>
11+
<testcase name="testSmsIsSentViaClickSendWithCustomClientFromAndClientRef" class="NotificationChannels\ClickSend\Test\Unit\Channels\ClickSendSmsChannelTest" classname="NotificationChannels.ClickSend.Test.Unit.Channels.ClickSendSmsChannelTest" file="/app/tests/Unit/Channels/ClickSendSmsChannelTest.php" line="155" assertions="2" time="0.000197"/>
12+
</testsuite>
13+
</testsuite>
14+
<testsuite name="Feature" tests="3" assertions="4" errors="0" warnings="0" failures="0" skipped="0" time="0.948493">
15+
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.869834">
16+
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAPICredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAPICredentialsTest" file="/app/tests/Feature/ClientAPICredentialsTest.php" line="15" assertions="1" time="0.869834"/>
17+
</testsuite>
18+
<testsuite name="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" tests="1" assertions="1" errors="0" warnings="0" failures="0" skipped="0" time="0.036415">
19+
<testcase name="testClientCreatedWithBasicAPICredentials" class="NotificationChannels\ClickSend\Test\Feature\ClientAccountCredentialsTest" classname="NotificationChannels.ClickSend.Test.Feature.ClientAccountCredentialsTest" file="/app/tests/Feature/ClientAccountCredentialsTest.php" line="15" assertions="1" time="0.036415"/>
20+
</testsuite>
21+
<testsuite name="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" tests="1" assertions="2" errors="0" warnings="0" failures="0" skipped="0" time="0.042244">
22+
<testcase name="testWhenNoConfigurationIsGivenExceptionIsRaised" class="NotificationChannels\ClickSend\Test\Feature\NoClickSendConfigurationTest" classname="NotificationChannels.ClickSend.Test.Feature.NoClickSendConfigurationTest" file="/app/tests/Feature/NoClickSendConfigurationTest.php" line="15" assertions="2" time="0.042244"/>
23+
</testsuite>
24+
</testsuite>
25+
</testsuite>
26+
</testsuites>

0 commit comments

Comments
 (0)