Module: Dnsimple::Client::DomainsEmailForwards

Included in:
DomainsService
Defined in:
lib/dnsimple/client/domains_email_forwards.rb

Instance Method Summary collapse

Instance Method Details

#all_email_forwards(account_id, domain_id, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::EmailForward>

Lists ALL the email forwards for the domain.

This method is similar to #email_forwards, but instead of returning the results of a specific page it iterates all the pages and returns the entire collection.

Please use this method carefully, as fetching the entire collection will increase the number of requests you send to the API server and you may eventually risk to hit the throttle limit.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

    the filtering and sorting option

Returns:

Raises:

See Also:



45
46
47
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 45

def all_email_forwards(, domain_id, options = {})
  paginate(:email_forwards, , domain_id, options)
end

#create_email_forward(account_id, domain_id, attributes, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::EmailForward>

Creates an email forward for the domain.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:



60
61
62
63
64
65
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 60

def create_email_forward(, domain_id, attributes, options = {})
  Extra.validate_mandatory_attributes(attributes, [:from, :to])
  response = client.post(Client.versioned("/%s/domains/%s/email_forwards" % [, domain_id]), attributes, options)

  Dnsimple::Response.new(response, Struct::EmailForward.new(response["data"]))
end

#delete_email_forward(account_id, domain_id, email_forward_id, options = {}) ⇒ Dnsimple::Response<nil>

Deletes an email forward for the domain.

WARNING: this cannot be undone.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

  • email_forward_id (#to_s)

    The email forward ID

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

Returns:

Raises:

See Also:



99
100
101
102
103
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 99

def delete_email_forward(, domain_id, email_forward_id, options = {})
  response = client.delete(Client.versioned("/%s/domains/%s/email_forwards/%s" % [, domain_id, email_forward_id]), nil, options)

  Dnsimple::Response.new(response, nil)
end

#email_forward(account_id, domain_id, email_forward_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::EmailForward>

Gets a email forward for the domain.

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

  • email_forward_id (#to_s)

    The email forward ID

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

Returns:

Raises:

See Also:



79
80
81
82
83
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 79

def email_forward(, domain_id, email_forward_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/email_forwards/%s" % [, domain_id, email_forward_id]), options)

  Dnsimple::Response.new(response, Struct::EmailForward.new(response["data"]))
end

#email_forwards(account_id, domain_id, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::EmailForward>

Lists the email forwards for the domain.

Examples:

List email forwards in the first page

client.domains.email_forwards(1010, "example.com")

List email forwards, provide a specific page

client.domains.email_forwards(1010, "example.com", query: { page: 2 })

Parameters:

  • account_id (Fixnum, Dnsimple::Client::WILDCARD_ACCOUNT)

    the account ID or wildcard

  • domain_id (#to_s)

    The domain ID or domain name

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

    the filtering and sorting option

Returns:

Raises:

See Also:



22
23
24
25
26
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 22

def email_forwards(, domain_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/email_forwards" % [, domain_id]), options)

  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::EmailForward.new(r) })
end