Module: Katapaty
- Defined in:
- lib/katapaty/tx_decode.rb,
lib/katapaty.rb,
lib/katapaty/errors.rb,
lib/katapaty/version.rb,
lib/katapaty/configuration.rb
Overview
Defined Under Namespace
Classes: Configuration, JsonResponseError, ResponseError, TxDecode
Constant Summary
collapse
- VERSION =
"0.3.4"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.configuration ⇒ Object
17
18
19
|
# File 'lib/katapaty.rb', line 17
def configuration
@configuration ||= Configuration.new
end
|
Class Method Details
25
26
27
|
# File 'lib/katapaty.rb', line 25
def configure
yield(configuration)
end
|
.method_missing(name, *args) ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/katapaty.rb', line 29
def method_missing(name, *args)
args = args.nil? ? nil : args.first
client = RestClient::Resource.new @configuration.api_url
request = { method: name, params: args, jsonrpc: '2.0', id: '0' }.to_json
response = JSON.parse client.post(request,
user: @configuration.username,
password: @configuration.password,
accept: 'json',
content_type: 'json' )
raise JsonResponseError.new response if response.has_key? 'code'
raise ResponseError.new response['error'] if response.has_key? 'error'
response['result']
end
|
.reset ⇒ Object
21
22
23
|
# File 'lib/katapaty.rb', line 21
def reset
@configuration = Configuration.new
end
|