Sha256: 9f59fd25e33b8eabd9d8dcb6406b6310f88433371535bf1a074d9824e3eb15c5

Contents?: true

Size: 738 Bytes

Versions: 3

Compression:

Stored size: 738 Bytes

Contents

module Monzo

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

    attr_reader :id, :description, :created

    # Public: Initialize an Account.
    #
    # params - A Hash of account parameters.
    def initialize(params)
      @id = params[:id]
      @description = params[:description]
      @created = params[:created]
    end

    # Public: Find all Monzo Accounts
    #
    # Returns An Array of Monzo::Account
    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
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
monzo-0.3.0 lib/monzo/account.rb
monzo-0.2.0 lib/monzo/account.rb
monzo-0.1.0 lib/monzo/account.rb