Class: Mailtrap::SendingDomainsAPI

Inherits:
Object
  • Object
show all
Includes:
BaseAPI
Defined in:
lib/mailtrap/sending_domains_api.rb

Instance Attribute Summary

Attributes included from BaseAPI

#account_id, #client

Instance Method Summary collapse

Methods included from BaseAPI

included, #initialize

Instance Method Details

#create(options) ⇒ SendingDomain

Creates a new sending domain

Parameters:

  • options (Hash)

    The parameters to create

Options Hash (options):

  • :domain_name (String)

    The sending domain name

Returns:

Raises:



42
43
44
# File 'lib/mailtrap/sending_domains_api.rb', line 42

def create(options)
  base_create(options, %i[domain_name])
end

#delete(domain_id) ⇒ Object

Deletes a sending domain

Parameters:

  • domain_id (Integer)

    The sending domain ID

Returns:

  • nil

Raises:



50
51
52
# File 'lib/mailtrap/sending_domains_api.rb', line 50

def delete(domain_id)
  base_delete(domain_id)
end

#get(domain_id) ⇒ SendingDomain

Retrieves a specific sending domain

Parameters:

  • domain_id (Integer)

    The sending domain ID

Returns:

Raises:



32
33
34
# File 'lib/mailtrap/sending_domains_api.rb', line 32

def get(domain_id)
  base_get(domain_id)
end

#listArray<SendingDomain>

Lists all sending domains for the account

Returns:

Raises:



23
24
25
26
# File 'lib/mailtrap/sending_domains_api.rb', line 23

def list
  response = client.get(base_path)
  response[:data].map { |item| handle_response(item) }
end

#send_setup_instructions(domain_id, email:) ⇒ Object

Email DNS configuration instructions for the sending domain

Parameters:

  • domain_id (Integer)

    The sending domain ID

  • email (String)

    The email for instructions

Returns:

  • nil

Raises:



74
75
76
# File 'lib/mailtrap/sending_domains_api.rb', line 74

def send_setup_instructions(domain_id, email:)
  client.post("#{base_path}/#{domain_id}/send_setup_instructions", email:)
end

#update(domain_id, options) ⇒ SendingDomain

Updates configuration settings for a sending domain

Parameters:

  • domain_id (Integer)

    The sending domain ID

  • options (Hash)

    The parameters to update

Options Hash (options):

  • :open_tracking_enabled (Boolean)

    Enable open tracking for emails sent from this domain

  • :click_tracking_enabled (Boolean)

    Enable click tracking for links in emails sent from this domain

  • :tracking_opt_out_enabled (Boolean)

    Enable the tracking opt-out link in tracked emails

  • :auto_unsubscribe_link_enabled (Boolean)

    Automatically add an unsubscribe link to emails

  • :inbound_enabled (Boolean)

    Enable inbound email for this domain

Returns:

Raises:



65
66
67
# File 'lib/mailtrap/sending_domains_api.rb', line 65

def update(domain_id, options)
  base_update(domain_id, options)
end