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 (Integer)

    the account ID

  • domain_id (#to_s)

    The domain ID or domain name

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

    the filtering and sorting option

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Returns:

Raises:

See Also:


56
57
58
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 56

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 (Integer)

    the account ID

  • domain_id (#to_s)

    The domain ID or domain name

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

Returns:

Raises:

See Also:


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

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 (Integer)

    the account ID

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


110
111
112
113
114
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 110

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 (Integer)

    the account ID

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


90
91
92
93
94
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 90

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")

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    The domain ID or domain name

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Returns:

Raises:

See Also:


30
31
32
33
34
# File 'lib/dnsimple/client/domains_email_forwards.rb', line 30

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