Class: Coinbase::User
- Inherits:
-
Object
- Object
- Coinbase::User
- Defined in:
- lib/coinbase/user.rb
Overview
A representation of a User. Users have Wallets, which can hold balances of Assets. Access the default User through Coinbase#default_user.
Instance Method Summary collapse
-
#create_wallet(create_wallet_options = {}) ⇒ Coinbase::Wallet
Creates a new Wallet belonging to the User.
-
#id ⇒ String
Returns the User ID.
-
#import_wallet(data) ⇒ Coinbase::Wallet
Imports a Wallet belonging to the User.
-
#initialize(model) ⇒ User
constructor
Returns a new User object.
-
#inspect ⇒ String
Same as to_s.
-
#to_s ⇒ String
Returns a string representation of the User.
-
#wallet(wallet_id) ⇒ Coinbase::Wallet
Returns the Wallet with the given ID.
-
#wallets ⇒ Enumerator<Coinbase::Wallet>
Enumerates the Wallets belonging to the User.
Constructor Details
#initialize(model) ⇒ User
Returns a new User object. Do not use this method directly. Instead, use Coinbase#default_user.
12 13 14 |
# File 'lib/coinbase/user.rb', line 12 def initialize(model) @model = model end |
Instance Method Details
#create_wallet(create_wallet_options = {}) ⇒ Coinbase::Wallet
Creates a new Wallet belonging to the User.
25 26 27 28 29 30 31 |
# File 'lib/coinbase/user.rb', line 25 def create_wallet( = {}) # For ruby 2.7 compatibility we cannot pass in keyword args when the create wallet # options is empty return Wallet.create if .empty? Wallet.create(**) end |
#id ⇒ String
Returns the User ID.
18 19 20 |
# File 'lib/coinbase/user.rb', line 18 def id @model.id end |
#import_wallet(data) ⇒ Coinbase::Wallet
Imports a Wallet belonging to the User.
36 37 38 |
# File 'lib/coinbase/user.rb', line 36 def import_wallet(data) Wallet.import(data) end |
#inspect ⇒ String
Same as to_s.
61 62 63 |
# File 'lib/coinbase/user.rb', line 61 def inspect to_s end |
#to_s ⇒ String
Returns a string representation of the User.
55 56 57 |
# File 'lib/coinbase/user.rb', line 55 def to_s "Coinbase::User{user_id: '#{id}'}" end |
#wallet(wallet_id) ⇒ Coinbase::Wallet
Returns the Wallet with the given ID.
49 50 51 |
# File 'lib/coinbase/user.rb', line 49 def wallet(wallet_id) Wallet.fetch(wallet_id) end |
#wallets ⇒ Enumerator<Coinbase::Wallet>
Enumerates the Wallets belonging to the User.
42 43 44 |
# File 'lib/coinbase/user.rb', line 42 def wallets Wallet.list end |