Class: Testcloud::Devices::Client
- Inherits:
-
Object
- Object
- Testcloud::Devices::Client
- Extended by:
- Forwardable
- 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.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
-
#response ⇒ Object
Returns the value of attribute response.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .api_token ⇒ Object
- .api_token=(value) ⇒ Object
- .setup {|_self| ... } ⇒ Object
- .url ⇒ Object
- .url=(value) ⇒ Object
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.
36 37 38 39 40 41 |
# File 'lib/testcloud/devices/client.rb', line 36 def initialize( = {}) @type, @category = [:type], [:category] self.class.debug_output if [:debug] self.class.base_uri([:url] || self.class.url || DEFAULT_URL) self.class.api_token = [:api_token] if [:api_token] end |
Instance Attribute Details
#api_token ⇒ Object
Returns the value of attribute api_token.
11 12 13 |
# File 'lib/testcloud/devices/client.rb', line 11 def api_token @api_token end |
#category ⇒ Object
Returns the value of attribute category.
11 12 13 |
# File 'lib/testcloud/devices/client.rb', line 11 def category @category end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
11 12 13 |
# File 'lib/testcloud/devices/client.rb', line 11 def raw_response @raw_response end |
#response ⇒ Object
Returns the value of attribute response.
11 12 13 |
# File 'lib/testcloud/devices/client.rb', line 11 def response @response end |
#type ⇒ Object
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_token ⇒ Object
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
15 16 17 |
# File 'lib/testcloud/devices/client.rb', line 15 def setup(&block) yield(self) end |
.url ⇒ Object
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
#categories ⇒ Object
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_data ⇒ Object
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 |
#types ⇒ Object
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 |