1.0.0 • Published 4 months ago

edith-sdk v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
4 months ago

EDITH - Email Service SDK

A TypeScript/JavaScript SDK for interacting with the Sparrow Email Service API.

Installation

npm install @sparroweng/edith

Usage

import { EdithClient } from "@sparroweng/edith";

// Initialize the client
const client = new EdithClient({
  apiKey: "your-api-key-here",
  // Optional: specify a different base path
  // basePath: 'https://api.yourdomain.com'
});

// Send a simple email
await client.sendSimpleEmail({
  from: "sender@example.com",
  to: ["recipient@example.com"],
  subject: "Hello from EDITH",
  html: "<h1>Hello World</h1>",
  text: "Hello World",
  mailer_id: "your-mailer-id",
});

// Add a domain
await client.addDomain({
  domain: "example.com",
});

// Configure SMTP
await client.configureSMTP({
  name: "My SMTP Config",
  config_type: "basic",
  connection_type: "tls",
  host: "smtp.example.com",
  port: 587,
  username: "smtp_user",
  password: "smtp_password",
});

// Get SMTP configuration
const smtpConfig = await client.getSMTPConfig("your-mailer-id");

// Register a webhook
await client.registerWebhook({
  url: "https://your-webhook-endpoint.com",
  events: ["email.sent", "email.delivered", "email.failed"],
});

Features

  • Send emails with HTML and plain text content
  • Manage email domains
  • Configure SMTP settings
  • Configure IMAP settings
  • Manage webhooks
  • Handle inbound email routing

API Reference

Email Operations

  • sendSimpleEmail(payload: SimpleEmailPayload): Send an email with a simplified payload
  • sendEmail(payload: RequestmodelsEmailPayload): Send an email with full configuration options

Domain Operations

  • addDomain(payload: RequestmodelsDomainPayload): Add a new domain
  • getDomain(domain: string): Get domain details
  • verifyDomain(domain: string): Verify a domain
  • deleteDomain(domain: string): Delete a domain

SMTP Operations

  • configureSMTP(payload: RequestmodelsCreateSMTPPayload): Configure SMTP settings
  • updateSMTP(payload: RequestmodelsUpdateSMTPPayload): Update SMTP configuration
  • getSMTPConfig(mailerId: string): Get SMTP configuration
  • deleteSMTPConfig(mailerId: string): Delete SMTP configuration

IMAP Operations

  • configureIMAP(payload: RequestmodelsCreateIMAPPayload): Configure IMAP settings
  • updateIMAP(payload: RequestmodelsUpdateIMAPPayload): Update IMAP configuration
  • getIMAPConfig(mailerId: string): Get IMAP configuration
  • deleteIMAPConfig(mailerId: string): Delete IMAP configuration

Webhook Operations

  • registerWebhook(payload: RequestmodelsWebhookCreatePayload): Register a webhook
  • updateWebhook(payload: RequestmodelsWebhookUpdatePayload): Update webhook settings
  • deleteWebhook(payload: RequestmodelsWebhookDeletePayload): Delete a webhook

Inbound Email Operations

  • configureInboundRouting(payload: RequestmodelsIncomingDomainPayload): Configure inbound email routing
  • updateInboundDomain(domain: string, payload: RequestmodelsUpdateIncomingDomainPayload): Update inbound domain configuration

Development

# Install dependencies
npm install

# Generate API types from swagger.json
npm run generate

# Build the SDK
npm run build

# Run the example
npm run test:example

License

ISC

Support

For support, please open an issue in the GitHub repository.

1.0.0

4 months ago