Class: Bcoin::Client::Wallets
- Inherits:
-
Collection
- Object
- Collection
- Bcoin::Client::Wallets
- Defined in:
- lib/bcoin/client/wallets.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Attributes inherited from Collection
Instance Method Summary collapse
-
#base_path ⇒ Object
The base path for the wallets collection must be set to ‘/’ since the bcoin API breaks from the RESTful standard for the retrieval of the wallet collection.
-
#create(options = {}) ⇒ Bcoin::Client::Wallet
Create a new Wallet.
- #find(attr) ⇒ Object
- #refresh! ⇒ Object
Methods inherited from Collection
#each, #error?, #initialize, #inspect
Methods included from HttpMethods
#delete, #get, #post, #put, #wallet_token
Constructor Details
This class inherits a constructor from Bcoin::Client::Collection
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/bcoin/client/wallets.rb', line 8 def client @client end |
Instance Method Details
#base_path ⇒ Object
The base path for the wallets collection must be set to ‘/’ since the bcoin API breaks from the RESTful standard for the retrieval of the wallet collection. The list of wallets is located at ‘/wallets/_admin/wallets’. The base path for all other wallet operations is the expected ‘/wallet’.
16 17 18 |
# File 'lib/bcoin/client/wallets.rb', line 16 def base_path '/' end |
#create(options = {}) ⇒ Bcoin::Client::Wallet
Create a new Wallet.
41 42 43 44 45 46 47 48 |
# File 'lib/bcoin/client/wallets.rb', line 41 def create = {} # The path in this post operation intentionally omits # the preceeding slash due to wonkiness with the wallets # base path breaking standards. See Wallets#base_path # comment above. response = post 'wallet/', Wallet.new(client, response) end |
#find(attr) ⇒ Object
30 31 32 |
# File 'lib/bcoin/client/wallets.rb', line 30 def find attr Wallet.new(client, attr).refresh! end |
#refresh! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/bcoin/client/wallets.rb', line 20 def refresh! # Preceeding slash in the GET operation intentionally omitted # due to wonkiness with the wallets base path. See the # Wallets#base_path comment above. @collection = super('wallet/_admin/wallets').collect { |w| Wallet.new(client, id: w).refresh! } self end |