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

Add Textlocal Channel #37

Open
wants to merge 64 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
16f5684
Add Textlocal Channel
msonowal Aug 7, 2017
0feceaa
Exception handling
msonowal Aug 7, 2017
ccf2195
Apply Patch from CI
msonowal Aug 7, 2017
9ea8b72
modified default case namespace
msonowal Aug 7, 2017
a194c6a
updated exception import which was incorrect previously
msonowal Aug 9, 2017
519cd62
apply fixes from styleci
msonowal Aug 9, 2017
30ec260
Update composer.json
msonowal Nov 25, 2017
e51d5ac
Update README.md
msonowal Nov 25, 2017
83e3f76
Update TextlocalChannel.php
msonowal Nov 25, 2017
b37a672
Update README.md
msonowal Nov 25, 2017
5e0e269
Update TextlocalChannel.php
msonowal Dec 2, 2017
0b5230f
Update TextlocalChannel.php
msonowal Apr 4, 2018
e7906c6
Update CouldNotSendNotification.php
msonowal Apr 4, 2018
1792aea
Added Multiple region textlocal config
msonowal Oct 19, 2018
3e2438f
moved config dir
msonowal Oct 19, 2018
c4c5604
updated contributors name
msonowal Oct 19, 2018
964f1bd
Fixed a bug which occurs when textlocal config is not published and h…
msonowal Oct 24, 2018
09f53ab
Update TextlocalChannel.php
msonowal Oct 29, 2018
e14ddd6
auto package discovery for newer laravel versions
nikugogoi Apr 5, 2019
ed07e6d
Merge pull request #2 from nikugogoi/patch-1
msonowal Apr 8, 2019
e3b5ef9
updated to use api_key from config
msonowal Jul 29, 2019
244e5fb
Update README.md
msonowal Jul 29, 2019
34d77ac
Update TextlocalServiceProvider.php
msonowal Jul 29, 2019
0db2909
Added Laravel 6 support
msonowal Sep 12, 2019
b4d67d8
Update README.md
msonowal Sep 12, 2019
56bf3c9
Update composer.json
msonowal Sep 13, 2019
9ad75cf
Update composer.json
msonowal Sep 13, 2019
2b94219
Update phpunit.xml.dist
msonowal Sep 13, 2019
6e7607f
Adding unicode support to SMS. (#8)
ShankarAkunuri Oct 29, 2019
d24268b
updated minimum php version to 7.0
msonowal Oct 30, 2019
ffebe51
Update TextlocalChannel.php
msonowal Oct 30, 2019
5c0f0da
Update travis.yml
msonowal Oct 30, 2019
620d6a4
Update textlocal.php
msonowal Oct 30, 2019
8c62761
Update TextlocalServiceProvider.php
msonowal Oct 30, 2019
00fb886
Update Textlocal.php
msonowal Oct 30, 2019
4495ca3
Update Textlocal.php
msonowal Oct 30, 2019
4c981b0
Update composer.json
msonowal Oct 30, 2019
203efc2
Update TextlocalChannel.php
msonowal Oct 30, 2019
8bb4701
Update TextlocalChannel.php
msonowal Oct 30, 2019
56795f2
Update TextlocalChannel.php
msonowal Oct 30, 2019
8deb52c
Update TextlocalChannel.php
msonowal Oct 30, 2019
0378869
updated method routeNotificationFor('sms') to routeNotificationFor('T…
msonowal Oct 30, 2019
610ba82
Update textlocal.php
msonowal Oct 30, 2019
8a6196e
Update README.md
msonowal Oct 30, 2019
4881869
Update README.md
msonowal Oct 30, 2019
ee8e7e5
Update composer.json
msonowal Nov 5, 2019
610c6e8
Update README.md
msonowal Nov 5, 2019
37ad613
Update TextlocalChannel.php (#12)
tsainadh Dec 9, 2019
e41ddde
Upgrade to GitHub-native Dependabot (#13)
dependabot-preview[bot] Dec 30, 2021
4431763
Laravel 7.x & 8.x support (#14)
rupamjbordoloi Dec 30, 2021
1d3cde6
updated support for Laravel 9 LTS
msonowal Jul 16, 2022
5ae212f
Update README.md
msonowal Jul 29, 2022
f57475a
Update README.md
msonowal Jul 29, 2022
d75d588
Update README.md
msonowal Jul 29, 2022
0ecbbe6
Update README.md
msonowal Jul 29, 2022
f645e05
Update README.md
msonowal Jul 29, 2022
8273965
Update README.md
msonowal Jul 29, 2022
be0bc25
feat: custom client configuration usage via per notification or noti…
msonowal Jul 29, 2022
38bda2c
Update TextlocalChannel.php
msonowal Aug 17, 2022
1ae7cf2
Update INotificationUsesTextlocalClientConfig.php
msonowal Aug 17, 2022
2409b6f
Update TextlocalChannel.php
msonowal Aug 17, 2022
d509d17
Update textlocal.php config with sample/example stub for custom usage
msonowal Aug 17, 2022
8a2349f
feat: added support for laravel 10 Update composer.json
msonowal Feb 18, 2023
30cac8b
Add Laravel 11 Support
lrljoe May 11, 2024
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
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: 2
updates:
- package-ecosystem: composer
directory: "/"
schedule:
interval: daily
time: "23:30"
open-pull-requests-limit: 10
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Changelog

All notable changes to `Textlocal` will be documented in this file


## 2.4.0 - 2022-08-17

`public function getSenderId($notifiable)`

method has changed from `public function getSenderId()`, so now the notifiable is passed as parameter
giving more control to the imeplementation to decide based on user/recipent in case want to use some alternate deciding factor

## 0.0.1 - 2017-08-07

- initial release
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Contributions are **welcome** and will be fully **credited**.

Please read and understand the contribution guide before creating an issue or pull request.

## Etiquette

This project is open source, and as such, the maintainers give their free time to build and maintain the source code
held within. They make the code freely available in the hope that it will be of use to other developers. It would be
extremely unfair for them to suffer abuse or anger for their hard work.

Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
world that developers are civilized and selfless people.

It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
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.

## Viability

When requesting or submitting new features, first consider whether it might be useful to others. Open
source projects are used by many developers, who may have entirely different needs to your own. Think about
whether or not your feature is likely to be used by other users of the project.

## Procedure

Before filing an issue:

- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.

Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.

## Requirements

If the project maintainer has any additional requirements, you will find them listed here.

- **[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).

- **Add tests!** - Your patch won't be accepted if it doesn't have tests.

- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.

- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.

- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.

- **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.

**Happy coding**!
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) Manash Jyoti Sonowal <[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
> 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.
175 changes: 172 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,174 @@
# new-channels
This package allows to send SMS using Textlocal API using laravel notifications channel textlocal sms

Discuss about new channel proposals our share your finished channels in the [proposal issue](https://github.com/laravel-notification-channels/new-channels/issues/6).
Supports Laravel 5.5 upto 10.x

Take a look at our [FAQ](http://laravel-notification-channels.com/) to see our small list of rules, to provide top-notch notification channels.
[![Latest Stable Version](https://poser.pugx.org/msonowal/laravel-notification-channel-textlocal/v/stable)](https://packagist.org/packages/msonowal/laravel-notification-channel-textlocal)
[![License](https://poser.pugx.org/msonowal/laravel-notification-channel-textlocal/license)](https://packagist.org/packages/msonowal/laravel-notification-channel-textlocal)
[![Total Downloads](https://poser.pugx.org/msonowal/laravel-notification-channel-textlocal/downloads)](https://packagist.org/packages/msonowal/laravel-notification-channel-textlocal)

This package makes it easy to send notifications using [textlocal](https://www.textlocal.in/) with Laravel 5.3.+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This package makes it easy to send notifications using [textlocal](https://www.textlocal.in/) with Laravel 5.3.+
This package makes it easy to send notifications using [textlocal](https://www.textlocal.in/) with Laravel 5.5+ & 6.x



To use version ^2.3.0 onwards will require PHP 8.0

for other PHP version use upto ^2.2.0

## Contents

- [Installation](#installation)
- [Setting up the textlocal service](#setting-up-the-textlocal-service)
- [Usage](#usage)
- [Available Message methods](#available-message-methods)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)


## Installation

Create an account in textlocal then create an API key or hash(password).

`composer require msonowal/laravel-notification-channel-textlocal`

### Setting up the textlocal service

default config `textlocal.php` update where desired

Important Either specify a Key OR a Hash - don't enter both!

```
return [
'username' => env('TEXTLOCAL_USERNAME'),
'password' => env('TEXTLOCAL_PASSWORD'),
'hash' => env('TEXTLOCAL_HASH'), //optional if api_key is set
'api_key' => env('TEXTLOCAL_API_KEY'), //optional if hash is set
'sender' => env('TEXTLOCAL_SENDER'),
'request_urls' => [
'IN' => 'https://api.textlocal.in/',
'UK' => 'https://api.txtlocal.com/'
],
'country' => env('TEXTLOCAL_COUNTRY', 'IN'),
'extra' => [
// extra config define keys as desired for use within the textlocal client config
// if you want to use the custom client config for each notification or notifiable
// INotificationUsesTextlocalClientConfig
]public function getSenderId($notifiable)
### Configuring .env
```
TEXTLOCAL_USERNAME=Your email id or api key
TEXTLOCAL_HASH=get it from url '/docs/' under your API KEYS section
TEXTLOCAL_API_KEY get it from url '/docs/' under your API KEYS section
TEXTLOCAL_SENDER=Name of the Sender that will be displayed to the recipient (max 6 Characters).
TEXTLOCAL_COUNTRY=Your Two letter(ISO-3166-alpha-2) Country Code. It should be the Country of the TEXTLOCAL account. defaults to IN
```

### Publish Config
```
php artisan vendor:publish --tag=textlocal
```

Currently, only textlocal of two country is supported IN(India) and UK(United Kingdom).

## Usage

Implement this method `routeNotificationForTextlocal()` in your notifiable class/model which will return array of mobile numbers. Please make sure the mobile number contains the dial code as well (e.g +91 for India). And lastly implement `toSms()` method in the notification class which will return the (string) sms or template that is defined in textlocal account that needs to be send.


## Usage

You can use the channel in your `via()` method inside the notification:

```php
use Illuminate\Notifications\Notification;
use NotificationChannels\Textlocal\TextlocalChannel;

class TestOTPNotification extends Notification
{
public function via($notifiable)
{
return [TextlocalChannel::class];
}

public function toSms($notifiable)
{
return 'Use 1234 as OTP for resetting your password.';
}
}
```

In your notifiable model, make sure to include a `routeNotificationForTextlocal()` method, which returns a phone number or multiple numbers in array
or an array of phone numbers.

```php
public function routeNotificationForTextlocal(): array
{
return [$this->mobile_no];
}
```

Annoynmous Notifable when say mobile no is not added to a notifiable model you can directly send to mobile no by using that

```php
Notification::route('Textlocal', $mobileNo')->notify(new VerifyMobileNotification($otp));
```

### Available Message methods

And if you want to have a specific sender based on Notification, e.g. like you are sending promotional notification using one and another for transaction then you can just define this method in your notification class which will return your sender id for that notification only
```
public function getSenderId($notifiable)
{
return 'YOUR_SENDER_ID';
}
```


Unicode support
If you want to send the notification content to have unicode support. Define this method in your notification which will return boolean based on which the sms will set the unicode mode in textlocal API
```
public function getUnicodeMode()
{
return true;
}
```

A list of all available options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing


## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Testing

``` bash
$ composer test
```

## Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

# Found any bugs or improvement open an issue or send me a PR

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Credits

- [Manash Jyoti Sonowal](https://github.com/msonowal)
- [Mr Ejang](https://github.com/tomonsoejang)
- [Sinadh](https://github.com/tsainadh)
- [All Contributors](../../contributors)

## License

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

## TODO
Need to convert to Guzzle Http as a Client in core
Add more countries
add tests
47 changes: 47 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "msonowal/laravel-notification-channel-textlocal",
"description": "Textlocal Notifications Channel for Laravel",
"homepage": "https://github.com/laravel-notification-channels/textlocal",
"license": "MIT",
"authors": [
{
"name": "Manash Jyoti Sonowal",
"email": "[email protected]",
"homepage": "https://github.com/msonowal",
"role": "Developer"
}
],
"require": {
"php": ">=7.0",
"ext-json": "*",
"illuminate/notifications": "~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0",
"illuminate/support": "~5.5|~6.0|~7.0|~8.0|~9.0|~10.0|~11.0"
},
"require-dev": {
"mockery/mockery": "^0.9.5|^1.0",
"phpunit/phpunit": "~5|^8.0|^9.0|^10.0|~11.0"
},
"autoload": {
"psr-4": {
"NotificationChannels\\Textlocal\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"NotificationChannels\\Textlocal\\Test\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
"NotificationChannels\\Textlocal\\TextlocalServiceProvider"
]
}
},
"scripts": {
"test": "vendor/bin/phpunit"
},
"config": {
"sort-packages": true
}
}
26 changes: 26 additions & 0 deletions config/textlocal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

return [
'username' => env('TEXTLOCAL_USERNAME'),
'password' => env('TEXTLOCAL_PASSWORD'),
'hash' => env('TEXTLOCAL_HASH'),
'api_key' => env('TEXTLOCAL_API_KEY'),
'sender' => env('TEXTLOCAL_SENDER', 'DOCONL'),
'request_urls' => [
'IN' => 'https://api.textlocal.in/',
'UK' => 'https://api.txtlocal.com/',
],
'country' => env('TEXTLOCAL_COUNTRY', 'IN'),
/*
// a sample way to organize custom config when using mutliple on demand config
// uncomment this for that purpose or feel free to use your own implementations
'UK' => [
'username' => env('TEXTLOCAL_USERNAME_UK'),
'password' => env('TEXTLOCAL_PASSWORD_UK'),
'hash' => env('TEXTLOCAL_HASH_UK'),
'api_key' => env('TEXTLOCAL_API_KEY_UK'),
'sender' => env('TEXTLOCAL_SENDER_UK', 'DOCONL'),
'country' => env('TEXTLOCAL_COUNTRY_UK', 'UK'),
],
*/
];
29 changes: 29 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name=":service_name Test Suite">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Service name here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still missing

<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
Loading