Class: Ynaby::User

Inherits:
Base
  • Object
show all
Defined in:
lib/ynaby/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#ynab_client

Constructor Details

#initialize(api_token) ⇒ User

Returns a new instance of User.



5
6
7
# File 'lib/ynaby/user.rb', line 5

def initialize(api_token)
  @api_token = api_token
end

Instance Attribute Details

#api_tokenObject (readonly)

Returns the value of attribute api_token.



3
4
5
# File 'lib/ynaby/user.rb', line 3

def api_token
  @api_token
end

Instance Method Details

#budget(id) ⇒ Object



16
17
18
# File 'lib/ynaby/user.rb', line 16

def budget(id)
  budgets.find { |budget| budget.id == id }
end

#budgetsObject



9
10
11
12
13
14
# File 'lib/ynaby/user.rb', line 9

def budgets
  response = ynab_client.budgets.get_budgets
  response.data.budgets.map do |budget|
    Budget.parse(budget, self)
  end
end