Class: RippleRest::Account
- Inherits:
-
Object
- Object
- RippleRest::Account
- Defined in:
- lib/ripple-rest/helpers.rb
Instance Attribute Summary collapse
-
#address ⇒ String
Account’s Address (rXXXXXX…).
-
#secret ⇒ String
Account’s secret.
Private APIs collapse
- #require_secret ⇒ Object private
Instance Method Summary collapse
-
#balances ⇒ Array<Balance>
Get an account’s existing balances.
-
#initialize(address, secret = nil) ⇒ Account
constructor
A new instance of Account.
-
#notifications ⇒ Notifications
Returns a Notifications object for this account.
-
#payments ⇒ Payments
Returns a Payments object for this account.
-
#settings ⇒ AccountSettings
Returns a AccountSettings object for this account.
-
#to_s ⇒ String
Returns the address of attribute address.
-
#trustlines ⇒ Trustlines
Returns a Trustlines object for this account.
Constructor Details
#initialize(address, secret = nil) ⇒ Account
Returns a new instance of Account.
11 12 13 14 |
# File 'lib/ripple-rest/helpers.rb', line 11 def initialize address, secret = nil @address = address @secret = secret end |
Instance Attribute Details
#address ⇒ String
Account’s Address (rXXXXXX…)
5 6 7 |
# File 'lib/ripple-rest/helpers.rb', line 5 def address @address end |
#secret ⇒ String
Account’s secret
9 10 11 |
# File 'lib/ripple-rest/helpers.rb', line 9 def secret @secret end |
Instance Method Details
#balances ⇒ Array<Balance>
Get an account’s existing balances. This includes XRP balance (which does not include a counterparty) and trustline balances.
21 22 23 24 25 |
# File 'lib/ripple-rest/helpers.rb', line 21 def balances RippleRest .get("v1/accounts/#{@address}/balances")["balances"] .map(&Balance.method(:new)) end |
#notifications ⇒ Notifications
Returns a Notifications object for this account.
53 54 55 56 57 58 59 |
# File 'lib/ripple-rest/helpers.rb', line 53 def notifications @notifications ||= lambda { obj = Notifications.new obj.account = self obj }.call end |
#payments ⇒ Payments
Returns a Payments object for this account.
63 64 65 66 67 68 69 |
# File 'lib/ripple-rest/helpers.rb', line 63 def payments payments ||= lambda { obj = Payments.new obj.account = self obj }.call end |
#require_secret ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/ripple-rest/helpers.rb', line 79 def require_secret raise ArgumentError.new("Secret is required for this operation.") unless secret end |
#settings ⇒ AccountSettings
Returns a AccountSettings object for this account.
44 45 46 47 48 49 |
# File 'lib/ripple-rest/helpers.rb', line 44 def settings data = RippleRest.get("v1/accounts/#{@address}/settings")["settings"] obj = AccountSettings.new data obj.account = self obj end |
#to_s ⇒ String
Returns the address of attribute address.
73 74 75 |
# File 'lib/ripple-rest/helpers.rb', line 73 def to_s address end |
#trustlines ⇒ Trustlines
Returns a Trustlines object for this account.
31 32 33 34 35 36 37 38 |
# File 'lib/ripple-rest/helpers.rb', line 31 def trustlines data = RippleRest .get("v1/accounts/#{@address}/trustlines")["trustlines"] .map(&Trustline.method(:new)) obj = Trustlines.new data obj.account = self obj end |