uzbek/eskiz-sms-client

Eskiz.uz sms client

Installs: 96

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 2

Open Issues: 4

pkg:composer/uzbek/eskiz-sms-client


README

Latest Version on Packagist Total Downloads

Eskiz.uz sms client for Laravel.

Requirements

  • PHP 8.3+
  • Laravel 11.x or 12.x

Installation

You can install the package via composer:

composer require uzbek/eskiz-sms-client

You can publish the config file with:

php artisan vendor:publish --tag="eskiz-sms-client-config"

Add the following environment variables to your .env file:

ESKIZ_SMS_EMAIL=your-email@example.com
ESKIZ_SMS_PASSWORD=your-password
ESKIZ_SMS_FROM=4546

Usage

Sending SMS

use Uzbek\EskizSmsClient\Facades\Sms;

// Basic usage
$response = Sms::send('998901234567', 'Hello from Laravel!');

if ($response->isOk()) {
    echo "SMS sent! ID: " . $response->id;
}

// With custom sender
$response = Sms::send('998901234567', 'Hello!', 'CustomSender');

Getting User Info

$user = Sms::user();

echo $user->name;      // User name
echo $user->email;     // User email
echo $user->balance;   // Account balance
echo $user->isActive(); // true/false

Checking Limits

$limits = Sms::limits();

echo $limits->limit;           // Total limit
echo $limits->used;            // Used count
echo $limits->remaining;       // Remaining count
echo $limits->usagePercentage(); // Usage percentage (e.g., 25.5)
echo $limits->hasRemaining();  // true/false

Getting Balance

$balance = Sms::balance();

Refreshing Token

Sms::refreshToken();

Exception Handling

The package throws specific exceptions for different error scenarios:

use Uzbek\EskizSmsClient\Exceptions\AuthenticationException;
use Uzbek\EskizSmsClient\Exceptions\RateLimitException;
use Uzbek\EskizSmsClient\Exceptions\EskizException;

try {
    $response = Sms::send('998901234567', 'Hello!');
} catch (AuthenticationException $e) {
    // Invalid credentials or token issues
} catch (RateLimitException $e) {
    // Too many requests
    $retryAfter = $e->retryAfter; // Seconds to wait
} catch (EskizException $e) {
    // Other API errors
    $response = $e->response; // Raw API response
}

Response Objects

All methods return typed response objects:

  • SendResponse - SMS send result with id, status, message, phone
  • UserResponse - User info with id, name, email, role, status, balance, isVip
  • LimitResponse - Limits info with limit, used, remaining, resetAt

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.