mailtrap-nodejs icon indicating copy to clipboard operation
mailtrap-nodejs copied to clipboard

Restructure SDK

Open narekhovhannisyan opened this issue 6 months ago • 3 comments

Motivation

  1. The general and testing APIs are created lazily, after the first access to the corresponding getters.
  2. Missing params for the Testing API (here) are treated as errors (throw new Error(...)), not warnings.
  3. Updated the MailtrapClient to accept two more params: bulk: Boolean and sandbox: Boolean. They are changing the behavior of the send method of the client in the following way:
let host

if (this.bulk && this.sandbox) {
  throw new Error('bulk mode is not applicable for sandbox API');
}
else if (this.sandbox) {
  host = TESTING_ENDPOINT; // should be sandbox.api.mailtrap.io
}
else if (this.bulk) {
  host = BULK_SENDING_ENDPOINT;
}
else {
  host = SENDING_ENDPOINT;
}

In the sandbox mode, the client.send sends the email to the sandbox, in the bulk mode - to the Bulk API.

  1. Removes send methods from the BulkSendingAPI and TestingAPI classes. There should be only one send method on the MailtrapClient that will behave as described above.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new configuration for CodeQL analysis to enhance code quality checks.
    • Added support for bulk email sending in the Mailtrap client.
    • New examples for sending emails using Mailtrap and Nodemailer.
  • Bug Fixes

    • Improved error handling for incompatible bulk and sandbox modes in the Mailtrap client.
    • Added a new error message for bulk mode incompatibility with the sandbox API.
  • Documentation

    • Updated the README for better clarity on version compatibility.
  • Tests

    • Enhanced test coverage for MailtrapClient with new scenarios.
    • Removed outdated tests related to bulk email functionality.
    • Streamlined tests for the Testing class, focusing on essential functionality.
    • Updated import paths in examples for consistency and maintainability.

narekhovhannisyan avatar Aug 19 '24 10:08 narekhovhannisyan