Sha256: adf5bf6f1ef84c6397a26705c9a6dd8ff0533c2da1c7c3fb9c07808aee675be4

Contents?: true

Size: 1.07 KB

Versions: 13

Compression:

Stored size: 1.07 KB

Contents

module CardanoWallet
  class Base
    include HTTParty

    attr_accessor :opt

    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]
      unless(opt[:timeout] == -1)
        self.class.default_timeout(opt[:timeout].to_i)
      end

      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

    # Init API for Shelley
    def shelley
      Shelley.new @opt
    end

    # Init API for Byron
    def byron
      Byron.new @opt
    end

    # Init API for Misc
    def misc
      Misc.new @opt
    end

    # Init API for Proxy
    def proxy
      Proxy.new @opt
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cardano_wallet-0.3.2 lib/cardano_wallet/base.rb
cardano_wallet-0.3.1 lib/cardano_wallet/base.rb
cardano_wallet-0.3.0 lib/cardano_wallet/base.rb
cardano_wallet-0.2.9 lib/cardano_wallet/base.rb
cardano_wallet-0.2.8 lib/cardano_wallet/base.rb
cardano_wallet-0.2.7 lib/cardano_wallet/base.rb
cardano_wallet-0.2.6 lib/cardano_wallet/base.rb
cardano_wallet-0.2.5 lib/cardano_wallet/base.rb
cardano_wallet-0.2.4 lib/cardano_wallet/base.rb
cardano_wallet-0.2.3 lib/cardano_wallet/base.rb
cardano_wallet-0.2.2 lib/cardano_wallet/base.rb
cardano_wallet-0.2.1 lib/cardano_wallet/base.rb
cardano_wallet-0.2.0 lib/cardano_wallet/base.rb