Class: Testcloud::Devices::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
15
# File 'lib/testcloud/devices/client.rb', line 10

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

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



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

def api_token
  @api_token
end

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#categoriesObject



22
23
24
25
# File 'lib/testcloud/devices/client.rb', line 22

def categories
  response = self.class.get("/devices/#{type.pluralize}/categories", access_headers)
  Response.new(response).keys
end

#form_dataObject



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

def form_data
  response = self.class.get("/devices/#{type}/#{category}/form_data", access_headers)
  Response.new(response)
end

#typesObject



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

def types
  response = self.class.get('/devices/types', access_headers)
  Response.new(response).keys
end

#validate(data = {}) ⇒ Object



27
28
29
30
# File 'lib/testcloud/devices/client.rb', line 27

def validate(data = {})
  response = self.class.post("/devices/#{type}/#{category}", access_headers.merge(body: data))
  Response.new(response)
end