Class: K3cloud::WebApiClient
- Inherits:
-
Object
- Object
- K3cloud::WebApiClient
- Defined in:
- lib/k3cloud/web_api_client.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #execute(service_name, parameters) ⇒ Object
-
#initialize(config = Configuration.default) ⇒ WebApiClient
constructor
A new instance of WebApiClient.
Constructor Details
#initialize(config = Configuration.default) ⇒ WebApiClient
Returns a new instance of WebApiClient.
15 16 17 |
# File 'lib/k3cloud/web_api_client.rb', line 15 def initialize(config = Configuration.default) @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
13 14 15 |
# File 'lib/k3cloud/web_api_client.rb', line 13 def config @config end |
Instance Method Details
#execute(service_name, parameters) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/k3cloud/web_api_client.rb', line 19 def execute(service_name, parameters) result = execute_json(service_name, parameters) if result.start_with?("response_error:") error = K3cloudError.parse(result) raise K3cloud::ResponseError, result if error.nil? = error.inner_ex_wrapper.nil? ? error. : "#{error.message} --> #{error.inner_ex_wrapper&.message}" raise K3cloud::ResponseError, else begin JSON.parse(result) rescue JSON::ParserError raise K3cloud::ResponseError, "JSON parse error, response: [#{result}]" end end end |