Class: Sequence::Account::ClientModule

Inherits:
ClientModule show all
Defined in:
lib/sequence/account.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 = {}) ⇒ Account

Creates a new account in the ledger.

Parameters:

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

    Options hash

Options Hash (opts):

  • id (String)

    Unique, user-specified identifier.

  • alias (String)

    Deprecated. Use :id instead. Unique, user-specified identifier.

  • key_ids (Array<String>)

    The key IDs used for signing transactions that spend from the account.

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

    Deprecated. Use :key_ids instead. The keys used for signing transactions that spend from the account. 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 spend from the account. Defaults to the number of keys provided.

  • tags (Hash)

    User-specified key-value data describing the account.

Returns:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/sequence/account.rb', line 74

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

#list(opts = {}) ⇒ Query

Filters accounts.

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.

Returns:



148
149
150
151
152
153
154
155
# File 'lib/sequence/account.rb', line 148

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

#query(opts = {}) ⇒ Query

Deprecated.

Use list instead.

Executes a query, returning an enumerable over individual accounts.

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 Deprecated. Use list.page(size: size) instead. The number of items to return in the result set.

Returns:



128
129
130
131
132
133
134
135
136
137
# File 'lib/sequence/account.rb', line 128

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 account’s tags.

Parameters:

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

    Options hash

Options Hash (opts):

  • id (String)

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

  • alias (String)

    Deprecated. Use :id instead. The alias of the account. Either an ID or alias should be provided, but not both.

  • tags (Hash)

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



107
108
109
110
111
112
113
114
# File 'lib/sequence/account.rb', line 107

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-account-tags', opts)
end