Class: OnyxMesh::Asset::ClientModule

Inherits:
ClientModule
  • Object
show all
Defined in:
lib/onyx_mesh/asset.rb

Instance Method Summary collapse

Instance Method Details

#create(key_ids:, id: nil, quorum: nil, tags: nil) ⇒ Asset

Create a new asset in the ledger.

Parameters:

  • key_ids (Array<String>) —

    The set of key IDs used for signing transactions that issue tokens of the asset.

  • id (String) (defaults to: nil) —

    Unique identifier. Auto-generated if not specified.

  • quorum (Integer) (defaults to: nil) —

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

  • tags (Hash) (defaults to: nil) —

    User-specified key-value data describing the asset.

Returns:

Raises:

  • (ArgumentError)


51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/onyx_mesh/asset.rb', line 51

def create(key_ids:, id: nil, quorum: nil, tags: nil)
  raise ArgumentError, ':key_ids cannot be empty' if key_ids == []
  Asset.new(
    client.session.request(
      'create-asset',
      id: id,
      key_ids: key_ids,
      quorum: quorum,
      tags: tags,
    ),
  )
end

#list(filter: nil, filter_params: nil) ⇒ Query

Execute a query, returning an enumerable over individual assets.

Parameters:

  • filter (String) (defaults to: nil) —

    A filter expression.

  • filter_params (Array<String|Integer>) (defaults to: nil) —

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

Returns:



81
82
83
# File 'lib/onyx_mesh/asset.rb', line 81

def list(filter: nil, filter_params: nil)
  Query.new(client, filter: filter, filter_params: filter_params)
end

#update_tags(id:, tags: nil) ⇒ void

This method returns an undefined value.

Update an asset's tags.

Parameters:

  • id (String) —

    The ID of the asset.

  • tags (Hash) (defaults to: nil) —

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

Raises:

  • (ArgumentError)


70
71
72
73
# File 'lib/onyx_mesh/asset.rb', line 70

def update_tags(id:, tags: nil)
  raise ArgumentError, ':id cannot be blank' if id == ''
  client.session.request('update-asset-tags', id: id, tags: tags)
end