Class: Testcloud::Devices::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Resources
Defined in:
lib/testcloud/devices/client.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



24
25
26
27
28
29
# File 'lib/testcloud/devices/client.rb', line 24

def initialize(options = {})
  @type, @category = options[:type], options[:category]
  self.class.debug_output if options[:debug]
  self.class.base_uri(options[:url] || config.url || Testcloud::Devices::Config::DEFAULT_URL)
  config.api_token = options[:api_token] if options[:api_token]
end

Class Attribute Details

.configObject (readonly)

Returns the value of attribute config.



17
18
19
# File 'lib/testcloud/devices/client.rb', line 17

def config
  @config
end

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



9
10
11
# File 'lib/testcloud/devices/client.rb', line 9

def api_token
  @api_token
end

#categoryObject

Returns the value of attribute category.



9
10
11
# File 'lib/testcloud/devices/client.rb', line 9

def category
  @category
end

#raw_responseObject

Returns the value of attribute raw_response.



9
10
11
# File 'lib/testcloud/devices/client.rb', line 9

def raw_response
  @raw_response
end

#responseObject

Returns the value of attribute response.



9
10
11
# File 'lib/testcloud/devices/client.rb', line 9

def response
  @response
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/testcloud/devices/client.rb', line 9

def type
  @type
end

Class Method Details

.setup {|@config| ... } ⇒ Object

Yields:



18
19
20
21
# File 'lib/testcloud/devices/client.rb', line 18

def setup(&block)
  @config = Testcloud::Devices::Config.new
  yield(@config)
end

Instance Method Details

#errors?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/testcloud/devices/client.rb', line 31

def errors?
  return true if raw_response.code >= 300
  return true if response.has_key?(:errors)
  false
end