ynab 1.15.0 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/ynab.rb +13 -8
  4. data/lib/ynab/api/accounts_api.rb +65 -7
  5. data/lib/ynab/api/budgets_api.rb +10 -7
  6. data/lib/ynab/api/categories_api.rb +15 -15
  7. data/lib/ynab/api/deprecated_api.rb +3 -3
  8. data/lib/ynab/api/months_api.rb +7 -7
  9. data/lib/ynab/api/payee_locations_api.rb +7 -7
  10. data/lib/ynab/api/payees_api.rb +7 -7
  11. data/lib/ynab/api/scheduled_transactions_api.rb +7 -7
  12. data/lib/ynab/api/transactions_api.rb +93 -41
  13. data/lib/ynab/api/user_api.rb +1 -1
  14. data/lib/ynab/api_client.rb +3 -2
  15. data/lib/ynab/configuration.rb +2 -3
  16. data/lib/ynab/models/account.rb +4 -7
  17. data/lib/ynab/models/account_response.rb +4 -3
  18. data/lib/ynab/models/account_response_data.rb +4 -3
  19. data/lib/ynab/models/accounts_response.rb +4 -3
  20. data/lib/ynab/models/accounts_response_data.rb +4 -3
  21. data/lib/ynab/models/budget_detail.rb +4 -3
  22. data/lib/ynab/models/budget_detail_response.rb +4 -3
  23. data/lib/ynab/models/budget_detail_response_data.rb +4 -3
  24. data/lib/ynab/models/budget_settings.rb +4 -3
  25. data/lib/ynab/models/budget_settings_response.rb +4 -3
  26. data/lib/ynab/models/budget_settings_response_data.rb +4 -3
  27. data/lib/ynab/models/budget_summary.rb +20 -7
  28. data/lib/ynab/models/budget_summary_response.rb +4 -3
  29. data/lib/ynab/models/budget_summary_response_data.rb +4 -3
  30. data/lib/ynab/models/bulk_response.rb +4 -3
  31. data/lib/ynab/models/bulk_response_data.rb +4 -3
  32. data/lib/ynab/models/bulk_response_data_bulk.rb +5 -4
  33. data/lib/ynab/models/bulk_transactions.rb +4 -3
  34. data/lib/ynab/models/categories_response.rb +4 -3
  35. data/lib/ynab/models/categories_response_data.rb +4 -3
  36. data/lib/ynab/models/category.rb +6 -9
  37. data/lib/ynab/models/category_group.rb +4 -3
  38. data/lib/ynab/models/category_group_with_categories.rb +4 -3
  39. data/lib/ynab/models/category_response.rb +4 -3
  40. data/lib/ynab/models/category_response_data.rb +4 -3
  41. data/lib/ynab/models/currency_format.rb +4 -3
  42. data/lib/ynab/models/date_format.rb +4 -3
  43. data/lib/ynab/models/error_detail.rb +4 -3
  44. data/lib/ynab/models/error_response.rb +4 -3
  45. data/lib/ynab/models/hybrid_transaction.rb +4 -15
  46. data/lib/ynab/models/hybrid_transactions_response.rb +4 -3
  47. data/lib/ynab/models/hybrid_transactions_response_data.rb +4 -3
  48. data/lib/ynab/models/month_detail.rb +6 -5
  49. data/lib/ynab/models/month_detail_response.rb +4 -3
  50. data/lib/ynab/models/month_detail_response_data.rb +4 -3
  51. data/lib/ynab/models/month_summaries_response.rb +4 -3
  52. data/lib/ynab/models/month_summaries_response_data.rb +4 -3
  53. data/lib/ynab/models/month_summary.rb +6 -5
  54. data/lib/ynab/models/payee.rb +5 -4
  55. data/lib/ynab/models/payee_location.rb +4 -3
  56. data/lib/ynab/models/payee_location_response.rb +4 -3
  57. data/lib/ynab/models/payee_location_response_data.rb +4 -3
  58. data/lib/ynab/models/payee_locations_response.rb +4 -3
  59. data/lib/ynab/models/payee_locations_response_data.rb +4 -3
  60. data/lib/ynab/models/payee_response.rb +4 -3
  61. data/lib/ynab/models/payee_response_data.rb +4 -3
  62. data/lib/ynab/models/payees_response.rb +4 -3
  63. data/lib/ynab/models/payees_response_data.rb +4 -3
  64. data/lib/ynab/models/save_account.rb +250 -0
  65. data/lib/ynab/models/save_account_wrapper.rb +189 -0
  66. data/lib/ynab/models/save_category_response.rb +4 -3
  67. data/lib/ynab/models/save_category_response_data.rb +4 -3
  68. data/lib/ynab/models/save_month_category.rb +4 -3
  69. data/lib/ynab/models/save_month_category_wrapper.rb +4 -3
  70. data/lib/ynab/models/save_sub_transaction.rb +259 -0
  71. data/lib/ynab/models/save_transaction.rb +24 -19
  72. data/lib/ynab/models/save_transaction_wrapper.rb +4 -3
  73. data/lib/ynab/models/save_transactions_response.rb +4 -3
  74. data/lib/ynab/models/save_transactions_response_data.rb +5 -4
  75. data/lib/ynab/models/save_transactions_wrapper.rb +4 -3
  76. data/lib/ynab/models/scheduled_sub_transaction.rb +4 -3
  77. data/lib/ynab/models/scheduled_transaction_detail.rb +4 -11
  78. data/lib/ynab/models/scheduled_transaction_response.rb +4 -3
  79. data/lib/ynab/models/scheduled_transaction_response_data.rb +4 -3
  80. data/lib/ynab/models/scheduled_transaction_summary.rb +4 -11
  81. data/lib/ynab/models/scheduled_transactions_response.rb +4 -3
  82. data/lib/ynab/models/scheduled_transactions_response_data.rb +4 -3
  83. data/lib/ynab/models/sub_transaction.rb +33 -4
  84. data/lib/ynab/models/transaction_detail.rb +4 -11
  85. data/lib/ynab/models/transaction_response.rb +4 -3
  86. data/lib/ynab/models/transaction_response_data.rb +4 -3
  87. data/lib/ynab/models/transaction_summary.rb +4 -11
  88. data/lib/ynab/models/transactions_import_response.rb +189 -0
  89. data/lib/ynab/models/transactions_import_response_data.rb +192 -0
  90. data/lib/ynab/models/transactions_response.rb +4 -3
  91. data/lib/ynab/models/transactions_response_data.rb +4 -3
  92. data/lib/ynab/models/update_transaction.rb +18 -27
  93. data/lib/ynab/models/update_transactions_wrapper.rb +4 -3
  94. data/lib/ynab/models/user.rb +4 -3
  95. data/lib/ynab/models/user_response.rb +4 -3
  96. data/lib/ynab/models/user_response_data.rb +4 -3
  97. data/lib/ynab/version.rb +1 -1
  98. data/spec/api/accounts_spec.rb +19 -10
  99. data/spec/api/budgets_spec.rb +4 -4
  100. data/spec/api/categories_spec.rb +5 -5
  101. data/spec/api/months_spec.rb +4 -4
  102. data/spec/api/payee_locations_spec.rb +4 -4
  103. data/spec/api/payees_spec.rb +4 -4
  104. data/spec/api/scheduled_transactions_spec.rb +4 -4
  105. data/spec/api/transactions_spec.rb +23 -13
  106. data/spec/fixtures/vcr_cassettes/create_account.yml +51 -0
  107. data/spec/fixtures/vcr_cassettes/import_transactions.yml +50 -0
  108. data/spec/models/transaction_detail_spec.rb +11 -0
  109. metadata +26 -15
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -18,7 +18,7 @@ module YNAB
18
18
 
19
19
  attr_accessor :name
20
20
 
21
- # If a transfer payee, the account_id to which this payee transfers to
21
+ # If a transfer payee, the `account_id` to which this payee transfers to
22
22
  attr_accessor :transfer_account_id
23
23
 
24
24
  # Whether or not the payee has been deleted. Deleted payees will only be included in delta requests.
@@ -119,7 +119,6 @@ module YNAB
119
119
  def hash
120
120
  [id, name, transfer_account_id, deleted].hash
121
121
  end
122
-
123
122
  # Builds the object from hash
124
123
  # @param [Hash] attributes Model attributes in the form of hash
125
124
  # @return [Object] Returns the model itself
@@ -127,7 +126,7 @@ module YNAB
127
126
  return nil unless attributes.is_a?(Hash)
128
127
  self.class.swagger_types.each_pair do |key, type|
129
128
  if type =~ /\AArray<(.*)>/i
130
- # check to ensure the input is an array given that the the attribute
129
+ # check to ensure the input is an array given that the attribute
131
130
  # is documented as an array but the input is not
132
131
  if attributes[self.class.attribute_map[key]].is_a?(Array)
133
132
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -223,5 +222,7 @@ module YNAB
223
222
  value
224
223
  end
225
224
  end
225
+
226
226
  end
227
+
227
228
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -137,7 +137,6 @@ module YNAB
137
137
  def hash
138
138
  [id, payee_id, latitude, longitude, deleted].hash
139
139
  end
140
-
141
140
  # Builds the object from hash
142
141
  # @param [Hash] attributes Model attributes in the form of hash
143
142
  # @return [Object] Returns the model itself
@@ -145,7 +144,7 @@ module YNAB
145
144
  return nil unless attributes.is_a?(Hash)
146
145
  self.class.swagger_types.each_pair do |key, type|
147
146
  if type =~ /\AArray<(.*)>/i
148
- # check to ensure the input is an array given that the the attribute
147
+ # check to ensure the input is an array given that the attribute
149
148
  # is documented as an array but the input is not
150
149
  if attributes[self.class.attribute_map[key]].is_a?(Array)
151
150
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -241,5 +240,7 @@ module YNAB
241
240
  value
242
241
  end
243
242
  end
243
+
244
244
  end
245
+
245
246
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [data].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [payee_location].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [data].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -82,7 +82,6 @@ module YNAB
82
82
  def hash
83
83
  [payee_locations].hash
84
84
  end
85
-
86
85
  # Builds the object from hash
87
86
  # @param [Hash] attributes Model attributes in the form of hash
88
87
  # @return [Object] Returns the model itself
@@ -90,7 +89,7 @@ module YNAB
90
89
  return nil unless attributes.is_a?(Hash)
91
90
  self.class.swagger_types.each_pair do |key, type|
92
91
  if type =~ /\AArray<(.*)>/i
93
- # check to ensure the input is an array given that the the attribute
92
+ # check to ensure the input is an array given that the attribute
94
93
  # is documented as an array but the input is not
95
94
  if attributes[self.class.attribute_map[key]].is_a?(Array)
96
95
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -186,5 +185,7 @@ module YNAB
186
185
  value
187
186
  end
188
187
  end
188
+
189
189
  end
190
+
190
191
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [data].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [payee].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -80,7 +80,6 @@ module YNAB
80
80
  def hash
81
81
  [data].hash
82
82
  end
83
-
84
83
  # Builds the object from hash
85
84
  # @param [Hash] attributes Model attributes in the form of hash
86
85
  # @return [Object] Returns the model itself
@@ -88,7 +87,7 @@ module YNAB
88
87
  return nil unless attributes.is_a?(Hash)
89
88
  self.class.swagger_types.each_pair do |key, type|
90
89
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
90
+ # check to ensure the input is an array given that the attribute
92
91
  # is documented as an array but the input is not
93
92
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
93
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +183,7 @@ module YNAB
184
183
  value
185
184
  end
186
185
  end
186
+
187
187
  end
188
+
188
189
  end
@@ -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.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.15
10
10
 
11
11
  =end
12
12
 
@@ -97,7 +97,6 @@ module YNAB
97
97
  def hash
98
98
  [payees, server_knowledge].hash
99
99
  end
100
-
101
100
  # Builds the object from hash
102
101
  # @param [Hash] attributes Model attributes in the form of hash
103
102
  # @return [Object] Returns the model itself
@@ -105,7 +104,7 @@ module YNAB
105
104
  return nil unless attributes.is_a?(Hash)
106
105
  self.class.swagger_types.each_pair do |key, type|
107
106
  if type =~ /\AArray<(.*)>/i
108
- # check to ensure the input is an array given that the the attribute
107
+ # check to ensure the input is an array given that the attribute
109
108
  # is documented as an array but the input is not
110
109
  if attributes[self.class.attribute_map[key]].is_a?(Array)
111
110
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -201,5 +200,7 @@ module YNAB
201
200
  value
202
201
  end
203
202
  end
203
+
204
204
  end
205
+
205
206
  end
@@ -0,0 +1,250 @@
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.15
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
+ # The account type
21
+ attr_accessor :type
22
+
23
+ # The current balance of the account in milliunits format
24
+ attr_accessor :balance
25
+
26
+ class EnumAttributeValidator
27
+ attr_reader :datatype
28
+ attr_reader :allowable_values
29
+
30
+ def initialize(datatype, allowable_values)
31
+ @allowable_values = allowable_values.map do |value|
32
+ case datatype.to_s
33
+ when /Integer/i
34
+ value.to_i
35
+ when /Float/i
36
+ value.to_f
37
+ else
38
+ value
39
+ end
40
+ end
41
+ end
42
+
43
+ def valid?(value)
44
+ !value || allowable_values.include?(value)
45
+ end
46
+ end
47
+
48
+ # Attribute mapping from ruby-style variable name to JSON key.
49
+ def self.attribute_map
50
+ {
51
+ :'name' => :'name',
52
+ :'type' => :'type',
53
+ :'balance' => :'balance'
54
+ }
55
+ end
56
+
57
+ # Attribute type mapping.
58
+ def self.swagger_types
59
+ {
60
+ :'name' => :'String',
61
+ :'type' => :'String',
62
+ :'balance' => :'Integer'
63
+ }
64
+ end
65
+
66
+ # Initializes the object
67
+ # @param [Hash] attributes Model attributes in the form of hash
68
+ def initialize(attributes = {})
69
+ return unless attributes.is_a?(Hash)
70
+
71
+ # convert string to symbol for hash key
72
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
73
+
74
+ if attributes.has_key?(:'name')
75
+ self.name = attributes[:'name']
76
+ end
77
+
78
+ if attributes.has_key?(:'type')
79
+ self.type = attributes[:'type']
80
+ end
81
+
82
+ if attributes.has_key?(:'balance')
83
+ self.balance = attributes[:'balance']
84
+ end
85
+ end
86
+
87
+ # Show invalid properties with the reasons. Usually used together with valid?
88
+ # @return Array for valid properties with the reasons
89
+ def list_invalid_properties
90
+ invalid_properties = Array.new
91
+ if @name.nil?
92
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
93
+ end
94
+
95
+ if @type.nil?
96
+ invalid_properties.push('invalid value for "type", type cannot be nil.')
97
+ end
98
+
99
+ if @balance.nil?
100
+ invalid_properties.push('invalid value for "balance", balance cannot be nil.')
101
+ end
102
+
103
+ invalid_properties
104
+ end
105
+
106
+ # Check to see if the all the properties in the model are valid
107
+ # @return true if the model is valid
108
+ def valid?
109
+ return false if @name.nil?
110
+ return false if @type.nil?
111
+ type_validator = EnumAttributeValidator.new('String', ['checking', 'savings', 'creditCard', 'cash', 'lineOfCredit', 'otherAsset', 'otherLiability'])
112
+ return false unless type_validator.valid?(@type)
113
+ return false if @balance.nil?
114
+ true
115
+ end
116
+
117
+ # Custom attribute writer method checking allowed values (enum).
118
+ # @param [Object] type Object to be assigned
119
+ def type=(type)
120
+ @type = type
121
+ end
122
+
123
+ # Checks equality by comparing each attribute.
124
+ # @param [Object] Object to be compared
125
+ def ==(o)
126
+ return true if self.equal?(o)
127
+ self.class == o.class &&
128
+ name == o.name &&
129
+ type == o.type &&
130
+ balance == o.balance
131
+ end
132
+
133
+ # @see the `==` method
134
+ # @param [Object] Object to be compared
135
+ def eql?(o)
136
+ self == o
137
+ end
138
+
139
+ # Calculates hash code according to all attributes.
140
+ # @return [Fixnum] Hash code
141
+ def hash
142
+ [name, type, balance].hash
143
+ end
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ self.class.swagger_types.each_pair do |key, type|
150
+ if type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :DateTime
171
+ DateTime.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :String
175
+ value.to_s
176
+ when :Integer
177
+ value.to_i
178
+ when :Float
179
+ value.to_f
180
+ when :BOOLEAN
181
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182
+ true
183
+ else
184
+ false
185
+ end
186
+ when :Object
187
+ # generic object (usually a Hash), return directly
188
+ value
189
+ when /\AArray<(?<inner_type>.+)>\z/
190
+ inner_type = Regexp.last_match[:inner_type]
191
+ value.map { |v| _deserialize(inner_type, v) }
192
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193
+ k_type = Regexp.last_match[:k_type]
194
+ v_type = Regexp.last_match[:v_type]
195
+ {}.tap do |hash|
196
+ value.each do |k, v|
197
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198
+ end
199
+ end
200
+ else # model
201
+ temp_model = YNAB.const_get(type).new
202
+ temp_model.build_from_hash(value)
203
+ end
204
+ end
205
+
206
+ # Returns the string representation of the object
207
+ # @return [String] String presentation of the object
208
+ def to_s
209
+ to_hash.to_s
210
+ end
211
+
212
+ # to_body is an alias to to_hash (backward compatibility)
213
+ # @return [Hash] Returns the object in the form of hash
214
+ def to_body
215
+ to_hash
216
+ end
217
+
218
+ # Returns the object in the form of hash
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_hash
221
+ hash = {}
222
+ self.class.attribute_map.each_pair do |attr, param|
223
+ value = self.send(attr)
224
+ next if value.nil?
225
+ hash[param] = _to_hash(value)
226
+ end
227
+ hash
228
+ end
229
+
230
+ # Outputs non-array value in the form of hash
231
+ # For object, use to_hash. Otherwise, just return the value
232
+ # @param [Object] value Any valid value
233
+ # @return [Hash] Returns the value in the form of hash
234
+ def _to_hash(value)
235
+ if value.is_a?(Array)
236
+ value.compact.map { |v| _to_hash(v) }
237
+ elsif value.is_a?(Hash)
238
+ {}.tap do |hash|
239
+ value.each { |k, v| hash[k] = _to_hash(v) }
240
+ end
241
+ elsif value.respond_to? :to_hash
242
+ value.to_hash
243
+ else
244
+ value
245
+ end
246
+ end
247
+
248
+ end
249
+
250
+ end