Class: Chain::Account::ClientModule
- Inherits:
-
ClientModule
- Object
- ClientModule
- Chain::Account::ClientModule
- Defined in:
- lib/chain/account.rb
Instance Attribute Summary
Attributes inherited from ClientModule
Instance Method Summary collapse
- #create(opts) ⇒ Account
- #create_batch(opts) ⇒ BatchResponse<Account>
-
#create_control_program(opts = {}) ⇒ ControlProgram
deprecated
Deprecated.
(as of version 1.1) Use #create_receiver instead.
-
#create_receiver(opts) ⇒ Receiver
Creates a new receiver under the specified account.
-
#create_receiver_batch(opts_list) ⇒ BatchResponse<Receiver>
Creates new receivers under the specified accounts.
- #query(opts = {}) ⇒ Query
Methods inherited from ClientModule
Constructor Details
This class inherits a constructor from Chain::ClientModule
Instance Method Details
#create(opts) ⇒ Account
44 45 46 47 |
# File 'lib/chain/account.rb', line 44 def create(opts) opts = {client_token: SecureRandom.uuid}.merge(opts) client.conn.singleton_batch_request('create-account', [opts]) { |item| Account.new(item) } end |
#create_batch(opts) ⇒ BatchResponse<Account>
51 52 53 54 |
# File 'lib/chain/account.rb', line 51 def create_batch(opts) opts = opts.map { |i| {client_token: SecureRandom.uuid}.merge(i) } client.conn.batch_request('create-account', opts) { |item| Account.new(item) } end |
#create_control_program(opts = {}) ⇒ ControlProgram
Deprecated.
(as of version 1.1) Use #create_receiver instead.
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/chain/account.rb', line 59 def create_control_program(opts = {}) # We don't use keyword params here because 'alias' is a Ruby reserverd # word. params = {} params[:account_alias] = opts[:alias] if opts.key?(:alias) params[:account_id] = opts[:id] if opts.key?(:id) client.conn.singleton_batch_request( 'create-control-program', [{type: :account, params: params}] ) { |item| ControlProgram.new(item) } end |
#create_receiver(opts) ⇒ Receiver
Creates a new receiver under the specified account.
79 80 81 |
# File 'lib/chain/account.rb', line 79 def create_receiver(opts) client.conn.singleton_batch_request('create-account-receiver', [opts]) { |item| Receiver.new(item) } end |
#create_receiver_batch(opts_list) ⇒ BatchResponse<Receiver>
Creates new receivers under the specified accounts.
87 88 89 |
# File 'lib/chain/account.rb', line 87 def create_receiver_batch(opts_list) client.conn.batch_request('create-account-receiver', opts_list) { |item| Receiver.new(item) } end |
#query(opts = {}) ⇒ Query
95 96 97 |
# File 'lib/chain/account.rb', line 95 def query(opts = {}) Query.new(client, opts) end |