Sha256: 3dd794b53c3fe53eee523854524c943dbf49661645a71244a4d9108953af56d3

Contents?: true

Size: 1.19 KB

Versions: 18

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module CardanoWallet
  ##
  # Base class for all APIs
  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]
      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

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

    # Init API for Shared wallets
    def shared
      Shared.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

18 entries across 18 versions & 1 rubygems

Version Path
cardano_wallet-0.3.21 lib/cardano_wallet/base.rb
cardano_wallet-0.3.20 lib/cardano_wallet/base.rb
cardano_wallet-0.3.19 lib/cardano_wallet/base.rb
cardano_wallet-0.3.18 lib/cardano_wallet/base.rb
cardano_wallet-0.3.17 lib/cardano_wallet/base.rb
cardano_wallet-0.3.16 lib/cardano_wallet/base.rb
cardano_wallet-0.3.15 lib/cardano_wallet/base.rb
cardano_wallet-0.3.14 lib/cardano_wallet/base.rb
cardano_wallet-0.3.12 lib/cardano_wallet/base.rb
cardano_wallet-0.3.11 lib/cardano_wallet/base.rb
cardano_wallet-0.3.10 lib/cardano_wallet/base.rb
cardano_wallet-0.3.9 lib/cardano_wallet/base.rb
cardano_wallet-0.3.8 lib/cardano_wallet/base.rb
cardano_wallet-0.3.7 lib/cardano_wallet/base.rb
cardano_wallet-0.3.6 lib/cardano_wallet/base.rb
cardano_wallet-0.3.5 lib/cardano_wallet/base.rb
cardano_wallet-0.3.4 lib/cardano_wallet/base.rb
cardano_wallet-0.3.3 lib/cardano_wallet/base.rb