-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4436877
Showing
8 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea | ||
composer.lock | ||
vendor | ||
logs | ||
.php_cs.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
The MIT License (MIT) | ||
Copyright (c) 2019 Craftsys, Inc | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# MSG91 PHP Client | ||
|
||
This is a **PHP Client** for [MSG91 APIs](https://docs.msg91.com/collection/msg91-api-integration/5/pages/139). | ||
|
||
## Usage | ||
|
||
### Create a Client | ||
|
||
```php | ||
// initialize the client | ||
$client = new MSG91Client(string $token, GuzzleHttp\Client $httpClient); | ||
// $token and $httpClient are optional | ||
// e.g. $client = new MSG91Client(); | ||
// token can be provided at a later stage | ||
// $client->setToken($token); | ||
// $httpClient will be automatically created if none provided | ||
``` | ||
|
||
### Managing OTPs | ||
|
||
#### Send OTP | ||
|
||
```php | ||
$client->otp(12345) // set the OTP. OTP parameter is optional | ||
->to(912343434312) // set the mobile with country code | ||
->country(91) // set the country code | ||
->send(); // send the otp | ||
``` | ||
|
||
### Verify OTP | ||
|
||
```php | ||
$client->otp(12345) // set the OTP that should be verified | ||
->to(912343434312) // set the mobile with country code | ||
->country(91) // set the country code | ||
->verify(); // verify this otp | ||
``` | ||
|
||
### Resend OTP | ||
|
||
```php | ||
$client->otp() | ||
->to(912343434312) // set the mobile with country code | ||
->country(91) // set the country code | ||
->via("text") // way of retry: "text" | "voice" | ||
->resend(); // resend otp | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "craftsys/msg91-php", | ||
"description": "PHP Client for using MSG91's API.", | ||
"license": "MIT", | ||
"type": "library", | ||
"authors": [ | ||
{ | ||
"name": "Sudhir Mitharwal", | ||
"email": "luckysud4@gmail.com", | ||
"role": "Developer", | ||
"homepage": "http://github.com/sudkumar" | ||
} | ||
], | ||
"support": { | ||
"email": "luckysud4@gmail.com" | ||
}, | ||
"require": { | ||
"php": ">=7.1" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^7.4" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Craftsys\\MSG91\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Craftsys\\MSG91\\Test\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<phpunit colors="true" bootstrap="vendor/autoload.php"> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace Craftsys\MSG91; | ||
|
||
class Client | ||
{ | ||
public static function otp() | ||
{ | ||
return 'WIP'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Craftsys\MSG91\Test; | ||
|
||
use Craftsys\MSG91\Client; | ||
|
||
class ClientTest extends TestCase | ||
{ | ||
public function test_works() | ||
{ | ||
$hello = (new Client())->otp(); | ||
$this->assertEquals("WIP", $hello); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Craftsys\MSG91\Test; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
abstract class TestCase extends BaseTestCase | ||
{ } |