Module: EmailFuse::Emails

Included in:
Client
Defined in:
lib/email_fuse/emails.rb,
lib/email_fuse/emails/receiving.rb,
lib/email_fuse/emails/attachments.rb,
lib/email_fuse/emails/receiving/attachments.rb

Overview

Module responsible for wrapping email sending API

Defined Under Namespace

Modules: Attachments, Receiving

Class Method Summary collapse

Class Method Details

.cancel(email_id = "") ⇒ Object

Cancel a scheduled email. see more: resend.com/docs/api-reference/emails/cancel-email



30
31
32
33
# File 'lib/email_fuse/emails.rb', line 30

def cancel(email_id = "")
  path = "emails/#{email_id}/cancel"
  EmailFuse::Request.new(path, {}, "post").perform
end

.get(email_id = "") ⇒ Object

Retrieve a single email. see more: resend.com/docs/api-reference/emails/retrieve-email



16
17
18
19
# File 'lib/email_fuse/emails.rb', line 16

def get(email_id = "")
  path = "emails/#{email_id}"
  EmailFuse::Request.new(path, {}, "get").perform
end

.list(options = {}) ⇒ Object

List emails with optional pagination. see more: resend.com/docs/api-reference/emails/list-emails

Parameters:

  • options (Hash) (defaults to: {})

    Optional parameters for pagination

Options Hash (options):

  • :limit (Integer)

    Maximum number of emails to return (1-100, default 20)

  • :after (String)

    Cursor for pagination (newer emails)

  • :before (String)

    Cursor for pagination (older emails)



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/email_fuse/emails.rb', line 42

def list(options = {})
  path = "emails"

  # Build query parameters, filtering out nil values
  query_params = {}
  query_params[:limit] = options[:limit] if options[:limit]
  query_params[:after] = options[:after] if options[:after]
  query_params[:before] = options[:before] if options[:before]

  EmailFuse::Request.new(path, query_params, "get").perform
end

.send(params, options: {}) ⇒ Object

Sends or schedules an email. see more: resend.com/docs/api-reference/emails/send-email



9
10
11
12
# File 'lib/email_fuse/emails.rb', line 9

def send(params, options: {})
  path = "emails"
  EmailFuse::Request.new(path, params, "post", options: options).perform
end

.update(params) ⇒ Object

Update a scheduled email. see more: resend.com/docs/api-reference/emails/update-email



23
24
25
26
# File 'lib/email_fuse/emails.rb', line 23

def update(params)
  path = "emails/#{params[:email_id]}"
  EmailFuse::Request.new(path, params, "patch").perform
end