Class: DNSimple::Service
Overview
Represents a service that can be applied to a domain.
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#short_name ⇒ Object
Returns the value of attribute short_name.
Class Method Summary collapse
-
.all(options = {}) ⇒ Object
Get all of the services that can be applied to a domain.
-
.find(id_or_short_name, options = {}) ⇒ Object
Find a service by its ID or short name.
Methods inherited from Base
Constructor Details
This class inherits a constructor from DNSimple::Base
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
12 13 14 |
# File 'lib/dnsimple/service.rb', line 12 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/dnsimple/service.rb', line 6 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/dnsimple/service.rb', line 8 def name @name end |
#short_name ⇒ Object
Returns the value of attribute short_name.
10 11 12 |
# File 'lib/dnsimple/service.rb', line 10 def short_name @short_name end |
Class Method Details
.all(options = {}) ⇒ Object
Get all of the services that can be applied to a domain
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dnsimple/service.rb', line 30 def self.all(={}) response = DNSimple::Client.get("/v1/services", ) case response.code when 200 response.map { |r| new(r["service"]) } else raise RequestError.new("Error listing services", response) end end |
.find(id_or_short_name, options = {}) ⇒ Object
Find a service by its ID or short name
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/dnsimple/service.rb', line 15 def self.find(id_or_short_name, ={}) id = id_or_short_name response = DNSimple::Client.get("/v1/services/#{id}", ) case response.code when 200 new(response["service"]) when 404 raise RecordNotFound, "Could not find service #{id}" else raise RequestError.new("Error finding service", response) end end |