Module: Dnsimple::Client::ServicesDomains

Included in:
ServicesService
Defined in:
lib/dnsimple/client/services_domains.rb

Instance Method Summary collapse

Instance Method Details

#applied(domain, options = {}) ⇒ Array<Struct::Service>

Lists the services applied to a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Returns:

Raises:

See Also:



14
15
16
17
18
# File 'lib/dnsimple/client/services_domains.rb', line 14

def applied(domain, options = {})
  response = client.get(Client.versioned("domains/#{domain}/applied_services"), options)

  response.map { |r| Struct::Service.new(r["service"]) }
end

#apply(domain, service, options = {}) ⇒ void

This method returns an undefined value.

Applies a service to a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • service (Fixnum)

    The service id.

Raises:

See Also:



45
46
47
48
49
# File 'lib/dnsimple/client/services_domains.rb', line 45

def apply(domain, service, options = {})
  options  = Extra.deep_merge(options, { service: { id: service }})
  response = client.post(Client.versioned("domains/#{domain}/applied_services"), options)
  response.code == 200
end

#available(domain, options = {}) ⇒ Array<Struct::Service>

Lists the services not applied to a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Returns:

Raises:

See Also:



29
30
31
32
33
# File 'lib/dnsimple/client/services_domains.rb', line 29

def available(domain, options = {})
  response = client.get(Client.versioned("domains/#{domain}/available_services"), options)

  response.map { |r| Struct::Service.new(r["service"]) }
end

#unapply(domain, service, options = {}) ⇒ void

This method returns an undefined value.

Un-applies a service from a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

  • service (Fixnum)

    The service id.

Raises:

See Also:



61
62
63
64
# File 'lib/dnsimple/client/services_domains.rb', line 61

def unapply(domain, service, options = {})
  response = client.delete(Client.versioned("domains/#{domain}/applied_services/#{service}"), options)
  response.code == 200
end