Class: Bankscrap::Account

Inherits:
Object
  • Object
show all
Includes:
Utils::Inspectable
Defined in:
lib/bankscrap/account.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils::Inspectable

#inspect

Constructor Details

#initialize(params = {}) ⇒ Account

Returns a new instance of Account.



10
11
12
13
14
15
# File 'lib/bankscrap/account.rb', line 10

def initialize(params = {})
  raise NotMoneyObjectError, :balance unless params[:balance].is_a?(Money)
  raise NotMoneyObjectError, :available_balance unless params[:available_balance].is_a?(Money)

  params.each { |key, value| send "#{key}=", value }
end

Instance Attribute Details

#available_balanceObject

Returns the value of attribute available_balance.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def available_balance
  @available_balance
end

#balanceObject

Returns the value of attribute balance.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def balance
  @balance
end

#bankObject

Returns the value of attribute bank.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def bank
  @bank
end

#bicObject

Returns the value of attribute bic.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def bic
  @bic
end

#descriptionObject

Returns the value of attribute description.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def description
  @description
end

#ibanObject

Returns the value of attribute iban.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def iban
  @iban
end

#idObject

Returns the value of attribute id.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def id
  @id
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def name
  @name
end

#raw_dataObject

Returns the value of attribute raw_data.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def raw_data
  @raw_data
end

#transactionsObject

Returns the value of attribute transactions.



5
6
7
# File 'lib/bankscrap/account.rb', line 5

def transactions
  @transactions
end

Instance Method Details

#currencyObject



25
26
27
# File 'lib/bankscrap/account.rb', line 25

def currency
  balance.try(:currency)
end

#fetch_transactions(start_date: Date.today - 2.years, end_date: Date.today) ⇒ Object



21
22
23
# File 'lib/bankscrap/account.rb', line 21

def fetch_transactions(start_date: Date.today - 2.years, end_date: Date.today)
  bank.fetch_transactions_for(self, start_date: start_date, end_date: end_date)
end

#to_aObject



33
34
35
# File 'lib/bankscrap/account.rb', line 33

def to_a
  [id, iban, name, description, balance]
end

#to_sObject



29
30
31
# File 'lib/bankscrap/account.rb', line 29

def to_s
  description
end