Sha256: b7367e03c45b76d3956e5ea32152ee346a99af151f25ed543621d2424e6932f7

Contents?: true

Size: 1.37 KB

Versions: 8

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require "resend/request"

module Resend
  # Module responsible for wrapping email sending API
  module Emails
    class << self
      # Sends or schedules an email.
      # see more: https://resend.com/docs/api-reference/send-email
      def send(params)
        path = "emails"
        Resend::Request.new(path, params, "post").perform
      end

      # Retrieve a single email.
      # see more: https://resend.com/docs/api-reference/emails/retrieve-email
      def get(email_id = "")
        path = "emails/#{email_id}"
        Resend::Request.new(path, {}, "get").perform
      end

      # Update a scheduled email.
      # see more: https://resend.com/docs/api-reference/emails/update-email
      def update(params)
        path = "emails/#{params[:email_id]}"
        Resend::Request.new(path, params, "patch").perform
      end

      # Cancel a scheduled email.
      # see more: https://resend.com/docs/api-reference/emails/cancel-email
      def cancel(email_id = "")
        path = "emails/#{email_id}/cancel"
        Resend::Request.new(path, {}, "post").perform
      end
    end

    # This method is kept here for backwards compatibility
    # Use Resend::Emails.send instead.
    def send_email(params)
      warn "[DEPRECATION] `send_email` is deprecated.  Please use `Resend::Emails.send` instead."
      Resend::Emails.send(params)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
resend-0.18.0 lib/resend/emails.rb
resend-0.17.2 lib/resend/emails.rb
resend-0.17.1 lib/resend/emails.rb
resend-0.17.0 lib/resend/emails.rb
resend-0.16.0 lib/resend/emails.rb
resend-0.15.0 lib/resend/emails.rb
resend-0.14.0 lib/resend/emails.rb
resend-0.13.0 lib/resend/emails.rb