Class: MmJsonClient::JsonRpcHttp::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mm_json_client/json_rpc_http/client.rb

Overview

A helper client for doing JSON-RPC calls over http.

Instance Method Summary collapse

Constructor Details

#initialize(base_url, options = {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
# File 'lib/mm_json_client/json_rpc_http/client.rb', line 9

def initialize(base_url, options = {})
  @http_client =
    MmJsonClient::HttpClient::Client.new(base_url, options[:endpoint],
                                         allowed_client_options(options))
end

Instance Method Details

#request(method, params = nil, id = false) ⇒ Object

id defaults to false to detect if was specified. Null is a valid value according to the spec.



17
18
19
20
# File 'lib/mm_json_client/json_rpc_http/client.rb', line 17

def request(method, params = nil, id = false)
  http_response = @http_client.post(request_message(method, params, id))
  MmJsonClient::JsonRpcHttp::Response.new(http_response.body)
end