Sha256: 433ceea18c3175b0732bdcaf4cfdff29f95b23118dd8b2259c0beb6efc8c5291

Contents?: true

Size: 958 Bytes

Versions: 5

Compression:

Stored size: 958 Bytes

Contents

module ECMBlockchain
  class Tokens
    extend ECMBlockchain::Routes
    extend ECMBlockchain::Request

    class << self
      def create(identity, data)
        token(request( :post, "/#{identity}#{TOKENS_URL}/mint", data ))
      end

      def retrieve(identity, kind='all')
        token(request( :get, "/#{identity}#{TOKENS_URL}/#{kind}" ))
      end

      def total_supply()
        token(request( :get, "/#{TOKENS_URL}"))
      end

      def burn(identity, data)
        response = request( :delete, "/#{identity}#{TOKENS_URL}/burn", data)
        OpenStruct.new(success: true, details: "Tokens successfully burnt")
      end

      def transfer(from, to, data)
        data[:transferee] = request( :get, "/#{to}#{TOKENS_URL}/wallet")[:address]
        token(request( :patch, "/#{from}#{TOKENS_URL}/transfer", data ))
      end

      private

      def token(params)
        ECMBlockchain::TokensCollection.new(params)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
ecm-blockchain-api-1.1.2 lib/ecm-blockchain-api/token.rb
ecm-blockchain-api-1.1.1 lib/ecm-blockchain-api/token.rb
ecm-blockchain-api-1.1.0 lib/ecm-blockchain-api/token.rb
ecm_blockchain_api-1.0.1 lib/ecm_blockchain_api/token.rb
ecm_blockchain_api-1.0.0 lib/ecm_blockchain_api/token.rb