Sha256: d4cba6f6477a652826151aea5f6de9c016f23d6804022545debf658dcc2b192e
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'rest-client' require 'json' require 'katapaty/version' require 'katapaty/configuration' require 'katapaty/errors' require 'katapaty/tx_decode' module Katapaty class << self attr_writer :configuration def configuration @configuration ||= Configuration.new end def reset @configuration = Configuration.new end def configure yield(configuration) end 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katapaty-0.3.2 | lib/katapaty.rb |