ynab 1.19.0 → 1.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/lib/ynab/api/accounts_api.rb +63 -5
  4. data/lib/ynab/api/budgets_api.rb +5 -5
  5. data/lib/ynab/api/categories_api.rb +9 -9
  6. data/lib/ynab/api/deprecated_api.rb +3 -3
  7. data/lib/ynab/api/months_api.rb +5 -5
  8. data/lib/ynab/api/payee_locations_api.rb +9 -9
  9. data/lib/ynab/api/payees_api.rb +7 -7
  10. data/lib/ynab/api/scheduled_transactions_api.rb +5 -5
  11. data/lib/ynab/api/transactions_api.rb +23 -23
  12. data/lib/ynab/api/user_api.rb +1 -1
  13. data/lib/ynab/api_client.rb +1 -1
  14. data/lib/ynab/configuration.rb +1 -1
  15. data/lib/ynab/models/account.rb +23 -34
  16. data/lib/ynab/models/account_response.rb +1 -1
  17. data/lib/ynab/models/account_response_data.rb +1 -1
  18. data/lib/ynab/models/account_type.rb +41 -0
  19. data/lib/ynab/models/accounts_response.rb +1 -1
  20. data/lib/ynab/models/accounts_response_data.rb +1 -1
  21. data/lib/ynab/models/budget_detail.rb +1 -1
  22. data/lib/ynab/models/budget_detail_response.rb +1 -1
  23. data/lib/ynab/models/budget_detail_response_data.rb +1 -1
  24. data/lib/ynab/models/budget_settings.rb +1 -1
  25. data/lib/ynab/models/budget_settings_response.rb +1 -1
  26. data/lib/ynab/models/budget_settings_response_data.rb +1 -1
  27. data/lib/ynab/models/budget_summary.rb +1 -1
  28. data/lib/ynab/models/budget_summary_response.rb +1 -1
  29. data/lib/ynab/models/budget_summary_response_data.rb +1 -1
  30. data/lib/ynab/models/bulk_response.rb +1 -1
  31. data/lib/ynab/models/bulk_response_data.rb +1 -1
  32. data/lib/ynab/models/bulk_response_data_bulk.rb +1 -1
  33. data/lib/ynab/models/bulk_transactions.rb +1 -1
  34. data/lib/ynab/models/categories_response.rb +1 -1
  35. data/lib/ynab/models/categories_response_data.rb +1 -1
  36. data/lib/ynab/models/category.rb +44 -4
  37. data/lib/ynab/models/category_group.rb +1 -1
  38. data/lib/ynab/models/category_group_with_categories.rb +1 -1
  39. data/lib/ynab/models/category_response.rb +1 -1
  40. data/lib/ynab/models/category_response_data.rb +1 -1
  41. data/lib/ynab/models/currency_format.rb +1 -1
  42. data/lib/ynab/models/date_format.rb +1 -1
  43. data/lib/ynab/models/error_detail.rb +1 -1
  44. data/lib/ynab/models/error_response.rb +1 -1
  45. data/lib/ynab/models/hybrid_transaction.rb +1 -1
  46. data/lib/ynab/models/hybrid_transactions_response.rb +1 -1
  47. data/lib/ynab/models/hybrid_transactions_response_data.rb +1 -1
  48. data/lib/ynab/models/month_detail.rb +4 -4
  49. data/lib/ynab/models/month_detail_response.rb +1 -1
  50. data/lib/ynab/models/month_detail_response_data.rb +1 -1
  51. data/lib/ynab/models/month_summaries_response.rb +1 -1
  52. data/lib/ynab/models/month_summaries_response_data.rb +1 -1
  53. data/lib/ynab/models/month_summary.rb +4 -4
  54. data/lib/ynab/models/payee.rb +1 -1
  55. data/lib/ynab/models/payee_location.rb +1 -1
  56. data/lib/ynab/models/payee_location_response.rb +1 -1
  57. data/lib/ynab/models/payee_location_response_data.rb +1 -1
  58. data/lib/ynab/models/payee_locations_response.rb +1 -1
  59. data/lib/ynab/models/payee_locations_response_data.rb +1 -1
  60. data/lib/ynab/models/payee_response.rb +1 -1
  61. data/lib/ynab/models/payee_response_data.rb +1 -1
  62. data/lib/ynab/models/payees_response.rb +1 -1
  63. data/lib/ynab/models/payees_response_data.rb +1 -1
  64. data/lib/ynab/models/save_account.rb +219 -0
  65. data/lib/ynab/models/save_account_wrapper.rb +189 -0
  66. data/lib/ynab/models/save_category_response.rb +1 -1
  67. data/lib/ynab/models/save_category_response_data.rb +1 -1
  68. data/lib/ynab/models/save_month_category.rb +1 -1
  69. data/lib/ynab/models/save_month_category_wrapper.rb +1 -1
  70. data/lib/ynab/models/save_sub_transaction.rb +1 -1
  71. data/lib/ynab/models/save_transaction.rb +1 -1
  72. data/lib/ynab/models/save_transaction_wrapper.rb +1 -1
  73. data/lib/ynab/models/save_transactions_response.rb +1 -1
  74. data/lib/ynab/models/save_transactions_response_data.rb +1 -1
  75. data/lib/ynab/models/save_transactions_wrapper.rb +1 -1
  76. data/lib/ynab/models/scheduled_sub_transaction.rb +1 -1
  77. data/lib/ynab/models/scheduled_transaction_detail.rb +1 -1
  78. data/lib/ynab/models/scheduled_transaction_response.rb +1 -1
  79. data/lib/ynab/models/scheduled_transaction_response_data.rb +1 -1
  80. data/lib/ynab/models/scheduled_transaction_summary.rb +1 -1
  81. data/lib/ynab/models/scheduled_transactions_response.rb +1 -1
  82. data/lib/ynab/models/scheduled_transactions_response_data.rb +1 -1
  83. data/lib/ynab/models/sub_transaction.rb +1 -1
  84. data/lib/ynab/models/transaction_detail.rb +1 -1
  85. data/lib/ynab/models/transaction_response.rb +1 -1
  86. data/lib/ynab/models/transaction_response_data.rb +1 -1
  87. data/lib/ynab/models/transaction_summary.rb +1 -1
  88. data/lib/ynab/models/transactions_import_response.rb +1 -1
  89. data/lib/ynab/models/transactions_import_response_data.rb +1 -1
  90. data/lib/ynab/models/transactions_response.rb +1 -1
  91. data/lib/ynab/models/transactions_response_data.rb +1 -1
  92. data/lib/ynab/models/update_transaction.rb +19 -5
  93. data/lib/ynab/models/update_transactions_wrapper.rb +1 -1
  94. data/lib/ynab/models/user.rb +1 -1
  95. data/lib/ynab/models/user_response.rb +1 -1
  96. data/lib/ynab/models/user_response_data.rb +1 -1
  97. data/lib/ynab/version.rb +1 -1
  98. data/lib/ynab.rb +11 -8
  99. data/spec/api/accounts_spec.rb +19 -10
  100. data/spec/api/budgets_spec.rb +4 -4
  101. data/spec/api/categories_spec.rb +5 -5
  102. data/spec/api/months_spec.rb +4 -4
  103. data/spec/api/payee_locations_spec.rb +4 -4
  104. data/spec/api/payees_spec.rb +4 -4
  105. data/spec/api/scheduled_transactions_spec.rb +4 -4
  106. data/spec/api/transactions_spec.rb +13 -14
  107. data/spec/fixtures/vcr_cassettes/create_account.yml +51 -0
  108. metadata +8 -3
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -46,12 +46,24 @@ module YNAB
46
46
  # The goal target amount in milliunits
47
47
  attr_accessor :goal_target
48
48
 
49
- # The target month for the goal to be completed. Only some goal types specify this date.
49
+ # The original target month for the goal to be completed. Only some goal types specify this date.
50
50
  attr_accessor :goal_target_month
51
51
 
52
52
  # The percentage completion of the goal
53
53
  attr_accessor :goal_percentage_complete
54
54
 
55
+ # The number of months, including the current month, left in the current goal period.
56
+ attr_accessor :goal_months_to_budget
57
+
58
+ # The amount of funding still needed in the current month to stay on track towards completing the goal within the current goal period. This amount will generally correspond to the 'Underfunded' amount in the web and mobile clients except when viewing a category with a Needed for Spending Goal in a future month. The web and mobile clients will ignore any funding from a prior goal period when viewing category with a Needed for Spending Goal in a future month.
59
+ attr_accessor :goal_under_funded
60
+
61
+ # The total amount funded towards the goal within the current goal period.
62
+ attr_accessor :goal_overall_funded
63
+
64
+ # The amount of funding still needed to complete the goal within the current goal period.
65
+ attr_accessor :goal_overall_left
66
+
55
67
  # Whether or not the category has been deleted. Deleted categories will only be included in delta requests.
56
68
  attr_accessor :deleted
57
69
 
@@ -94,6 +106,10 @@ module YNAB
94
106
  :'goal_target' => :'goal_target',
95
107
  :'goal_target_month' => :'goal_target_month',
96
108
  :'goal_percentage_complete' => :'goal_percentage_complete',
109
+ :'goal_months_to_budget' => :'goal_months_to_budget',
110
+ :'goal_under_funded' => :'goal_under_funded',
111
+ :'goal_overall_funded' => :'goal_overall_funded',
112
+ :'goal_overall_left' => :'goal_overall_left',
97
113
  :'deleted' => :'deleted'
98
114
  }
99
115
  end
@@ -115,6 +131,10 @@ module YNAB
115
131
  :'goal_target' => :'Integer',
116
132
  :'goal_target_month' => :'Date',
117
133
  :'goal_percentage_complete' => :'Integer',
134
+ :'goal_months_to_budget' => :'Integer',
135
+ :'goal_under_funded' => :'Integer',
136
+ :'goal_overall_funded' => :'Integer',
137
+ :'goal_overall_left' => :'Integer',
118
138
  :'deleted' => :'BOOLEAN'
119
139
  }
120
140
  end
@@ -183,6 +203,22 @@ module YNAB
183
203
  self.goal_percentage_complete = attributes[:'goal_percentage_complete']
184
204
  end
185
205
 
206
+ if attributes.has_key?(:'goal_months_to_budget')
207
+ self.goal_months_to_budget = attributes[:'goal_months_to_budget']
208
+ end
209
+
210
+ if attributes.has_key?(:'goal_under_funded')
211
+ self.goal_under_funded = attributes[:'goal_under_funded']
212
+ end
213
+
214
+ if attributes.has_key?(:'goal_overall_funded')
215
+ self.goal_overall_funded = attributes[:'goal_overall_funded']
216
+ end
217
+
218
+ if attributes.has_key?(:'goal_overall_left')
219
+ self.goal_overall_left = attributes[:'goal_overall_left']
220
+ end
221
+
186
222
  if attributes.has_key?(:'deleted')
187
223
  self.deleted = attributes[:'deleted']
188
224
  end
@@ -237,7 +273,7 @@ module YNAB
237
273
  return false if @budgeted.nil?
238
274
  return false if @activity.nil?
239
275
  return false if @balance.nil?
240
- goal_type_validator = EnumAttributeValidator.new('String', ['TB', 'TBD', 'MF', 'NEED'])
276
+ goal_type_validator = EnumAttributeValidator.new('String', ['TB', 'TBD', 'MF', 'NEED', 'DEBT'])
241
277
  return false unless goal_type_validator.valid?(@goal_type)
242
278
  return false if @deleted.nil?
243
279
  true
@@ -268,6 +304,10 @@ module YNAB
268
304
  goal_target == o.goal_target &&
269
305
  goal_target_month == o.goal_target_month &&
270
306
  goal_percentage_complete == o.goal_percentage_complete &&
307
+ goal_months_to_budget == o.goal_months_to_budget &&
308
+ goal_under_funded == o.goal_under_funded &&
309
+ goal_overall_funded == o.goal_overall_funded &&
310
+ goal_overall_left == o.goal_overall_left &&
271
311
  deleted == o.deleted
272
312
  end
273
313
 
@@ -280,7 +320,7 @@ module YNAB
280
320
  # Calculates hash code according to all attributes.
281
321
  # @return [Fixnum] Hash code
282
322
  def hash
283
- [id, category_group_id, name, hidden, original_category_group_id, note, budgeted, activity, balance, goal_type, goal_creation_month, goal_target, goal_target_month, goal_percentage_complete, deleted].hash
323
+ [id, category_group_id, name, hidden, original_category_group_id, note, budgeted, activity, balance, goal_type, goal_creation_month, goal_target, goal_target_month, goal_percentage_complete, goal_months_to_budget, goal_under_funded, goal_overall_funded, goal_overall_left, deleted].hash
284
324
  end
285
325
  # Builds the object from hash
286
326
  # @param [Hash] attributes Model attributes in the form of hash
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -18,16 +18,16 @@ module YNAB
18
18
 
19
19
  attr_accessor :note
20
20
 
21
- # The total amount of transactions categorized to 'Inflow: To be Budgeted' in the month
21
+ # The total amount of transactions categorized to 'Inflow: Ready to Assign' in the month
22
22
  attr_accessor :income
23
23
 
24
24
  # The total amount budgeted in the month
25
25
  attr_accessor :budgeted
26
26
 
27
- # The total amount of transactions in the month, excluding those categorized to 'Inflow: To be Budgeted'
27
+ # The total amount of transactions in the month, excluding those categorized to 'Inflow: Ready to Assign'
28
28
  attr_accessor :activity
29
29
 
30
- # The available amount for 'To be Budgeted'
30
+ # The available amount for 'Ready to Assign'
31
31
  attr_accessor :to_be_budgeted
32
32
 
33
33
  # The Age of Money as of the month
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -18,16 +18,16 @@ module YNAB
18
18
 
19
19
  attr_accessor :note
20
20
 
21
- # The total amount of transactions categorized to 'Inflow: To be Budgeted' in the month
21
+ # The total amount of transactions categorized to 'Inflow: Ready to Assign' in the month
22
22
  attr_accessor :income
23
23
 
24
24
  # The total amount budgeted in the month
25
25
  attr_accessor :budgeted
26
26
 
27
- # The total amount of transactions in the month, excluding those categorized to 'Inflow: To be Budgeted'
27
+ # The total amount of transactions in the month, excluding those categorized to 'Inflow: Ready to Assign'
28
28
  attr_accessor :activity
29
29
 
30
- # The available amount for 'To be Budgeted'
30
+ # The available amount for 'Ready to Assign'
31
31
  attr_accessor :to_be_budgeted
32
32
 
33
33
  # The Age of Money as of the month
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.15
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -0,0 +1,219 @@
1
+ =begin
2
+ #YNAB API Endpoints
3
+
4
+ #Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com
5
+
6
+ OpenAPI spec version: 1.0.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module YNAB
16
+ class SaveAccount
17
+ # The name of the account
18
+ attr_accessor :name
19
+
20
+ attr_accessor :type
21
+
22
+ # The current balance of the account in milliunits format
23
+ attr_accessor :balance
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'name' => :'name',
29
+ :'type' => :'type',
30
+ :'balance' => :'balance'
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.swagger_types
36
+ {
37
+ :'name' => :'String',
38
+ :'type' => :'AccountType',
39
+ :'balance' => :'Integer'
40
+ }
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ return unless attributes.is_a?(Hash)
47
+
48
+ # convert string to symbol for hash key
49
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
50
+
51
+ if attributes.has_key?(:'name')
52
+ self.name = attributes[:'name']
53
+ end
54
+
55
+ if attributes.has_key?(:'type')
56
+ self.type = attributes[:'type']
57
+ end
58
+
59
+ if attributes.has_key?(:'balance')
60
+ self.balance = attributes[:'balance']
61
+ end
62
+ end
63
+
64
+ # Show invalid properties with the reasons. Usually used together with valid?
65
+ # @return Array for valid properties with the reasons
66
+ def list_invalid_properties
67
+ invalid_properties = Array.new
68
+ if @name.nil?
69
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
70
+ end
71
+
72
+ if @type.nil?
73
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
74
+ end
75
+
76
+ if @balance.nil?
77
+ invalid_properties.push('invalid value for "balance", balance cannot be nil.')
78
+ end
79
+
80
+ invalid_properties
81
+ end
82
+
83
+ # Check to see if the all the properties in the model are valid
84
+ # @return true if the model is valid
85
+ def valid?
86
+ return false if @name.nil?
87
+ return false if @type.nil?
88
+ return false if @balance.nil?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ name == o.name &&
98
+ type == o.type &&
99
+ balance == o.balance
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(o)
105
+ self == o
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Fixnum] Hash code
110
+ def hash
111
+ [name, type, balance].hash
112
+ end
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def build_from_hash(attributes)
117
+ return nil unless attributes.is_a?(Hash)
118
+ self.class.swagger_types.each_pair do |key, type|
119
+ if type =~ /\AArray<(.*)>/i
120
+ # check to ensure the input is an array given that the attribute
121
+ # is documented as an array but the input is not
122
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
123
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
124
+ end
125
+ elsif !attributes[self.class.attribute_map[key]].nil?
126
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
127
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
128
+ end
129
+
130
+ self
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def _deserialize(type, value)
138
+ case type.to_sym
139
+ when :DateTime
140
+ DateTime.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :BOOLEAN
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ temp_model = YNAB.const_get(type).new
171
+ temp_model.build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ # Returns the object in the form of hash
188
+ # @return [Hash] Returns the object in the form of hash
189
+ def to_hash
190
+ hash = {}
191
+ self.class.attribute_map.each_pair do |attr, param|
192
+ value = self.send(attr)
193
+ next if value.nil?
194
+ hash[param] = _to_hash(value)
195
+ end
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to? :to_hash
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+
217
+ end
218
+
219
+ end