Class: Monzo::Balance
- Inherits:
-
Object
- Object
- Monzo::Balance
- Defined in:
- lib/monzo/balance.rb
Overview
Public: Retrieve information about an account’s balance.
Instance Attribute Summary collapse
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#local_currency ⇒ Object
readonly
Returns the value of attribute local_currency.
-
#local_exchange_rate ⇒ Object
readonly
Returns the value of attribute local_exchange_rate.
-
#local_spend ⇒ Object
readonly
Returns the value of attribute local_spend.
-
#spend_today ⇒ Object
readonly
Returns the value of attribute spend_today.
Class Method Summary collapse
-
.find(account_id) ⇒ Object
Public: Find the balance of the given account id.
Instance Method Summary collapse
-
#initialize(params) ⇒ Balance
constructor
Public: Initialize a Balance.
Constructor Details
#initialize(params) ⇒ Balance
Public: Initialize a Balance.
params - A Hash of balance parameters.
12 13 14 15 16 17 18 19 |
# File 'lib/monzo/balance.rb', line 12 def initialize(params) @balance = params[:balance] @currency = params[:currency] @spend_today = params[:spend_today] @local_currency = params[:local_currency] @local_exchange_rate = params[:local_exchange_rate] @local_spend = params[:local_spend] end |
Instance Attribute Details
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def balance @balance end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def currency @currency end |
#local_currency ⇒ Object (readonly)
Returns the value of attribute local_currency.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def local_currency @local_currency end |
#local_exchange_rate ⇒ Object (readonly)
Returns the value of attribute local_exchange_rate.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def local_exchange_rate @local_exchange_rate end |
#local_spend ⇒ Object (readonly)
Returns the value of attribute local_spend.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def local_spend @local_spend end |
#spend_today ⇒ Object (readonly)
Returns the value of attribute spend_today.
6 7 8 |
# File 'lib/monzo/balance.rb', line 6 def spend_today @spend_today end |
Class Method Details
.find(account_id) ⇒ Object
Public: Find the balance of the given account id.
account_id - The Monzo account id to find the balance for.
Returns an instance of Monzo::Balance
26 27 28 29 30 31 32 |
# File 'lib/monzo/balance.rb', line 26 def self.find(account_id) client = Monzo.client response = client.get("/balance", {:account_id => account_id}) parsed_response = JSON.parse(response.body, :symbolize_names => true) Monzo::Balance.new(parsed_response) end |