Class: Monzo::Account

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

Overview

Public: Accounts represent a store of funds, and have a list of transactions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Account

Public: Initialize an Account.

params - A Hash of account parameters.



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

def initialize(params)
  @id = params[:id]
  @description = params[:description]
  @created = params[:created]
end

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



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

def created
  @created
end

#descriptionObject (readonly)

Returns the value of attribute description.



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

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

Class Method Details

.allObject

Public: Find all Monzo Accounts

Returns An Array of Monzo::Account



20
21
22
23
24
25
26
27
28
# File 'lib/monzo/account.rb', line 20

def self.all
  client = Monzo.client
  response = client.get("/accounts")
  parsed_response = JSON.parse(response.body, :symbolize_names => true)

  parsed_response[:accounts].map do |item|
    Monzo::Account.new(item)
  end
end