Class: Sequence::Asset::ClientModule

Inherits:
ClientModule show all
Defined in:
lib/sequence/asset.rb

Instance Attribute Summary

Attributes inherited from ClientModule

#client

Instance Method Summary collapse

Methods inherited from ClientModule

#initialize

Constructor Details

This class inherits a constructor from Sequence::ClientModule

Instance Method Details

#create(opts = {}) ⇒ Asset

Creates a new asset in the ledger.

Parameters:

  • opts (Hash) (defaults to: {})

    Options hash

Options Hash (opts):

  • alias (String)

    Unique, user-specified identifier.

  • keys (Array<Hash>, Array<Sequence::Key>)

    The set of keys used for signing transactions that issue the asset. A key can be either a key object, or a hash containing either an ‘id` or `alias` field.

  • quorum (Integer)

    The number of keys required to sign transactions that issue the asset. Defaults to the number of keys provided.

  • tags (Hash)

    User-specified key-value data describing the asset.

Returns:



57
58
59
60
61
# File 'lib/sequence/asset.rb', line 57

def create(opts = {})
  validate_inclusion_of!(opts, :alias, :keys, :quorum, :tags)
  validate_required!(opts, :keys)
  Asset.new(client.session.request('create-asset', opts))
end

#query(opts = {}) ⇒ Query

Executes a query, returning an enumerable over individual assets.

Parameters:

  • opts (Hash) (defaults to: {})

    Options hash

Options Hash (opts):

  • filter (String)

    A filter expression.

  • filter_params (Array<String|Integer>)

    A list of values that will be interpolated into the filter expression.

  • ] (Integer)

    page_size The number of items to return in the result set.

Returns:



94
95
96
97
98
99
100
101
102
103
# File 'lib/sequence/asset.rb', line 94

def query(opts = {})
  validate_inclusion_of!(
    opts,
    :filter,
    :filter_params,
    :page_size,
    :after,
  )
  Query.new(client, opts)
end

#update_tags(opts = {}) ⇒ void

This method returns an undefined value.

Updates an asset’s tags.

Parameters:

  • opts (Hash) (defaults to: {})

    Options hash

Options Hash (opts):

  • id (String)

    The ID of the asset. Either an ID or alias should be provided, but not both.

  • alias (String)

    The alias of the asset. Either an ID or alias should be provided, but not both.

  • tags (Hash)

    A new set of tags, which will replace the existing tags.



75
76
77
78
79
80
81
82
# File 'lib/sequence/asset.rb', line 75

def update_tags(opts = {})
  validate_inclusion_of!(opts, :id, :alias, :tags)
  if (opts[:id].nil? || opts[:id].empty?) &&
     (opts[:alias].nil? || opts[:alias].empty?)
    raise ArgumentError, ':id or :alias (but not both) must be provided'
  end
  client.session.request('update-asset-tags', opts)
end