Skip to content

Commit e0eda73

Browse files
authored
Update SMS to use the new Flow api and Templates
1 parent 7bdc688 commit e0eda73

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed

README.md

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ This is a **[laravel](https://laravel.com) service provider** for [Msg91 APIs](h
1616
- [Verify OTP](#verify-otp)
1717
- [Resend OTP](#resend-otp)
1818
- [Sending SMS](#sending-sms)
19+
- [Bulk SMS](#bulk-sms)
20+
- [Message Variables](#message-variables)
1921
- [Handling Responses](#handling-responses)
2022
- [Related](#related)
2123
- [Acknowledgements](#acknowledgements)
@@ -31,9 +33,9 @@ composer require craftsys/msg91-laravel
3133
**prerequisite**
3234

3335
- php^7.1
34-
- laravel^5|^6|^7
36+
- laravel^5|^6|^7|^8
3537

36-
The package is tested for 5.8+,^6.0,^7.0 only. If you find any bugs for laravel (5.0< >5.8), please file an issue.
38+
The package is tested for 5.8+,^6.0,^7.0,^8.0 only. If you find any bugs for laravel (5.0< >5.8), please file an issue.
3739

3840
### Laravel 5.5+
3941

@@ -69,7 +71,7 @@ To verify that everything is working as expected, excecute the following php cod
6971
in an example route or in `php artisan tinker` if you are in Laravel.
7072

7173
```php
72-
// this should print the `\Craftsys\Msg91\Services\OTPService` of some default configuration values
74+
// this should print the `\Craftsys\Msg91\OTP\OTPService` of some default configuration values
7375
echo Msg91::otp()::class
7476
```
7577

@@ -85,10 +87,10 @@ The package can be configured by providing a `msg91` key inside your `config/ser
8587
<?php
8688

8789
return [
88-
// along with other services
89-
"msg91" => [
90-
'key' => env("Msg91_KEY"),
91-
],
90+
// along with other services
91+
"msg91" => [
92+
'key' => env("Msg91_KEY"),
93+
],
9294
];
9395
```
9496

@@ -121,6 +123,7 @@ OTP services like sending, verifying, and resending etc, can be accessed via `ot
121123
```php
122124
Msg91::otp()
123125
->to(912343434312) // phone number with country code
126+
->template('your_template_id') // set the otp template
124127
->send(); // send the otp
125128
```
126129

@@ -137,6 +140,7 @@ Msg91::otp(1234) // OTP to be verified
137140
```php
138141
Msg91::otp()
139142
->to(912343434312) // set the mobile with country code
143+
->viaVoice() // set the otp sending method (can be "viaText" as well)
140144
->resend(); // resend otp
141145
```
142146

@@ -145,13 +149,47 @@ Msg91::otp()
145149
```php
146150
Msg91::sms()
147151
->to(912343434312) // set the mobile with country code
148-
->message("Your message here"); // provide your message
152+
->flow("your_flow_id_here") // set the flow id
149153
->send(); // send
150154
```
151155

156+
### Bulk SMS
157+
158+
```
159+
Msg91::sms()
160+
->to([912343434312, 919898889892]) // set the mobiles with country code
161+
->flow("your_flow_id_here") // set the flow id
162+
->send(); // send
163+
```
164+
165+
### Message Variables
166+
167+
```
168+
// send in bulk with variables
169+
Msg91::sms()
170+
->to([912343434312, 919898889892]) // set the mobiles with country code
171+
->flow("your_flow_id_here") // set the flow id
172+
->variable('date', "Sunday") // the the value for variable "date" in your flow message template
173+
->send(); // send
174+
175+
// send in bulk with variables per recipient
176+
Msg91::sms()
177+
->to([912343434312, 919898889892]) // set the mobiles with country code
178+
->flow("your_flow_id_here") // set the flow id
179+
->recipients([
180+
['mobiles' => 919999223345, 'name' => 'Sudhir M'],
181+
['mobiles' => 912929223345, 'name' => 'Craft Sys']
182+
])
183+
// (optionally) set a "date" variable for all the recipients
184+
->variable('date', "Sunday")
185+
->send(); // send
186+
```
187+
188+
> For a detailed usage and options, please visit [msg91-php's documentation][client-sending-sms] on sending SMSs.
189+
152190
## Handling Responses
153191

154-
All the services will return `\Craftsys\Msg91\Response` instance for all successfully responses or will throw exceptions if request validation failed (`\Craftsys\Msg91\Exceptions\ValidationException`)or there was an error in the response (`\Craftsys\Msg91\Exceptions\ResponseErrorException`).
192+
All the services will return `\Craftsys\Msg91\Support\Response` instance for all successfully responses or will throw exceptions if request validation failed (`\Craftsys\Msg91\Exceptions\ValidationException`)or there was an error in the response (`\Craftsys\Msg91\Exceptions\ResponseErrorException`).
155193

156194
```php
157195
try {
@@ -172,6 +210,7 @@ try {
172210
[client-configuration]: https://github.com/craftsys/msg91-php#configuration
173211
[client-examples]: https://github.com/craftsys/msg91-php#examples
174212
[client-managing-otps]: https://github.com/craftsys/msg91-php#managing-otps
213+
[client-sending-sms]: https://github.com/craftsys/msg91-php#sending-sms
175214

176215

177216
# Related

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"require": {
2727
"php": "^7.1.3",
28-
"craftsys/msg91-php": "^0.9",
28+
"craftsys/msg91-php": "^0.12",
2929
"illuminate/support": "^5.2|^6.0|^7.0|^8.0"
3030
},
3131
"require-dev": {

0 commit comments

Comments
 (0)