Sha256: e9975c0880902aa5ca6414b35a7177ae3df87f10cd13e9c85c6ceee813badaed

Contents?: true

Size: 1.49 KB

Versions: 5

Compression:

Stored size: 1.49 KB

Contents

module ECMBlockchain
  class Asset
    extend ECMBlockchain::Routes
    extend ECMBlockchain::Request

    class << self
      def create(identity, data)
        verify_asset(data)
        asset(request( :post, "/#{identity}#{ASSET_URL}", data ))
      end

      # def batch_create(identity, data)
      #   verify_batch_assets(data)
      #   request( :post, "/#{identity}#{ASSET_BATCH_URL}", data ). 
      #     collect { |asset_response| asset(asset_response) }
      # rescue => error; error
      # end

      # def retrieve(identity)
      #   response = request( :get, "/#{identity}#{MEMBERS_URL}" )
      #   return_any_errors(response)
      #   ECMBlockchain::Member.new(JSON.parse(response.body).with_indifferent_access)
      # end

      # def update(identity, data)
      #   response = request( :patch, "/#{identity}#{MEMBERS_URL}", data )
      #   return_any_errors(response)
      #   ECMBlockchain::Member.new(JSON.parse(response.body).with_indifferent_access)
      # end

      # def revoke(identity)
      #   response = request( :delete, "/#{identity}#{MEMBERS_URL}")
      #   return_any_errors(response)
      #   OpenStruct.new(success: true, details: "Certificate successfully revoked")
      # end
      private 

      def asset(asset_data) 
        verify_asset(asset_data)
      end

      def verify_asset(asset)
        ECMBlockchain::AssetModel.verify(asset) 
      end

      def verify_batch_assets(arr)
        arr.find_all { |asset| verify_asset(asset) }  
      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/asset.rb
ecm-blockchain-api-1.1.1 lib/ecm-blockchain-api/asset.rb
ecm-blockchain-api-1.1.0 lib/ecm-blockchain-api/asset.rb
ecm_blockchain_api-1.0.1 lib/ecm_blockchain_api/asset.rb
ecm_blockchain_api-1.0.0 lib/ecm_blockchain_api/asset.rb