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:

  • The parameters to create

Options Hash (options):

  • :domain_name (String)

    The sending domain name

Returns:

  • Created sending domain

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

  • If invalid options are provided



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:

  • The sending domain ID

Returns:

  • nil

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made



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:

  • The sending domain ID

Returns:

  • Sending domain object

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made



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:

  • Array of sending domains

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made



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:

  • The sending domain ID

  • The email for instructions

Returns:

  • nil

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made



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:

  • The sending domain ID

  • 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:

  • Updated sending domain

Raises:

  • If the API request fails with a client or server error

  • If the API key is invalid

  • If the server refuses to process the request

  • If too many requests are made

  • If invalid options are provided



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

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