Sha256: 66e53ae29547bdcff6a16afccd348593658a846b7a3c2ed45b58a6bd0021a37a

Contents?: true

Size: 995 Bytes

Versions: 9

Compression:

Stored size: 995 Bytes

Contents

module DNSimple

  # Represents a service that can be applied to a domain.
  class Service < Base

    attr_accessor :id

    attr_accessor :name

    attr_accessor :short_name

    attr_accessor :description

    # Find a service by its ID or short name
    def self.find(id_or_short_name, options={})
      id = id_or_short_name
      response = DNSimple::Client.get("/v1/services/#{id}", options)

      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

    # Get all of the services that can be applied to a domain
    def self.all(options={})
      response = DNSimple::Client.get("/v1/services", options)

      case response.code
      when 200
        response.map { |r| new(r["service"]) }
      else
        raise RequestError.new("Error listing services", response)
      end
    end

  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
dnsimple-ruby-1.7.1 lib/dnsimple/service.rb
dnsimple-ruby-1.7.0 lib/dnsimple/service.rb
dnsimple-ruby-1.6.0 lib/dnsimple/service.rb
dnsimple-2.0.0.a lib/dnsimple/service.rb
dnsimple-ruby-1.5.5 lib/dnsimple/service.rb
dnsimple-ruby-1.5.4 lib/dnsimple/service.rb
dnsimple-ruby-1.5.3 lib/dnsimple/service.rb
dnsimple-ruby-1.5.2 lib/dnsimple/service.rb
dnsimple-ruby-1.5.1 lib/dnsimple/service.rb