Skip to content

Commit cdc4494

Browse files
committed
Syncing
1 parent bfa3784 commit cdc4494

File tree

7 files changed

+222
-222
lines changed

7 files changed

+222
-222
lines changed

.github/FUNDING.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github: TheBikramLama
1+
github: TheBikramLama

LICENSE

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
MIT License
2-
3-
Copyright (c) 2020 Bikram Lama
4-
5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
1+
MIT License
2+
3+
Copyright (c) 2020 Bikram Lama
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+83-83
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,83 @@
1-
Sparrow SMS Laravel Package
2-
=============================
3-
4-
[![Latest Version](https://img.shields.io/github/v/release/TheBikramLama/sparrow.svg?style=flat-square)](https://github.com/TheBikramLama/sparrow/releases)
5-
![Issues](https://img.shields.io/github/issues/TheBikramLama/sparrow)
6-
[![Downloads](https://img.shields.io/packagist/dt/TheBikramLama/sparrow.svg?style=flat-square)](https://packagist.org/packages/thebikramlama/sparrow)
7-
8-
Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits.
9-
10-
## Getting Started
11-
12-
This package can be installed through Composer.
13-
14-
```bash
15-
composer require thebikramlama/sparrow
16-
```
17-
18-
Publish `sparrow.php` config file for customization
19-
```bash
20-
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"
21-
```
22-
23-
## How to send an SMS
24-
25-
After the installation is complete, `Sparrow` alias is generated by default.
26-
27-
### Using the default Alias
28-
```php
29-
// Using Default
30-
use Sparrow;
31-
```
32-
33-
### Send an SMS
34-
```php
35-
$from = 'InfoSms'; // Setting FROM provided by Sparrow
36-
$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow
37-
38-
$to = '9801234567'; // Setting Phone Number
39-
$message = 'Test message from Sparrow.'; // Setting Message
40-
41-
// Send the message
42-
$sms_message = Sparrow::send($to, $message, $from, $access_token);
43-
// This will return a pseudo JSON response, you will need to json_decode it.
44-
```
45-
46-
## Getting available Credits
47-
```php
48-
$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow
49-
50-
// Query Credits
51-
$credits = Sparrow::credits($access_token);
52-
echo 'Available credits: '. json_decode($credits)->credits_available; // Available credits: 1500
53-
```
54-
55-
## Customization
56-
Make sure you have published `sparrow.php` config file
57-
```bash
58-
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"
59-
```
60-
You can find the `sparrow.php` config file under `config/sparrow.php` inside your laravel project.
61-
62-
You can edit the file as per your need.
63-
```php
64-
// Your Sparrow SMS Access Token here.
65-
'access_token' => 'YOUR_ACCESS_TOKEN',
66-
// Identity Provided by Sparrow SMS
67-
'from' => 'FROM',
68-
```
69-
70-
After updating the `sparrow.php` config file you can call `Sparrow` methods with lesser arguments.
71-
72-
Example:
73-
```php
74-
$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional
75-
$credits = Sparrow::credits(); // Access token is optional
76-
```
77-
78-
## Credits
79-
- [Bikram Lama](https://github.com/TheBikramLama)
80-
81-
## License
82-
83-
The MIT License (MIT). Please see [License File](LICENSE) for more information.
1+
Sparrow SMS Laravel Package
2+
=============================
3+
4+
[![Latest Version](https://img.shields.io/github/v/release/TheBikramLama/sparrow.svg?style=flat-square)](https://github.com/TheBikramLama/sparrow/releases)
5+
![Issues](https://img.shields.io/github/issues/TheBikramLama/sparrow)
6+
[![Downloads](https://img.shields.io/packagist/dt/TheBikramLama/sparrow.svg?style=flat-square)](https://packagist.org/packages/thebikramlama/sparrow)
7+
8+
Sparrow SMS Laravel Package can be used to send SMS via Sparrow SMS or query account's credits.
9+
10+
## Getting Started
11+
12+
This package can be installed through Composer.
13+
14+
```bash
15+
composer require thebikramlama/sparrow
16+
```
17+
18+
Publish `sparrow.php` config file for customization
19+
```bash
20+
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"
21+
```
22+
23+
## How to send an SMS
24+
25+
After the installation is complete, `Sparrow` alias is generated by default.
26+
27+
### Using the default Alias
28+
```php
29+
// Using Default
30+
use Sparrow;
31+
```
32+
33+
### Send an SMS
34+
```php
35+
$from = 'InfoSms'; // Setting FROM provided by Sparrow
36+
$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow
37+
38+
$to = '9801234567'; // Setting Phone Number
39+
$message = 'Test message from Sparrow.'; // Setting Message
40+
41+
// Send the message
42+
$sms_message = Sparrow::send($to, $message, $from, $access_token);
43+
// This will return a pseudo JSON response, you will need to json_decode it.
44+
```
45+
46+
## Getting available Credits
47+
```php
48+
$access_token = 'YOUR_ACCESS_TOKEN'; // Setting Access Token provided by Sparrow
49+
50+
// Query Credits
51+
$credits = Sparrow::credits($access_token);
52+
echo 'Available credits: '. json_decode($credits)->credits_available; // Available credits: 1500
53+
```
54+
55+
## Customization
56+
Make sure you have published `sparrow.php` config file
57+
```bash
58+
php artisan vendor:publish --provider="Thebikramlama\Sparrow\SparrowServiceProvider"
59+
```
60+
You can find the `sparrow.php` config file under `config/sparrow.php` inside your laravel project.
61+
62+
You can edit the file as per your need.
63+
```php
64+
// Your Sparrow SMS Access Token here.
65+
'access_token' => 'YOUR_ACCESS_TOKEN',
66+
// Identity Provided by Sparrow SMS
67+
'from' => 'FROM',
68+
```
69+
70+
After updating the `sparrow.php` config file you can call `Sparrow` methods with lesser arguments.
71+
72+
Example:
73+
```php
74+
$sms_message = Sparrow::send('98081234567', 'Test Messsage'); // From and Access token are optional
75+
$credits = Sparrow::credits(); // Access token is optional
76+
```
77+
78+
## Credits
79+
- [Bikram Lama](https://github.com/TheBikramLama)
80+
81+
## License
82+
83+
The MIT License (MIT). Please see [License File](LICENSE) for more information.

composer.json

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
{
2-
"name": "thebikramlama/sparrow",
3-
"description": "Laravel Package to send SMS via Sparrow SMS",
4-
"type": "library",
5-
"license": "MIT",
6-
"authors": [
7-
{
8-
"name": "Bikram Lama",
9-
"email": "[email protected]"
10-
}
11-
],
12-
"minimum-stability": "stable",
13-
"require": {
14-
"php" : "^7.0|^8.0",
15-
"guzzlehttp/guzzle": "^6.3"
16-
},
17-
"autoload": {
18-
"psr-4": {
19-
"Thebikramlama\\Sparrow\\": "src/"
20-
}
21-
},
22-
"extra": {
23-
"laravel": {
24-
"providers": [
25-
"Thebikramlama\\Sparrow\\SparrowServiceProvider"
26-
],
27-
"aliases": {
28-
"Sparrow": "Thebikramlama\\Sparrow\\Sparrow"
29-
}
30-
}
31-
}
32-
}
1+
{
2+
"name": "thebikramlama/sparrow",
3+
"description": "Laravel Package to send SMS via Sparrow SMS",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Bikram Lama",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"minimum-stability": "stable",
13+
"require": {
14+
"php" : "^7.0|^8.0",
15+
"guzzlehttp/guzzle": "^6.3"
16+
},
17+
"autoload": {
18+
"psr-4": {
19+
"Thebikramlama\\Sparrow\\": "src/"
20+
}
21+
},
22+
"extra": {
23+
"laravel": {
24+
"providers": [
25+
"Thebikramlama\\Sparrow\\SparrowServiceProvider"
26+
],
27+
"aliases": {
28+
"Sparrow": "Thebikramlama\\Sparrow\\Sparrow"
29+
}
30+
}
31+
}
32+
}

src/Sparrow.php

+48-48
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
1-
<?php
2-
namespace Thebikramlama\Sparrow;
3-
4-
use GuzzleHttp\Client;
5-
6-
class Sparrow {
7-
public static function getAccessToken() { return config('sparrow.access_token'); }
8-
public static function getFrom() { return config('sparrow.from'); }
9-
public static function getApiUrl() { return config('sparrow.api_endpoint'); }
10-
public static function getSendUrl() { return Sparrow::getApiUrl().config('sparrow.methods.send'); }
11-
public static function getCreditUrl() { return Sparrow::getApiUrl().config('sparrow.methods.credit'); }
12-
13-
public static function send( $to = Null, $text = Null, $from = Null, $accessToken = Null )
14-
{
15-
if ( is_null($to) || is_null($text) ) return json_encode(['response_code' => 404, 'response' => 'Required Fields Missing.']);
16-
$from = is_null($from) ? Sparrow::getFrom() : $from;
17-
$accessToken = is_null($accessToken) ? Sparrow::getAccessToken() : $accessToken;
18-
19-
$client = new Client();
20-
$request = $client->get( Sparrow::getSendUrl(), [
21-
'query' => [
22-
'token' => $accessToken,
23-
'from' => $from,
24-
'to' => $to,
25-
'text' => $text
26-
],
27-
'http_errors' => false
28-
]);
29-
30-
$response = $request->getBody();
31-
return $response;
32-
}
33-
34-
public static function credits( $accessToken = Null )
35-
{
36-
$accessToken = is_null($accessToken) ? Sparrow::getAccessToken() : $accessToken;
37-
38-
$client = new Client();
39-
$request = $client->get( Sparrow::getCreditUrl(), [
40-
'query' => [
41-
'token' => $accessToken
42-
],
43-
'http_errors' => false
44-
]);
45-
46-
$response = $request->getBody();
47-
return $response;
48-
}
1+
<?php
2+
namespace Thebikramlama\Sparrow;
3+
4+
use GuzzleHttp\Client;
5+
6+
class Sparrow {
7+
public static function getAccessToken() { return config('sparrow.access_token'); }
8+
public static function getFrom() { return config('sparrow.from'); }
9+
public static function getApiUrl() { return config('sparrow.api_endpoint'); }
10+
public static function getSendUrl() { return Sparrow::getApiUrl().config('sparrow.methods.send'); }
11+
public static function getCreditUrl() { return Sparrow::getApiUrl().config('sparrow.methods.credit'); }
12+
13+
public static function send( $to = Null, $text = Null, $from = Null, $accessToken = Null )
14+
{
15+
if ( is_null($to) || is_null($text) ) return json_encode(['response_code' => 404, 'response' => 'Required Fields Missing.']);
16+
$from = is_null($from) ? Sparrow::getFrom() : $from;
17+
$accessToken = is_null($accessToken) ? Sparrow::getAccessToken() : $accessToken;
18+
19+
$client = new Client();
20+
$request = $client->get( Sparrow::getSendUrl(), [
21+
'query' => [
22+
'token' => $accessToken,
23+
'from' => $from,
24+
'to' => $to,
25+
'text' => $text
26+
],
27+
'http_errors' => false
28+
]);
29+
30+
$response = $request->getBody();
31+
return $response;
32+
}
33+
34+
public static function credits( $accessToken = Null )
35+
{
36+
$accessToken = is_null($accessToken) ? Sparrow::getAccessToken() : $accessToken;
37+
38+
$client = new Client();
39+
$request = $client->get( Sparrow::getCreditUrl(), [
40+
'query' => [
41+
'token' => $accessToken
42+
],
43+
'http_errors' => false
44+
]);
45+
46+
$response = $request->getBody();
47+
return $response;
48+
}
4949
}

0 commit comments

Comments
 (0)