Class: Testcloud::Devices::Client

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



36
37
38
39
40
41
# File 'lib/testcloud/devices/client.rb', line 36

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

Instance Attribute Details

#api_tokenObject

Returns the value of attribute api_token.



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

def api_token
  @api_token
end

#categoryObject

Returns the value of attribute category.



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

def category
  @category
end

#raw_responseObject

Returns the value of attribute raw_response.



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

def raw_response
  @raw_response
end

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.api_tokenObject



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

def api_token
  @api_token
end

.api_token=(value) ⇒ Object



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

def api_token=(value)
  @api_token = value
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:



15
16
17
# File 'lib/testcloud/devices/client.rb', line 15

def setup(&block)
  yield(self)
end

.urlObject



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

def url
  @url
end

.url=(value) ⇒ Object



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

def url=(value)
  @url = value
end

Instance Method Details

#categoriesObject



48
49
50
51
# File 'lib/testcloud/devices/client.rb', line 48

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

#form_dataObject



58
59
60
61
# File 'lib/testcloud/devices/client.rb', line 58

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

#typesObject



43
44
45
46
# File 'lib/testcloud/devices/client.rb', line 43

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

#validate(data = {}) ⇒ Object



53
54
55
56
# File 'lib/testcloud/devices/client.rb', line 53

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