Class: BlueBank::Account

Inherits:
Object
  • Object
show all
Defined in:
lib/blue_bank/account.rb

Instance Method Summary collapse

Constructor Details

#initialize(id:, client:, json: nil) ⇒ Account

Returns a new instance of Account.



3
4
5
# File 'lib/blue_bank/account.rb', line 3

def initialize(id:, client:, json: nil)
  @id, @client, @json = id, client, json
end

Instance Method Details

#account_typeObject



15
16
17
# File 'lib/blue_bank/account.rb', line 15

def 
  json.fetch("accountType")
end

#current?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/blue_bank/account.rb', line 7

def current?
   == "Standard Current Account"
end

#idObject



36
37
38
# File 'lib/blue_bank/account.rb', line 36

def id
  @id ||= json.fetch("id")
end

#make_payment(account_number:, sort_code:, reference:, amount:) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/blue_bank/account.rb', line 19

def make_payment(account_number:, sort_code:, reference:, amount:)
  json = client.post(
    path: "/accounts/#{id}/payments",
    json: {
      "toAccountNumber" => ,
      "toSortCode" => sort_code,
      "paymentReference" => reference,
      "paymentAmount" => amount,
    }
  )
  Payment.new(id: json.fetch("id"), account: self, client: client, json: json)
end

#savings?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/blue_bank/account.rb', line 11

def savings?
   == "Standard Current Account"
end

#transactionsObject



32
33
34
# File 'lib/blue_bank/account.rb', line 32

def transactions
  client.get("/accounts/#{id}/transactions")
end