Class: Mailtrap::DomainsAPI

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

Direct Known Subclasses

SendingDomainsAPI

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) ⇒ Domain

Creates a new domain

Parameters:

  • options (Hash) —

    The parameters to create

Options Hash (options):

  • :domain_name (String) —

    The domain name

Returns:

Raises:



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

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

#delete(domain_id) ⇒ Object

Deletes a domain

Parameters:

  • domain_id (Integer) —

    The domain ID

Returns:

  • nil

Raises:



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

def delete(domain_id)
  base_delete(domain_id)
end

#get(domain_id) ⇒ Domain

Retrieves a specific domain

Parameters:

  • domain_id (Integer) —

    The domain ID

Returns:

Raises:



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

def get(domain_id)
  base_get(domain_id)
end

#list ⇒ Array<Domain>

Lists all domains for the account

Returns:

  • (Array<Domain>) —

    Array of domains

Raises:



23
24
25
26
# File 'lib/mailtrap/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 domain

Parameters:

  • domain_id (Integer) —

    The domain ID

  • email (String) —

    The email for instructions

Returns:

  • nil

Raises:



74
75
76
# File 'lib/mailtrap/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) ⇒ Domain

Updates configuration settings for a domain

Parameters:

  • domain_id (Integer) —

    The 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/domains_api.rb', line 65

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