Skip to main content

inboxiq 0.0.3 copy "inboxiq: ^0.0.3" to clipboard
inboxiq: ^0.0.3 copied to clipboard

A Dart SDK for InboxIQ email and SMS API.

InboxIQ #

A Dart SDK for the InboxIQ email and SMS API.

Disclaimer: This codebase is not affiliated with InboxIQ.

Installation #

Add inboxiq to your pubspec.yaml:

dependencies:
  inboxiq: ^0.0.3

Usage #

Initialize the client #

import 'package:inboxiq/inboxiq.dart';

final inboxiq = InboxIQ.initialize(
  username: 'your-username',
  password: 'your-password',
  apiKey: 'your-api-key',
);

Send an email #

final result = await inboxiq.sendEmail(
  SendEmailRequest(
    toRecipients: ['user@example.com'],
    subject: 'Welcome to InboxIQ!',
    body: '<h1>Hello!</h1><p>Welcome to our platform.</p>',
    from: 'noreply@yourdomain.com',
    applicationId: 123,
    personalName: 'John Doe',
  ),
);

switch (result) {
  case Success():
    print('Email queued successfully');
  case Error(:final error):
    print('Failed: ${error.message}');
}

Send an email with attachments #

final result = await inboxiq.sendEmail(
  SendEmailRequest(
    toRecipients: ['user@example.com'],
    subject: 'Your Invoice',
    body: '<p>Please find your invoice attached.</p>',
    from: 'billing@yourdomain.com',
    applicationId: 123,
    attachments: [
      Attachment(
        name: 'invoice.pdf',
        fileSourceUrl: 'https://yourdomain.com/files/invoice.pdf',
      ),
    ],
  ),
);

Send an SMS #

final result = await inboxiq.sendSms(
  SendSmsRequest(
    phoneNumber: '+263771234567',
    message: 'Your verification code is 123456',
    applicationId: 123,
  ),
);

switch (result) {
  case Success():
    print('SMS sent successfully');
  case Error(:final error):
    print('Failed: ${error.message}');
}

API Reference #

InboxIQ #

Method Description
sendEmail(SendEmailRequest) Send an email to one or more recipients
sendSms(SendSmsRequest) Send an SMS to a phone number

SendEmailRequest #

Parameter Type Required Description
toRecipients List<String> Yes Array of recipient email addresses
subject String Yes Email subject line
body String Yes Email body (HTML or plain text)
from String Yes Sender email (must be verified)
applicationId int Yes Your application ID from dashboard
plainText bool No Send as plain text (default: false)
personalName String No Sender's display name
attachments List<Attachment> No Email attachments

SendSmsRequest #

Parameter Type Required Description
phoneNumber String Yes Recipient phone number
message String Yes SMS message content
applicationId int Yes Your application ID from dashboard

Attachment #

Parameter Type Description
name String Attachment file name
fileSourceUrl String URL where the file is hosted

Error Handling #

The SDK uses a Result type for error handling:

final result = await inboxiq.sendEmail(request);

// Pattern matching
switch (result) {
  case Success():
    // Handle success
  case Error(:final error):
    print('Error ${error.statusCode}: ${error.message}');
}

// Or use helper methods
if (result.isSuccess) {
  // Handle success
}

if (result.isError) {
  final error = result.errorOrNull;
  print('Error: ${error?.message}');
}

// Or use when
result.when(
  success: (_) => print('Success!'),
  error: (e) => print('Error: ${e.message}'),
);

Error Codes #

Code Description
400 Bad Request - Missing or invalid parameters
401 Unauthorized - Invalid credentials
403 Forbidden - Insufficient permissions or credits
404 Not Found - Resource or endpoint not found
429 Too Many Requests - Rate limit exceeded
500 Server Error

Webhooks #

Handle incoming webhook events from InboxIQ on your Dart server.

Note: Webhooks are currently under development by InboxIQ. This SDK is ready for when they launch.

Setup #

import 'package:inboxiq/inboxiq.dart';

final handler = WebhookHandler(secret: 'your-webhook-secret');

Verify and Parse Webhooks #

// In your server route handler (e.g., Shelf, Dart Frog):
Future<Response> handleWebhook(Request request) async {
  final signature = request.headers[WebhookHandler.signatureHeader];
  final body = await request.readAsString();

  // Verify signature
  if (!handler.verifySignature(body, signature)) {
    return Response(401, body: 'Invalid signature');
  }

  // Parse event
  final event = handler.parseEvent(body);
  
  switch (event.event) {
    case WebhookEventType.emailDelivered:
      print('Email delivered to ${event.data.recipient}');
    case WebhookEventType.emailBounced:
      print('Email bounced: ${event.data.bounceType}');
    case WebhookEventType.emailOpened:
      print('Email opened at ${event.data.openedAt}');
    case WebhookEventType.emailClicked:
      print('Link clicked: ${event.data.clickedUrl}');
    case WebhookEventType.smsDelivered:
      print('SMS delivered to ${event.data.phoneNumber}');
    case WebhookEventType.smsFailed:
      print('SMS failed: ${event.data.errorMessage}');
    case WebhookEventType.unknown:
      print('Unknown event');
  }

  return Response.ok('OK');
}

Webhook Event Types #

Event Description
email.delivered Email successfully delivered
email.bounced Email bounced (hard or soft)
email.opened Recipient opened the email
email.clicked Recipient clicked a link
sms.delivered SMS successfully delivered
sms.failed SMS delivery failed

Webhook Payload Structure #

{
  "event": "email.delivered",
  "timestamp": "2025-01-23T14:30:00Z",
  "data": {
    "messageId": "msg_abc123def456",
    "recipient": "user@example.com",
    "subject": "Welcome to InboxIQ!",
    "deliveredAt": "2025-01-23T14:30:00Z",
    "status": "delivered"
  }
}

License #

MIT License - see LICENSE for details.

1
likes
140
points
23
downloads

Documentation

API reference

Publisher

verified publisheriamngoni.co.zw

Weekly Downloads

A Dart SDK for InboxIQ email and SMS API.

License

MIT (license)

Dependencies

crypto, dio, meta

More

Packages that depend on inboxiq