Class: Ynaby::Budget
Instance Attribute Summary collapse
-
#currency_format ⇒ Object
readonly
Returns the value of attribute currency_format.
-
#date_format ⇒ Object
readonly
Returns the value of attribute date_format.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#last_modified_on ⇒ Object
readonly
Returns the value of attribute last_modified_on.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #account(account_id) ⇒ Object
- #accounts ⇒ Object
- #api_token ⇒ Object
- #currency_code ⇒ Object
-
#initialize(id:, name:, last_modified_on:, date_format:, currency_format:, user:) ⇒ Budget
constructor
A new instance of Budget.
Methods inherited from Base
Constructor Details
#initialize(id:, name:, last_modified_on:, date_format:, currency_format:, user:) ⇒ Budget
Returns a new instance of Budget.
5 6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#currency_format ⇒ Object (readonly)
Returns the value of attribute currency_format.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def currency_format @currency_format end |
#date_format ⇒ Object (readonly)
Returns the value of attribute date_format.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def date_format @date_format end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def id @id end |
#last_modified_on ⇒ Object (readonly)
Returns the value of attribute last_modified_on.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def last_modified_on @last_modified_on end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def name @name end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
3 4 5 |
# File 'lib/ynaby/budget.rb', line 3 def user @user end |
Class Method Details
.parse(object, user) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# 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 |
Instance Method Details
#account(account_id) ⇒ Object
21 22 23 24 |
# 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 ⇒ Object
14 15 16 17 18 19 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/ynaby/budget.rb', line 41 def api_token user.api_token end |
#currency_code ⇒ Object
26 27 28 |
# File 'lib/ynaby/budget.rb', line 26 def currency_code currency_format[:iso_code] end |