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.

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Raises:

See Also:



54
55
56
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 54

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.



69
70
71
72
73
74
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 69

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.



108
109
110
111
112
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 108

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.



88
89
90
91
92
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 88

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", page: 2)

List email forwards, provide a sorting policy

client.domains.email_forwards(1010, "example.com", sort: "from:asc")

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Raises:

See Also:



28
29
30
31
32
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 28

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

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