Class: BlueBank::Account
- Inherits:
-
Object
- Object
- BlueBank::Account
- Defined in:
- lib/blue_bank/account.rb
Instance Method Summary collapse
- #account_type ⇒ Object
- #current? ⇒ Boolean
- #id ⇒ Object
-
#initialize(id:, client:, json: nil) ⇒ Account
constructor
A new instance of Account.
- #make_payment(account_number:, sort_code:, reference:, amount:) ⇒ Object
- #savings? ⇒ Boolean
- #transactions ⇒ Object
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_type ⇒ Object
15 16 17 |
# File 'lib/blue_bank/account.rb', line 15 def account_type json.fetch("accountType") end |
#current? ⇒ Boolean
7 8 9 |
# File 'lib/blue_bank/account.rb', line 7 def current? account_type == "Standard Current Account" end |
#id ⇒ Object
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" => account_number, "toSortCode" => sort_code, "paymentReference" => reference, "paymentAmount" => amount, } ) Payment.new(id: json.fetch("id"), account: self, client: client, json: json) end |
#savings? ⇒ Boolean
11 12 13 |
# File 'lib/blue_bank/account.rb', line 11 def savings? account_type == "Standard Current Account" end |
#transactions ⇒ Object
32 33 34 |
# File 'lib/blue_bank/account.rb', line 32 def transactions client.get("/accounts/#{id}/transactions") end |