├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ └── feature_request.md
├── .gitignore
├── src
├── helper.php
├── Support
│ └── Facades
│ │ └── Textit.php
├── TextitServiceProvider.php
└── Textit.php
├── CONTRIBUTING.md
├── LICENSE.md
├── tests
└── Feature
│ └── TextitTest.php
├── composer.json
├── README.md
├── config
└── textit.php
└── CODE_OF_CONDUCT.md
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: dasundev
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | composer.lock
3 | docs
4 | vendor
5 | coverage
6 | .phpunit.result.cache
7 | .idea
8 | .php_cs.cache
9 |
--------------------------------------------------------------------------------
/src/helper.php:
--------------------------------------------------------------------------------
1 | app->singleton('textit', function () {
17 | return new Textit();
18 | });
19 | }
20 |
21 | /**
22 | * Bootstrap services.
23 | *
24 | * @return void
25 | */
26 | public function boot()
27 | {
28 | $this->publishes([
29 | __DIR__.'/../config/textit.php' => config_path('textit.php'),
30 | ], 'config');
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Dasun Tharanga
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.
22 |
--------------------------------------------------------------------------------
/tests/Feature/TextitTest.php:
--------------------------------------------------------------------------------
1 | assertIsString($result);
27 | }
28 |
29 | public function testAccountBalanceUsingFacade()
30 | {
31 | $result = Textit::balance();
32 |
33 | $this->assertIsFloat($result);
34 | }
35 |
36 | public function testSendMessageUsingHelper()
37 | {
38 | $to = "07XXXXXXXX"; //replace with your mobile no
39 | $text = "Hello! This is a test message from Laravel Textit";
40 |
41 | $result = textit()->sms($to, $text);
42 |
43 | $this->assertIsString($result);
44 | }
45 |
46 | public function testAccountBalanceUsingHelper()
47 | {
48 | $result = textit()->balance();
49 |
50 | $this->assertIsFloat($result);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dasundev/laravel-textit",
3 | "description": "Laravel package for Textit SMS Gateway in Sri Lanka",
4 | "type": "library",
5 | "keywords": [
6 | "textit",
7 | "sms",
8 | "gateway"
9 | ],
10 | "homepage": "https://github.com/dasundev/laravel-textit",
11 | "require": {
12 | "laravel/framework": "*",
13 | "guzzlehttp/guzzle": "^7.4",
14 | "php": "^7.2.5|^8.0"
15 | },
16 | "require-dev": {
17 | "phpunit/phpunit": "^9.5"
18 | },
19 | "license": "MIT",
20 | "autoload": {
21 | "files": [
22 | "src/helper.php"
23 | ],
24 | "psr-4": {
25 | "Dasundev\\LaravelTextit\\": "src/"
26 | }
27 | },
28 | "autoload-dev": {
29 | "psr-4": {
30 | "Dasundev\\LaravelTextit\\Tests\\": "tests/"
31 | }
32 | },
33 | "extra": {
34 | "laravel": {
35 | "providers": [
36 | "Dasundev\\LaravelTextit\\TextitServiceProvider"
37 | ],
38 | "aliases": {
39 | "Textit": "Dasundev\\LaravelTextit\\Support\\Facades\\Textit"
40 | }
41 | }
42 | },
43 | "authors": [
44 | {
45 | "name": "Dasun Tharanga",
46 | "email": "hello@dasun.dev"
47 | }
48 | ],
49 | "minimum-stability": "dev",
50 | "prefer-stable": true
51 | }
52 |
--------------------------------------------------------------------------------
/src/Textit.php:
--------------------------------------------------------------------------------
1 | client = new Client([
31 | 'base_uri' => 'https://www.textit.biz'
32 | ]);
33 | }
34 |
35 | /**
36 | * Send a message to the user
37 | *
38 | * @param string $to
39 | * @param string $message
40 | * @return string
41 | * @throws \GuzzleHttp\Exception\GuzzleException
42 | */
43 | public function sms(string $to, string $message): string
44 | {
45 | $response = $this->client->get('sendmsg', [
46 | 'query' => [
47 | 'id' => config('textit.id'),
48 | 'pw' => config('textit.pw'),
49 | 'to' => $to,
50 | 'text' => $message
51 | ]
52 | ]);
53 |
54 | $result = explode(":", (string) $response->getBody());
55 |
56 | if (trim($result[0]) == "OK") {
57 | return "Message sent - Result: " . $result[1];
58 | } else {
59 | return "Sent Failed - Error: " . $result[1];
60 | }
61 | }
62 |
63 | /**
64 | * Check textit account balance
65 | *
66 | * @return float
67 | * @throws \GuzzleHttp\Exception\GuzzleException
68 | */
69 | public function balance(): float
70 | {
71 | $response = $this->client->get('creditchk', [
72 | 'query' => [
73 | 'id' => config('textit.id'),
74 | 'pw' => config('textit.pw')
75 | ]
76 | ]);
77 |
78 | return (float) (string) $response->getBody();
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | # Laravel Textit
12 |
13 | Laravel Textit will help you to integrate the Textit SMS
14 | gateway very easily on your laravel application.
15 |
16 | This package has been developed for [https://textit.biz](https://textit.biz/)
17 |
18 | Therefore, you must have an active textit account with sufficient balance to send SMS.
19 |
20 | ## Installation
21 |
22 | 1. You can install this package via composer:
23 | ```bash
24 | composer require dasundev/laravel-textit
25 | ```
26 | 2. You can publish the config file with:
27 | ```bash
28 | php artisan vendor:publish --provider="Dasundev\LaravelTextit\TextitServiceProvider" --tag="config"
29 | ```
30 | ## ENV Keys
31 |
32 | * Add following environment keys to your .env file. then replace with your Account ID & Password.
33 |
34 | ```dotenv
35 | TEXTIT_ACCOUNT_ID=94XXXXXXXXX
36 | TEXTIT_ACCOUNT_PASSWORD=1234
37 | ```
38 | * Optional environment keys(currently not available).
39 |
40 | ```dotenv
41 | TEXTIT_CUSTOM_SENDER_ID=Textit
42 | TEXTIT_ECO=Y
43 | TEXTIT_REPLY_NUMBER=07XXXXXXXX
44 | TEXTIT_REPLY_URL=https://your-domain.com/textit/replies
45 | ```
46 |
47 | ## Usage
48 |
49 | * Send message to a user.
50 | ```php
51 | Textit::sms('07XXXXXXXX', 'Your order has been delivered!'); // using facade
52 | textit()->sms('07XXXXXXXX', 'Your order has been delivered!'); // using helper function
53 | ```
54 | * Check your textit account balance.
55 | ```php
56 | $balance = Textit::balance(); // using facade
57 | $balance = textit()->balance(); // using helper function
58 | ```
59 | ### License
60 |
61 | Copyright © Dasun Tharanga
62 |
63 | Laravel Textit is open-sourced software licensed under the MIT license.
64 |
65 |
--------------------------------------------------------------------------------
/config/textit.php:
--------------------------------------------------------------------------------
1 | env('TEXTIT_ACCOUNT_ID', ''),
22 |
23 | /*
24 | |--------------------------------------------------------------------------
25 | | Password
26 | |--------------------------------------------------------------------------
27 | |
28 | | The textit account password that you need to authorize your account.
29 | |
30 | |
31 | */
32 |
33 | 'pw' => env('TEXTIT_ACCOUNT_PASSWORD', ''),
34 |
35 | /*
36 | |--------------------------------------------------------------------------
37 | | Custom Sender ID
38 | |--------------------------------------------------------------------------
39 | |
40 | | Pre‐registered custom Sender ID (case sensitive)
41 | |
42 | |
43 | */
44 |
45 | 'from' => env('TEXTIT_CUSTOM_SENDER_ID', ''),
46 |
47 | /*
48 | |--------------------------------------------------------------------------
49 | | Economy Route
50 | |--------------------------------------------------------------------------
51 | |
52 | | Selects economy route to send messages
53 | |
54 | |
55 | */
56 |
57 | 'eco' => env('TEXTIT_ECO', ''),
58 |
59 | /*
60 | |--------------------------------------------------------------------------
61 | | Reply Mobile Number
62 | |--------------------------------------------------------------------------
63 | |
64 | | Replies forwarded to the registered mobile number
65 | |
66 | |
67 | */
68 |
69 | 'reply' => env('TEXTIT_REPLY_NUMBER', ''),
70 |
71 | /*
72 | |--------------------------------------------------------------------------
73 | | Reply URL
74 | |--------------------------------------------------------------------------
75 | |
76 | | Replies will be posted to the given url
77 | |
78 | |
79 | */
80 |
81 | 'url' => env('TEXTIT_REPLY_URL', ''),
82 | ];
83 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | We as members, contributors, and leaders pledge to make participation in our
6 | community a harassment-free experience for everyone, regardless of age, body
7 | size, visible or invisible disability, ethnicity, sex characteristics, gender
8 | identity and expression, level of experience, education, socio-economic status,
9 | nationality, personal appearance, race, religion, or sexual identity
10 | and orientation.
11 |
12 | We pledge to act and interact in ways that contribute to an open, welcoming,
13 | diverse, inclusive, and healthy community.
14 |
15 | ## Our Standards
16 |
17 | Examples of behavior that contributes to a positive environment for our
18 | community include:
19 |
20 | * Demonstrating empathy and kindness toward other people
21 | * Being respectful of differing opinions, viewpoints, and experiences
22 | * Giving and gracefully accepting constructive feedback
23 | * Accepting responsibility and apologizing to those affected by our mistakes,
24 | and learning from the experience
25 | * Focusing on what is best not just for us as individuals, but for the
26 | overall community
27 |
28 | Examples of unacceptable behavior include:
29 |
30 | * The use of sexualized language or imagery, and sexual attention or
31 | advances of any kind
32 | * Trolling, insulting or derogatory comments, and personal or political attacks
33 | * Public or private harassment
34 | * Publishing others' private information, such as a physical or email
35 | address, without their explicit permission
36 | * Other conduct which could reasonably be considered inappropriate in a
37 | professional setting
38 |
39 | ## Enforcement Responsibilities
40 |
41 | Community leaders are responsible for clarifying and enforcing our standards of
42 | acceptable behavior and will take appropriate and fair corrective action in
43 | response to any behavior that they deem inappropriate, threatening, offensive,
44 | or harmful.
45 |
46 | Community leaders have the right and responsibility to remove, edit, or reject
47 | comments, commits, code, wiki edits, issues, and other contributions that are
48 | not aligned to this Code of Conduct, and will communicate reasons for moderation
49 | decisions when appropriate.
50 |
51 | ## Scope
52 |
53 | This Code of Conduct applies within all community spaces, and also applies when
54 | an individual is officially representing the community in public spaces.
55 | Examples of representing our community include using an official e-mail address,
56 | posting via an official social media account, or acting as an appointed
57 | representative at an online or offline event.
58 |
59 | ## Enforcement
60 |
61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
62 | reported to `hello@dasun.dev`.
63 | All complaints will be reviewed and investigated promptly and fairly.
64 |
65 | All community leaders are obligated to respect the privacy and security of the
66 | reporter of any incident.
67 |
68 | ## Enforcement Guidelines
69 |
70 | Community leaders will follow these Community Impact Guidelines in determining
71 | the consequences for any action they deem in violation of this Code of Conduct:
72 |
73 | ### 1. Correction
74 |
75 | **Community Impact**: Use of inappropriate language or other behavior deemed
76 | unprofessional or unwelcome in the community.
77 |
78 | **Consequence**: A private, written warning from community leaders, providing
79 | clarity around the nature of the violation and an explanation of why the
80 | behavior was inappropriate. A public apology may be requested.
81 |
82 | ### 2. Warning
83 |
84 | **Community Impact**: A violation through a single incident or series
85 | of actions.
86 |
87 | **Consequence**: A warning with consequences for continued behavior. No
88 | interaction with the people involved, including unsolicited interaction with
89 | those enforcing the Code of Conduct, for a specified period of time. This
90 | includes avoiding interactions in community spaces as well as external channels
91 | like social media. Violating these terms may lead to a temporary or
92 | permanent ban.
93 |
94 | ### 3. Temporary Ban
95 |
96 | **Community Impact**: A serious violation of community standards, including
97 | sustained inappropriate behavior.
98 |
99 | **Consequence**: A temporary ban from any sort of interaction or public
100 | communication with the community for a specified period of time. No public or
101 | private interaction with the people involved, including unsolicited interaction
102 | with those enforcing the Code of Conduct, is allowed during this period.
103 | Violating these terms may lead to a permanent ban.
104 |
105 | ### 4. Permanent Ban
106 |
107 | **Community Impact**: Demonstrating a pattern of violation of community
108 | standards, including sustained inappropriate behavior, harassment of an
109 | individual, or aggression toward or disparagement of classes of individuals.
110 |
111 | **Consequence**: A permanent ban from any sort of public interaction within
112 | the community.
113 |
114 | ## Attribution
115 |
116 | This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117 | version 2.0, available at
118 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
119 |
120 | Community Impact Guidelines were inspired by [Mozilla's code of conduct
121 | enforcement ladder](https://github.com/mozilla/diversity).
122 |
123 | [homepage]: https://www.contributor-covenant.org
124 |
125 | For answers to common questions about this code of conduct, see the FAQ at
126 | https://www.contributor-covenant.org/faq. Translations are available at
127 | https://www.contributor-covenant.org/translations.
128 |
--------------------------------------------------------------------------------