Skip to content

Commit daf7417

Browse files
committed
docs(response): add response handling docs and updated client
1 parent 51a26ec commit daf7417

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This is a **[laravel](https://laravel.com) service provider** for [Msg91 APIs](h
1717
- [Send OTP](#send-otp)
1818
- [Verify OTP](#verify-otp)
1919
- [Resend OTP](#resend-otp)
20+
- [Sending SMS](#sending-sms)
21+
- [Handling Error Responses](#error-responses)
2022

2123
## Installation
2224

@@ -140,6 +142,23 @@ Msg91::sms()
140142
->send(); // send
141143
```
142144

145+
## Error Responses
146+
147+
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`).
148+
149+
```php
150+
try {
151+
$response = $client->otp()->to(919999999999)->send();
152+
} catch (\Craftsys\Msg91\Exceptions\ValidationException $e) {
153+
// issue with the request e.g. token not provided
154+
} catch (\Craftsys\Msg91\Exceptions\ResponseErrorException $e) {
155+
// error thrown by msg91 apis or by http client
156+
} catch (\Exception $e) {
157+
// something else went wrong
158+
// plese report if this happens :)
159+
}
160+
```
161+
143162
> For all the examples and options, please consult [msg91-php examples section][client-examples]
144163
145164
[client]: https://github.com/craftsys/msg91-php

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",
28-
"craftsys/msg91-php": "^0.7",
28+
"craftsys/msg91-php": "^0.8",
2929
"illuminate/support": "^5.2|^6.0"
3030
},
3131
"require-dev": {

0 commit comments

Comments
 (0)