Class: Dnsimple::Client::ServicesService

Inherits:
ClientService show all
Defined in:
lib/dnsimple/client/services_service.rb

Instance Attribute Summary

Attributes inherited from ClientService

#client

Instance Method Summary collapse

Instance Method Details

#applied(domain) ⇒ Array<Service>

Lists the services applied to a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Returns:

Raises:

See Also:


41
42
43
44
45
# File 'lib/dnsimple/client/services_service.rb', line 41

def applied(domain)
  response = client.get("v1/domains/#{domain}/applied_services")

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

#apply(domain, service) ⇒ 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:


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

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

#available(domain) ⇒ Array<Service>

Lists the services not applied to a domain.

Parameters:

  • domain (#to_s)

    The domain id or domain name.

Returns:

Raises:

See Also:


56
57
58
59
60
# File 'lib/dnsimple/client/services_service.rb', line 56

def available(domain)
  response = client.get("v1/domains/#{domain}/available_services")

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

#find(service) ⇒ Service

Gets a service.

Parameters:

  • service (Fixnum)

    The service id.

Returns:

Raises:

See Also:


26
27
28
29
30
# File 'lib/dnsimple/client/services_service.rb', line 26

def find(service)
  response = client.get("v1/services/#{service}")

  Service.new(response["service"])
end

#listArray<Service>

Lists the supported services.

Returns:

Raises:

See Also:


11
12
13
14
15
# File 'lib/dnsimple/client/services_service.rb', line 11

def list
  response = client.get("v1/services")

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

#unapply(domain, service) ⇒ 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:


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

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