Class: TaaS::TaaSClient
- Inherits:
-
Object
- Object
- TaaS::TaaSClient
- Defined in:
- lib/taas_client.rb
Instance Attribute Summary collapse
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #execute_contract(params = {}) ⇒ Object
-
#initialize(url, timeout_in_seconds = 1000) ⇒ TaaSClient
constructor
A new instance of TaaSClient.
- #request_taas_server(params) ⇒ Object
Constructor Details
#initialize(url, timeout_in_seconds = 1000) ⇒ TaaSClient
Returns a new instance of TaaSClient.
12 13 14 15 |
# File 'lib/taas_client.rb', line 12 def initialize(url, timeout_in_seconds=1000) @url = url @timeout = timeout_in_seconds * 10000 end |
Instance Attribute Details
#timeout ⇒ Object
Returns the value of attribute timeout.
10 11 12 |
# File 'lib/taas_client.rb', line 10 def timeout @timeout end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/taas_client.rb', line 10 def url @url end |
Instance Method Details
#execute_contract(params = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/taas_client.rb', line 17 def execute_contract(params={}) response_body = request_taas_server(params) raise "TaaS Request is false" unless OutputParser.valid_server_response?(response_body) OutputParser.parse_server_output(response_body) end |
#request_taas_server(params) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/taas_client.rb', line 27 def request_taas_server(params) uri = URI.parse(@url) http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data(params) http.read_timeout = @timeout http.request(request).body end |