class Ynaby::Budget

Attributes

currency_format[R]
date_format[R]
id[R]
last_modified_on[R]
name[R]
user[R]

Public Class Methods

new(id:, name:, last_modified_on:, date_format:, currency_format:, user:) click to toggle source
# File lib/ynaby/budget.rb, line 5
def initialize(id:, name:, last_modified_on:, date_format:, currency_format:, user:)
  @id = id
  @name = name
  @last_modified_on = last_modified_on
  @date_format = date_format
  @currency_format = currency_format || {}
  @user = user
end
parse(object, user) click to toggle source
# File lib/ynaby/budget.rb, line 30
def self.parse(object, user)
  new(
    id: object.id,
    name: object.name,
    last_modified_on: object.last_modified_on,
    date_format: object.date_format.to_hash,
    currency_format: object.currency_format.to_hash,
    user: user
  )
end

Public Instance Methods

account(account_id) click to toggle source
# File lib/ynaby/budget.rb, line 21
def account(account_id)
  response = ynab_client.accounts.get_account_by_id(id, account_id)
  Account.parse(object: response.data.account, budget: self)
end
accounts() click to toggle source
# File lib/ynaby/budget.rb, line 14
def accounts
  response = ynab_client.accounts.get_accounts(@id)
  response.data.accounts.map do |account|
    Account.parse(object: account, budget: self)
  end
end
api_token() click to toggle source
# File lib/ynaby/budget.rb, line 41
def api_token
  user.api_token
end
currency_code() click to toggle source
# File lib/ynaby/budget.rb, line 26
def currency_code
  currency_format[:iso_code]
end