Class: Testcloud::Devices::Client
- Inherits:
-
Object
- Object
- Testcloud::Devices::Client
- Includes:
- HTTParty
- Defined in:
- lib/testcloud/devices/client.rb
Instance Attribute Summary collapse
-
#api_token ⇒ Object
Returns the value of attribute api_token.
-
#category ⇒ Object
Returns the value of attribute category.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #categories ⇒ Object
- #form_data ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #types ⇒ Object
- #validate(data = {}) ⇒ Object
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( = {}) @type, @category = [:type], [:category] self.class.debug_output if [:debug] self.class.base_uri([:url] || DEFAULT_URL) @api_token = [:api_token] || '' end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
8 9 10 |
# File 'lib/testcloud/devices/client.rb', line 8 def api_token @api_token end |
#category ⇒ Object
Returns the value of attribute category.
8 9 10 |
# File 'lib/testcloud/devices/client.rb', line 8 def category @category end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/testcloud/devices/client.rb', line 8 def type @type end |
Instance Method Details
#categories ⇒ Object
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_data ⇒ Object
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 |
#types ⇒ Object
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 |