Skip to content

Commit

Permalink
feat(init): basic setup
Browse files Browse the repository at this point in the history
  • Loading branch information
sudkumar committed Oct 18, 2019
0 parents commit 4436877
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
composer.lock
vendor
logs
.php_cs.cache
15 changes: 15 additions & 0 deletions LICENCE.txt
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.
47 changes: 47 additions & 0 deletions README.md
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
```
33 changes: 33 additions & 0 deletions composer.json
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/"
}
}
}
12 changes: 12 additions & 0 deletions phpunit.xml
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>
11 changes: 11 additions & 0 deletions src/Client.php
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';
}
}
14 changes: 14 additions & 0 deletions tests/ClientTest.php
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);
}
}
8 changes: 8 additions & 0 deletions tests/TestCase.php
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
{ }

0 comments on commit 4436877

Please sign in to comment.