Class: Nem::Endpoint::Account

Inherits:
Base
  • Object
show all
Defined in:
lib/nem/endpoint/account.rb

Instance Method Summary collapse

Methods inherited from Base

#current_node, #initialize, #next_node!, #request, #request!

Constructor Details

This class inherits a constructor from Nem::Endpoint::Base

Instance Method Details

#find(address) ⇒ Nem::Model::Account Also known as: get

Parameters:

  • address (String)

Returns:

See Also:



15
16
17
18
19
20
21
# File 'lib/nem/endpoint/account.rb', line 15

def find(address)
  request!(:get, '/account/get',
    address: address
  ) do |res|
    Nem::Model::Account.(res)
  end
end

#find_by_public_key(public_key) ⇒ Nem::Model::Account

Parameters:

  • public_key (String)

Returns:

See Also:



28
29
30
31
32
33
34
# File 'lib/nem/endpoint/account.rb', line 28

def find_by_public_key(public_key)
  request!(:get, '/account/get/from-public-key',
    publicKey: public_key
  ) do |res|
    Nem::Model::Account.(res)
  end
end

#find_forwarded(address) ⇒ Nem::Model::Account



39
40
41
42
43
44
45
# File 'lib/nem/endpoint/account.rb', line 39

def find_forwarded(address)
  request!(:get, '/account/get/forwarded',
    address: address
  ) do |res|
    Nem::Model::Account.(res)
  end
end

#find_forwarded_by_public_key(public_key) ⇒ Nem::Model::Account



50
51
52
53
54
55
56
# File 'lib/nem/endpoint/account.rb', line 50

def find_forwarded_by_public_key(public_key)
  request!(:get, '/account/get/forwarded/from-public-key',
    publicKey: public_key
  ) do |res|
    Nem::Model::Account.(res)
  end
end

#generateNem::Model::Keypair



6
7
8
9
10
# File 'lib/nem/endpoint/account.rb', line 6

def generate
  request!(:get, '/account/generate') do |res|
    Nem::Model::Keypair.new_from_key_pair_view_model(res)
  end
end

#harvests(address, hash: nil) ⇒ Array <Nem::Model::Harvest>

Parameters:

  • address (String)
  • hash (String) (defaults to: nil)

Returns:

See Also:



62
63
64
65
66
67
68
69
70
71
# File 'lib/nem/endpoint/account.rb', line 62

def harvests(address, hash: nil)
  request!(:get, '/account/harvests',
    address: address,
    hash: hash
  ) do |res|
    res[:data].map do |harvest|
      Nem::Model::Harvest.new_from_harvest(harvest)
    end
  end
end

#historical(address, start_height: nil, end_height: nil, increment: nil) ⇒ Array <Nem::Model::AccountHistorical>

Parameters:

  • address (String)
  • start_height (Integer) (defaults to: nil)
  • end_height (Integer) (defaults to: nil)
  • increment (Integer) (defaults to: nil)

Returns:

See Also:



89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/nem/endpoint/account.rb', line 89

def historical(address, start_height: nil, end_height: nil, increment: nil)
  request!(:get, '/account/historical/get',
    address: address,
    startHeight: start_height,
    endHeight: end_height,
    increment: increment
  ) do |res|
    res[:data].map do |ah|
      Nem::Model::AccountHistorical.(ah)
    end
  end
end

#importancesArray <Nem::Model::Importance>



75
76
77
78
79
80
81
# File 'lib/nem/endpoint/account.rb', line 75

def importances
  request!(:get, '/account/importances') do |res|
    res[:data].map do |aivm|
      Nem::Model::Importance.(aivm)
    end
  end
end

#lock(private_key) ⇒ nil

Parameters:

  • private_key (String)

Returns:

  • (nil)

See Also:



156
157
158
# File 'lib/nem/endpoint/account.rb', line 156

def lock(private_key)
  request!(:post, '/account/lock', value: private_key)
end

#mosaic_definition(address, parent: nil, id: nil) ⇒ Array <Nem::Model::MosaicDefinition>

Parameters:

  • address (String)
  • parent (String) (defaults to: nil)
  • id (String) (defaults to: nil)

Returns:

See Also:



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/nem/endpoint/account.rb', line 107

def mosaic_definition(address, parent: nil, id: nil)
  request!(:get, '/account/mosaic/definition/page',
    address: address,
    parent: parent,
    id: id,
  ) do |res|
    res[:data].map do |modef|
      Nem::Model::MosaicDefinition.new_from_mosaic_definition(modef)
    end
  end
end

#mosaic_owned(address) ⇒ Array <Nem::Model::AccountMetaDataPair>

Parameters:

  • address (String)

Returns:

  • (Array <Nem::Model::AccountMetaDataPair>)

See Also:



122
123
124
125
126
127
128
# File 'lib/nem/endpoint/account.rb', line 122

def mosaic_owned(address)
  request!(:get, '/account/mosaic/owned', address: address) do |res|
    Nem::Model::MosaicCollection.new(
      res[:data].map { |moa| Nem::Model::Mosaic.new_from_mosaic(moa) }
    )
  end
end

#namespace(address, parent: nil) ⇒ Array <Nem::Model::Namespace>

Parameters:

  • address (String)
  • parent (String) (defaults to: nil)
  • id (String)
  • page_size (Integer)

Returns:

See Also:



136
137
138
139
140
141
142
# File 'lib/nem/endpoint/account.rb', line 136

def namespace(address, parent: nil)
  request!(:get, '/account/namespace/page', address: address, parent: parent) do |res|
    res[:data].map do |ns|
      Nem::Model::Namespace.new_from_namespace(ns)
    end
  end
end

#status(address) ⇒ Nem::Model::Account

Parameters:

  • address (String)

Returns:

See Also:



147
148
149
150
151
# File 'lib/nem/endpoint/account.rb', line 147

def status(address)
  request!(:get, '/account/status', address: address) do |res|
    Nem::Model::Account.(res)
  end
end

#transfers(address, hash: nil, id: nil, page_size: nil, dir: :all) ⇒ Array <Nem::Model::TransactionMetaDataPair>

Parameters:

  • address (String)
  • hash (String) (defaults to: nil)
  • id (String) (defaults to: nil)
  • dir (Symbol) (defaults to: :all)

    direction(:in, :out, :unconfirmed, :all)

  • page_size (Integer) (defaults to: nil)

Returns:

  • (Array <Nem::Model::TransactionMetaDataPair>)

See Also:



254
255
256
257
258
259
260
261
# File 'lib/nem/endpoint/account.rb', line 254

def transfers(address, hash: nil, id: nil, page_size: nil, dir: :all)
  case dir.to_s
  when /\Ain/  then transfers_incoming(address, hash, id, page_size)
  when /\Aout/ then transfers_outgoing(address, hash, id, page_size)
  when /\Aunconfirmed/ then transfers_unconfirmed(address)
  else transfers_all(address, hash, id, page_size)
  end
end

#transfers_all(address, hash: nil, id: nil, page_size: nil) ⇒ Array <Nem::Model::Transaction>

Parameters:

  • address (String)
  • hash (String) (defaults to: nil)
  • id (String) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)

Returns:

See Also:



219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/nem/endpoint/account.rb', line 219

def transfers_all(address, hash: nil, id: nil, page_size: nil)
  request!(:get, '/account/transfers/all',
    address: address,
    hash: hash,
    id: id,
    pageSize: page_size
  ) do |res|
    res[:data].map do |tx|
      Nem::Model::Transaction.(tx)
    end
  end
end

#transfers_incoming(address, hash: nil, id: nil, page_size: nil) ⇒ Array <Nem::Model::Transaction>

Parameters:

  • address (String)
  • hash (String) (defaults to: nil)
  • id (String) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)

Returns:

See Also:



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/nem/endpoint/account.rb', line 181

def transfers_incoming(address, hash: nil, id: nil, page_size: nil)
  request!(:get, '/account/transfers/incoming',
    address: address,
    hash: hash,
    id: id,
    pageSize: page_size
  ) do |res|
    res[:data].map do |tx|
      Nem::Model::Transaction.(tx)
    end
  end
end

#transfers_outgoing(address, hash: nil, id: nil, page_size: nil) ⇒ Array <Nem::Model::Transaction>

Parameters:

  • address (String)
  • hash (String) (defaults to: nil)
  • id (String) (defaults to: nil)
  • page_size (Integer) (defaults to: nil)

Returns:

See Also:



200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/nem/endpoint/account.rb', line 200

def transfers_outgoing(address, hash: nil, id: nil, page_size: nil)
  request!(:get, '/account/transfers/outgoing',
    address: address,
    hash: hash,
    id: id,
    pageSize: page_size
  ) do |res|
    res[:data].map do |tx|
      Nem::Model::Transaction.(tx)
    end
  end
end

#unconfirmed_transactions(address) ⇒ Array <Nem::Model::Transaction> Also known as: transfers_unconfirmed



235
236
237
238
239
240
241
242
243
# File 'lib/nem/endpoint/account.rb', line 235

def unconfirmed_transactions(address)
  request!(:get, '/account/unconfirmedTransactions',
    address: address
  ) do |res|
    res[:data].map do |tx|
      Nem::Model::Transaction.(tx)
    end
  end
end

#unlock(private_key) ⇒ nil

Parameters:

  • private_key (String)

Returns:

  • (nil)

See Also:



163
164
165
# File 'lib/nem/endpoint/account.rb', line 163

def unlock(private_key)
  request!(:post, '/account/unlock', value: private_key)
end

#unlocked_infoNem::Model::UnlockedInfo



169
170
171
172
173
# File 'lib/nem/endpoint/account.rb', line 169

def unlocked_info
  request!(:post, '/account/unlocked/info') do |res|
    Nem::Model::UnlockedInfo.new_from_unlocked_info(res)
  end
end