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



36
37
38
# File 'lib/mailtrap/sending_domains_api.rb', line 36

def create(options)
  base_create(options)
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



44
45
46
# File 'lib/mailtrap/sending_domains_api.rb', line 44

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



26
27
28
# File 'lib/mailtrap/sending_domains_api.rb', line 26

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



17
18
19
20
# File 'lib/mailtrap/sending_domains_api.rb', line 17

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



53
54
55
# File 'lib/mailtrap/sending_domains_api.rb', line 53

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