Class: Monzo::Balance

Inherits:
Object
  • Object
show all
Defined in:
lib/monzo/balance.rb

Overview

Public: Retrieve information about an account’s balance.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#balanceObject (readonly)

Returns the value of attribute balance.



6
7
8
# File 'lib/monzo/balance.rb', line 6

def balance
  @balance
end

#currencyObject (readonly)

Returns the value of attribute currency.



6
7
8
# File 'lib/monzo/balance.rb', line 6

def currency
  @currency
end

#local_currencyObject (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_rateObject (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_spendObject (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_todayObject (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()
  client = Monzo.client
  response = client.get("/balance", {:account_id => })
  parsed_response = JSON.parse(response.body, :symbolize_names => true)

  Monzo::Balance.new(parsed_response)
end