Class: SolovisApiClient::Base
- Inherits:
-
Object
- Object
- SolovisApiClient::Base
- Defined in:
- lib/solovis_api_client/base.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
- #config ⇒ Object
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Base
constructor
A new instance of Base.
- #rpc_invoke(uri_path, message) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Base
4 5 6 7 |
# File 'lib/solovis_api_client/base.rb', line 4 def initialize( = {}) config.add(:url, [:url]) config.add(:api_key, [:api_key]) end |
Instance Attribute Details
#site ⇒ Object (readonly)
Returns the value of attribute site.
2 3 4 |
# File 'lib/solovis_api_client/base.rb', line 2 def site @site end |
Instance Method Details
#config ⇒ Object
9 10 11 |
# File 'lib/solovis_api_client/base.rb', line 9 def config SolovisApiClient.config end |
#connection ⇒ Object
13 14 15 |
# File 'lib/solovis_api_client/base.rb', line 13 def connection SolovisApiClient::Connection.new.rpc_connection end |
#rpc_invoke(uri_path, message) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/solovis_api_client/base.rb', line 21 def rpc_invoke(uri_path, ) response = connection.post do |req| req.headers["Content-Type"] = "x-post-rpc/json" req.headers["Content-Encoding"] = "utf-8" req.url uri_path req.body = .to_json end body = response.body if body["result"] return body elsif body["error"] raise RuntimeError.new(body["error"]) end end |