diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b3ac9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.idea +composer.lock +vendor +logs +.php_cs.cache diff --git a/LICENCE.txt b/LICENCE.txt new file mode 100644 index 0000000..d992e44 --- /dev/null +++ b/LICENCE.txt @@ -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. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e568990 --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..88e8e38 --- /dev/null +++ b/composer.json @@ -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/" + } + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..b92a5b3 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,12 @@ + + + + ./tests/ + + + + + ./src/ + + + diff --git a/src/Client.php b/src/Client.php new file mode 100644 index 0000000..b077100 --- /dev/null +++ b/src/Client.php @@ -0,0 +1,11 @@ +otp(); + $this->assertEquals("WIP", $hello); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..ee21494 --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,8 @@ +