class CardanoWallet::Base

Base class for all APIs

Attributes

opt[RW]

Public Class Methods

new(opt = {}) click to toggle source
# File lib/cardano_wallet/base.rb, line 11
def initialize(opt = {})
  raise ArgumentError, 'argument should be Hash' unless opt.is_a?(Hash)

  opt[:protocol] ||= 'http'
  opt[:host] ||= 'localhost'
  opt[:port] ||= 8090
  opt[:url] ||= "#{opt[:protocol]}://#{opt[:host]}:#{opt[:port]}/v2"
  opt[:cacert] ||= ''
  opt[:pem] ||= ''
  opt[:timeout] ||= -1
  self.class.base_uri opt[:url]
  self.class.default_timeout(opt[:timeout].to_i) unless opt[:timeout] == -1

  unless opt[:cacert].empty?
    ENV['SSL_CERT_FILE'] = opt[:cacert]
    self.class.ssl_ca_file(File.read(ENV['SSL_CERT_FILE']))
  end
  self.class.pem(File.read(opt[:pem])) unless opt[:pem].empty?

  @opt = opt
end

Public Instance Methods

byron() click to toggle source

Init API for Byron

# File lib/cardano_wallet/base.rb, line 44
def byron
  Byron.new @opt
end
misc() click to toggle source

Init API for Misc

# File lib/cardano_wallet/base.rb, line 49
def misc
  Misc.new @opt
end
proxy() click to toggle source

Init API for Proxy

# File lib/cardano_wallet/base.rb, line 54
def proxy
  Proxy.new @opt
end
shared() click to toggle source

Init API for Shared wallets

# File lib/cardano_wallet/base.rb, line 39
def shared
  Shared.new @opt
end
shelley() click to toggle source

Init API for Shelley

# File lib/cardano_wallet/base.rb, line 34
def shelley
  Shelley.new @opt
end