ringlesoft / jasmin-client
A laravel package for interacting with Jasmin SMS Gateway
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:laravel-plugin
Requires
- php: >=8.1
- glushkovds/php-smpp: ^0.7.1
- illuminate/collections: ^10.0|^11.23
- illuminate/http: ^10.0|^11.23
- illuminate/support: ^10.0|^11.23
- illuminate/validation: ^10.0|^11.23
Requires (Dev)
- phpunit/phpunit: ^11.3
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-11-30 15:04:08 UTC
README
A Laravel package for seamless integration with Jasmin SMS Gateway, supporting HTTP, REST API, and SMPP connections.
Features
- Easy-to-use interface for sending and receiving SMS
- Support for HTTP and REST API jasmin options
- SMPP support is coming soon
- Delivery report handling
Installation
You can install the package via composer:
composer require ringlesoft/jasmin-client
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="RingleSoft\JasminClient\JasminClientServiceProvider"
Then, edit the config/jasmin_client.php
file with your Jasmin SMS Gateway credentials and preferred settings.
Available configurations
The following are available configurations. Most of these are just defaults and can be overridden in your code
url
: The base url of the jasmin server (include the port if different from80
or443/446
)username
: The username for your jasmin accountpassword
: The password for your jasmin accountdlr_callback_url
: The default sms delivery callback urlbatch_callback_url
: the default batch callback urlbatch_errback_url
: the default batch errback urldefault_dlr_method
: the default dlr method (GET/POST)default_dlr_level
: The default DLR level (1, 2, or 3)batch_chunk_size
: The default Chunk size for batches
Usage
Sending an SMS
Sending a single message (Http & Rest)
$sms = JasminClient::message() ->content('Hello there! Have a nice day') ->to("255711000000") ->from('INFO') ->via('rest') // 'rest' or 'http' ->send();
- Returns
RingleSoft\JasminClient\Models\Jasmin\SentMessage
Sending multiple messages as a batch (Rest only)
$message = JasminClient::message(to: "255711000000", content: "Hello There. Have a nice day"); $message2 = JasminClient::message(to: "255711000002", content: "Hello There. Have a nice day"); $batch = JasminClient::batch() ->addMessage($message) ->addMessage($message2) ->from("INFO") ->send();
- Returns
RingleSoft\JasminClient\Models\Jasmin\SentBatch
Handling Delivery Statuses
This package provides a streamlined way to handle delivery statuses.
Class DlrController extends Controller { public function handleDlr(Request $request) { return JasminClient::receiveDlrCallback($request, function(DeliveryCallback $dlr) { // do something with the dlr and return true for success or false for failure // For example, you can dispatch a job to process the Delivery Report return true; }); } }
Handling Batch Callback Requests
When messages are sent in a batch, Jasmin responds with the ID of the batch created (batchId
) and enqueue the messages.
When each message is sent to SMC, jasmin fires a callback (batch callback) with messageId
of each message within the
batch.
To handle batch callbacks, you can use the receiveBatchCallback
method.
Class DlrController extends Controller { public function handleDlr(Request $request) { return JasminClient::receiveDlrCallback($request, function(DeliveryCallback $dlr) { // do something with the dlr and return true for success or false for failure // For example, you can dispatch a job to process Batch Callback return true; }); } }
Checking rates (Http & Rest)
$route = JasminClient::rest()->checkRoute("255711000000");
Checking account balance (Http & Rest)
$balance = JasminClient::rest()->checkBalance();
Monitoring Metrics (Http)
$metrics = JasminClient::http()->getMetrics();
Contributing
I'll soon let you know when you can contribute to this project.
License
This package is open-sourced software licensed under the MIT license.
Support
Contacts
Follow me on X: @ringunger
Email me: ringunger@gmail.com
Website: https://ringlesoft.com
Note: This package is still under development. Please report any issues you encounter.