plexisms 1.0.2 copy "plexisms: ^1.0.2" to clipboard
plexisms: ^1.0.2 copied to clipboard

A Dart client for the PlexiSMS API.

Plexisms Dart SDK #

A Dart client for the PlexiSMS API.

Features #

  • Send SMS messages (individual and bulk)
  • Check your account balance
  • Verify phone numbers with OTP

Getting started #

Add the dependency to your pubspec.yaml:

dependencies:
  plexisms: ^1.0.2

Or install it via command line:

dart pub add plexisms

Usage #

Initialization #

import 'dart:io';
import 'package:plexisms/plexisms.dart';

void main() async {
  // Initialize with API Key directly
  final client = Client('YOUR_API_KEY');

  // Or use environment variable PLEXISMS_API_KEY
  // final client = Client(Platform.environment['PLEXISMS_API_KEY']);
}

Sending SMS #

try {
  SmsResponse response = await client.messages.create(
    to: '+243970000000',
    body: 'Hello from PlexiSMS! 🚀',
    senderId: 'MyApp',
  );

  print('Message ID: ${response.messageId}');
  print('Status: ${response.status}');
} on PlexismsError catch (e) {
  print('Error: ${e.message}');
}

Checking Balance #

try {
  BalanceResponse balance = await client.account.balance();
  print('Balance: ${balance.balance} ${balance.currency}');
} catch (e) {
  print(e);
}

Sending OTP #

try {
  OtpResponse response = await client.otp.send(to: '+243970000000');
  print('Verification ID: ${response.verificationId}');
} catch (e) {
  print(e);
}

Error Handling #

The SDK throws specific exceptions for different error conditions:

  • AuthenticationError: Invalid API key or permissions (HTTP 401/403).
  • BalanceError: Insufficient funds (HTTP 402).
  • ValidationError: Invalid input data (HTTP 400/422).
  • APIError: Generic API errors or server issues (HTTP 500+).
1
likes
130
points
63
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart client for the PlexiSMS API.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http, meta

More

Packages that depend on plexisms