Sha256: 4b0323b92a976500f29602e8779de3ecd96d715d3447092a06ecfb65698bc0b1

Contents?: true

Size: 583 Bytes

Versions: 5

Compression:

Stored size: 583 Bytes

Contents

module Klaytn
  class Token < Client
    BASE_URL = 'https://th-api.klaytnapi.com/v2/contract/nft'.freeze

    attr_reader :encoder

    def initialize(opts = {})
      raise MISSING_CONTRACT if opts[:contract_address].blank?

      @encoder = Encoder.new
      super
    end

    def get(token_id)
      url = BASE_URL + "/#{contract_address}/token/#{encoded_token_id(token_id)}"
      resp = HTTParty.get(url, headers: headers, basic_auth: basic_auth)
      JSON.parse(resp.body)
    end

    def encoded_token_id(token_id)
      encoder.encode_integer(token_id)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
klaytn-0.1.2 lib/klaytn/token.rb
klaytn-0.1.1 lib/klaytn/token.rb
klaytn-0.1.0 lib/klaytn/token.rb
klaytn-0.0.9 lib/klaytn/token.rb
klaytn-0.0.8 lib/klaytn/token.rb