ynab 2.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/DEVELOPMENT.md +6 -2
  3. data/Gemfile.lock +1 -1
  4. data/README.md +3 -1
  5. data/Rakefile +3 -1
  6. data/docs/BulkTransactions.md +1 -1
  7. data/docs/CategoriesApi.md +22 -0
  8. data/docs/Category.md +1 -0
  9. data/docs/ExistingTransaction.md +18 -0
  10. data/docs/HybridTransaction.md +3 -2
  11. data/docs/NewTransaction.md +19 -0
  12. data/docs/PatchCategoryWrapper.md +8 -0
  13. data/docs/PatchPayeeWrapper.md +8 -0
  14. data/docs/PatchTransactionsWrapper.md +1 -1
  15. data/docs/PayeesApi.md +22 -0
  16. data/docs/PostTransactionsWrapper.md +2 -2
  17. data/docs/PutTransactionWrapper.md +1 -1
  18. data/docs/SaveCategory.md +10 -0
  19. data/docs/SavePayee.md +8 -0
  20. data/docs/SavePayeeResponse.md +8 -0
  21. data/docs/SavePayeeResponseData.md +9 -0
  22. data/docs/SaveTransactionWithIdOrImportId.md +20 -0
  23. data/docs/SaveTransactionWithOptionalFields.md +2 -3
  24. data/docs/ScheduledTransactionDetail.md +2 -1
  25. data/docs/ScheduledTransactionSummary.md +2 -1
  26. data/docs/TransactionClearedStatus.md +7 -0
  27. data/docs/TransactionDetail.md +3 -2
  28. data/docs/TransactionFlagColor.md +7 -0
  29. data/docs/TransactionSummary.md +3 -2
  30. data/docs/TransactionsApi.md +7 -7
  31. data/lib/ynab/api/accounts_api.rb +2 -2
  32. data/lib/ynab/api/budgets_api.rb +2 -2
  33. data/lib/ynab/api/categories_api.rb +82 -2
  34. data/lib/ynab/api/months_api.rb +2 -2
  35. data/lib/ynab/api/payee_locations_api.rb +2 -2
  36. data/lib/ynab/api/payees_api.rb +82 -2
  37. data/lib/ynab/api/scheduled_transactions_api.rb +2 -2
  38. data/lib/ynab/api/transactions_api.rb +12 -12
  39. data/lib/ynab/api/user_api.rb +2 -2
  40. data/lib/ynab/api_client.rb +2 -2
  41. data/lib/ynab/configuration.rb +14 -11
  42. data/lib/ynab/models/account.rb +13 -20
  43. data/lib/ynab/models/account_response.rb +13 -20
  44. data/lib/ynab/models/account_response_data.rb +13 -20
  45. data/lib/ynab/models/account_type.rb +2 -2
  46. data/lib/ynab/models/accounts_response.rb +13 -20
  47. data/lib/ynab/models/accounts_response_data.rb +13 -20
  48. data/lib/ynab/models/budget_detail.rb +13 -21
  49. data/lib/ynab/models/budget_detail_response.rb +13 -20
  50. data/lib/ynab/models/budget_detail_response_data.rb +13 -20
  51. data/lib/ynab/models/budget_settings.rb +13 -20
  52. data/lib/ynab/models/budget_settings_response.rb +13 -20
  53. data/lib/ynab/models/budget_settings_response_data.rb +13 -20
  54. data/lib/ynab/models/budget_summary.rb +13 -20
  55. data/lib/ynab/models/budget_summary_response.rb +13 -20
  56. data/lib/ynab/models/budget_summary_response_data.rb +13 -20
  57. data/lib/ynab/models/bulk_response.rb +13 -20
  58. data/lib/ynab/models/bulk_response_data.rb +13 -20
  59. data/lib/ynab/models/bulk_response_data_bulk.rb +13 -20
  60. data/lib/ynab/models/bulk_transactions.rb +14 -21
  61. data/lib/ynab/models/categories_response.rb +13 -20
  62. data/lib/ynab/models/categories_response_data.rb +13 -20
  63. data/lib/ynab/models/category.rb +25 -21
  64. data/lib/ynab/models/category_group.rb +13 -20
  65. data/lib/ynab/models/category_group_with_categories.rb +14 -22
  66. data/lib/ynab/models/category_response.rb +13 -20
  67. data/lib/ynab/models/category_response_data.rb +13 -20
  68. data/lib/ynab/models/currency_format.rb +13 -20
  69. data/lib/ynab/models/date_format.rb +13 -20
  70. data/lib/ynab/models/error_detail.rb +13 -20
  71. data/lib/ynab/models/error_response.rb +13 -20
  72. data/lib/ynab/models/existing_transaction.rb +359 -0
  73. data/lib/ynab/models/hybrid_transaction.rb +28 -43
  74. data/lib/ynab/models/hybrid_transactions_response.rb +13 -20
  75. data/lib/ynab/models/hybrid_transactions_response_data.rb +13 -20
  76. data/lib/ynab/models/month_detail.rb +13 -21
  77. data/lib/ynab/models/month_detail_response.rb +13 -20
  78. data/lib/ynab/models/month_detail_response_data.rb +13 -20
  79. data/lib/ynab/models/month_summaries_response.rb +13 -20
  80. data/lib/ynab/models/month_summaries_response_data.rb +13 -20
  81. data/lib/ynab/models/month_summary.rb +13 -20
  82. data/lib/ynab/models/new_transaction.rb +377 -0
  83. data/lib/ynab/models/patch_category_wrapper.rb +213 -0
  84. data/lib/ynab/models/patch_month_category_wrapper.rb +13 -20
  85. data/lib/ynab/models/patch_payee_wrapper.rb +213 -0
  86. data/lib/ynab/models/patch_transactions_wrapper.rb +14 -21
  87. data/lib/ynab/models/payee.rb +13 -20
  88. data/lib/ynab/models/payee_location.rb +13 -20
  89. data/lib/ynab/models/payee_location_response.rb +13 -20
  90. data/lib/ynab/models/payee_location_response_data.rb +13 -20
  91. data/lib/ynab/models/payee_locations_response.rb +13 -20
  92. data/lib/ynab/models/payee_locations_response_data.rb +13 -20
  93. data/lib/ynab/models/payee_response.rb +13 -20
  94. data/lib/ynab/models/payee_response_data.rb +13 -20
  95. data/lib/ynab/models/payees_response.rb +13 -20
  96. data/lib/ynab/models/payees_response_data.rb +13 -20
  97. data/lib/ynab/models/post_account_wrapper.rb +13 -20
  98. data/lib/ynab/models/post_transactions_wrapper.rb +15 -22
  99. data/lib/ynab/models/put_transaction_wrapper.rb +14 -21
  100. data/lib/ynab/models/save_account.rb +13 -20
  101. data/lib/ynab/models/save_category.rb +232 -0
  102. data/lib/ynab/models/save_category_response.rb +13 -20
  103. data/lib/ynab/models/save_category_response_data.rb +13 -20
  104. data/lib/ynab/models/save_month_category.rb +13 -20
  105. data/lib/ynab/models/save_payee.rb +220 -0
  106. data/lib/ynab/models/save_payee_response.rb +213 -0
  107. data/lib/ynab/models/save_payee_response_data.rb +224 -0
  108. data/lib/ynab/models/save_sub_transaction.rb +13 -20
  109. data/lib/ynab/models/save_transaction_with_id_or_import_id.rb +388 -0
  110. data/lib/ynab/models/save_transaction_with_optional_fields.rb +17 -59
  111. data/lib/ynab/models/save_transactions_response.rb +13 -20
  112. data/lib/ynab/models/save_transactions_response_data.rb +13 -20
  113. data/lib/ynab/models/scheduled_sub_transaction.rb +13 -20
  114. data/lib/ynab/models/scheduled_transaction_detail.rb +26 -32
  115. data/lib/ynab/models/scheduled_transaction_response.rb +13 -20
  116. data/lib/ynab/models/scheduled_transaction_response_data.rb +13 -20
  117. data/lib/ynab/models/scheduled_transaction_summary.rb +26 -31
  118. data/lib/ynab/models/scheduled_transactions_response.rb +13 -20
  119. data/lib/ynab/models/scheduled_transactions_response_data.rb +13 -20
  120. data/lib/ynab/models/sub_transaction.rb +13 -20
  121. data/lib/ynab/models/transaction_cleared_status.rb +41 -0
  122. data/lib/ynab/models/transaction_detail.rb +28 -43
  123. data/lib/ynab/models/transaction_flag_color.rb +45 -0
  124. data/lib/ynab/models/transaction_response.rb +13 -20
  125. data/lib/ynab/models/transaction_response_data.rb +13 -20
  126. data/lib/ynab/models/transaction_summary.rb +28 -42
  127. data/lib/ynab/models/transactions_import_response.rb +13 -20
  128. data/lib/ynab/models/transactions_import_response_data.rb +13 -20
  129. data/lib/ynab/models/transactions_response.rb +13 -20
  130. data/lib/ynab/models/transactions_response_data.rb +13 -20
  131. data/lib/ynab/models/user.rb +13 -20
  132. data/lib/ynab/models/user_response.rb +13 -20
  133. data/lib/ynab/models/user_response_data.rb +13 -20
  134. data/lib/ynab/version.rb +1 -1
  135. data/lib/ynab.rb +13 -12
  136. data/open_api_spec.yaml +464 -343
  137. data/ynab.gemspec +4 -3
  138. metadata +53 -31
@@ -0,0 +1,232 @@
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.ynab.com
5
+
6
+ The version of the OpenAPI document: 1.70.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module YNAB
17
+ class SaveCategory
18
+ attr_accessor :name
19
+
20
+ attr_accessor :note
21
+
22
+ attr_accessor :category_group_id
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'name' => :'name',
28
+ :'note' => :'note',
29
+ :'category_group_id' => :'category_group_id'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'name' => :'String',
42
+ :'note' => :'String',
43
+ :'category_group_id' => :'String'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ :'name',
51
+ :'note',
52
+ ])
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ if (!attributes.is_a?(Hash))
59
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SaveCategory` initialize method"
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SaveCategory`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
66
+ end
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:'name')
71
+ self.name = attributes[:'name']
72
+ end
73
+
74
+ if attributes.key?(:'note')
75
+ self.note = attributes[:'note']
76
+ end
77
+
78
+ if attributes.key?(:'category_group_id')
79
+ self.category_group_id = attributes[:'category_group_id']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ invalid_properties
88
+ end
89
+
90
+ # Check to see if the all the properties in the model are valid
91
+ # @return true if the model is valid
92
+ def valid?
93
+ true
94
+ end
95
+
96
+ # Checks equality by comparing each attribute.
97
+ # @param [Object] Object to be compared
98
+ def ==(o)
99
+ return true if self.equal?(o)
100
+ self.class == o.class &&
101
+ name == o.name &&
102
+ note == o.note &&
103
+ category_group_id == o.category_group_id
104
+ end
105
+
106
+ # @see the `==` method
107
+ # @param [Object] Object to be compared
108
+ def eql?(o)
109
+ self == o
110
+ end
111
+
112
+ # Calculates hash code according to all attributes.
113
+ # @return [Integer] Hash code
114
+ def hash
115
+ [name, note, category_group_id].hash
116
+ end
117
+
118
+ # Builds the object from hash
119
+ # @param [Hash] attributes Model attributes in the form of hash
120
+ # @return [Object] Returns the model itself
121
+ def self.build_from_hash(attributes)
122
+ return nil unless attributes.is_a?(Hash)
123
+ attributes = attributes.transform_keys(&:to_sym)
124
+ transformed_hash = {}
125
+ openapi_types.each_pair do |key, type|
126
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
127
+ transformed_hash["#{key}"] = nil
128
+ elsif type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[attribute_map[key]].is_a?(Array)
132
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
133
+ end
134
+ elsif !attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
136
+ end
137
+ end
138
+ new(transformed_hash)
139
+ end
140
+
141
+ # Deserializes the data based on type
142
+ # @param string type Data type
143
+ # @param string value Value to be deserialized
144
+ # @return [Object] Deserialized data
145
+ def self._deserialize(type, value)
146
+ case type.to_sym
147
+ when :Time
148
+ Time.parse(value)
149
+ when :Date
150
+ Date.parse(value)
151
+ when :String
152
+ value.to_s
153
+ when :Integer
154
+ value.to_i
155
+ when :Float
156
+ value.to_f
157
+ when :Boolean
158
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
159
+ true
160
+ else
161
+ false
162
+ end
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ else # model
178
+ # models (e.g. Pet) or oneOf
179
+ klass = YNAB.const_get(type)
180
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
181
+ end
182
+ end
183
+
184
+ # Returns the string representation of the object
185
+ # @return [String] String presentation of the object
186
+ def to_s
187
+ to_hash.to_s
188
+ end
189
+
190
+ # to_body is an alias to to_hash (backward compatibility)
191
+ # @return [Hash] Returns the object in the form of hash
192
+ def to_body
193
+ to_hash
194
+ end
195
+
196
+ # Returns the object in the form of hash
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_hash
199
+ hash = {}
200
+ self.class.attribute_map.each_pair do |attr, param|
201
+ value = self.send(attr)
202
+ if value.nil?
203
+ is_nullable = self.class.openapi_nullable.include?(attr)
204
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
205
+ end
206
+
207
+ hash[param] = _to_hash(value)
208
+ end
209
+ hash
210
+ end
211
+
212
+ # Outputs non-array value in the form of hash
213
+ # For object, use to_hash. Otherwise, just return the value
214
+ # @param [Object] value Any valid value
215
+ # @return [Hash] Returns the value in the form of hash
216
+ def _to_hash(value)
217
+ if value.is_a?(Array)
218
+ value.compact.map { |v| _to_hash(v) }
219
+ elsif value.is_a?(Hash)
220
+ {}.tap do |hash|
221
+ value.each { |k, v| hash[k] = _to_hash(v) }
222
+ end
223
+ elsif value.respond_to? :to_hash
224
+ value.to_hash
225
+ else
226
+ value
227
+ end
228
+ end
229
+
230
+ end
231
+
232
+ end
@@ -3,10 +3,10 @@
3
3
 
4
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.ynab.com
5
5
 
6
- The version of the OpenAPI document: 1.0.0
6
+ The version of the OpenAPI document: 1.70.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -100,37 +100,30 @@ module YNAB
100
100
  # @param [Hash] attributes Model attributes in the form of hash
101
101
  # @return [Object] Returns the model itself
102
102
  def self.build_from_hash(attributes)
103
- new.build_from_hash(attributes)
104
- end
105
-
106
- # Builds the object from hash
107
- # @param [Hash] attributes Model attributes in the form of hash
108
- # @return [Object] Returns the model itself
109
- def build_from_hash(attributes)
110
103
  return nil unless attributes.is_a?(Hash)
111
104
  attributes = attributes.transform_keys(&:to_sym)
112
- self.class.openapi_types.each_pair do |key, type|
113
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
114
- self.send("#{key}=", nil)
105
+ transformed_hash = {}
106
+ openapi_types.each_pair do |key, type|
107
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
108
+ transformed_hash["#{key}"] = nil
115
109
  elsif type =~ /\AArray<(.*)>/i
116
110
  # check to ensure the input is an array given that the attribute
117
111
  # is documented as an array but the input is not
118
- if attributes[self.class.attribute_map[key]].is_a?(Array)
119
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ if attributes[attribute_map[key]].is_a?(Array)
113
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
120
114
  end
121
- elsif !attributes[self.class.attribute_map[key]].nil?
122
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ elsif !attributes[attribute_map[key]].nil?
116
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
123
117
  end
124
118
  end
125
-
126
- self
119
+ new(transformed_hash)
127
120
  end
128
121
 
129
122
  # Deserializes the data based on type
130
123
  # @param string type Data type
131
124
  # @param string value Value to be deserialized
132
125
  # @return [Object] Deserialized data
133
- def _deserialize(type, value)
126
+ def self._deserialize(type, value)
134
127
  case type.to_sym
135
128
  when :Time
136
129
  Time.parse(value)
@@ -165,7 +158,7 @@ module YNAB
165
158
  else # model
166
159
  # models (e.g. Pet) or oneOf
167
160
  klass = YNAB.const_get(type)
168
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
161
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
162
  end
170
163
  end
171
164
 
@@ -3,10 +3,10 @@
3
3
 
4
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.ynab.com
5
5
 
6
- The version of the OpenAPI document: 1.0.0
6
+ The version of the OpenAPI document: 1.70.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -111,37 +111,30 @@ module YNAB
111
111
  # @param [Hash] attributes Model attributes in the form of hash
112
112
  # @return [Object] Returns the model itself
113
113
  def self.build_from_hash(attributes)
114
- new.build_from_hash(attributes)
115
- end
116
-
117
- # Builds the object from hash
118
- # @param [Hash] attributes Model attributes in the form of hash
119
- # @return [Object] Returns the model itself
120
- def build_from_hash(attributes)
121
114
  return nil unless attributes.is_a?(Hash)
122
115
  attributes = attributes.transform_keys(&:to_sym)
123
- self.class.openapi_types.each_pair do |key, type|
124
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
125
- self.send("#{key}=", nil)
116
+ transformed_hash = {}
117
+ openapi_types.each_pair do |key, type|
118
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
119
+ transformed_hash["#{key}"] = nil
126
120
  elsif type =~ /\AArray<(.*)>/i
127
121
  # check to ensure the input is an array given that the attribute
128
122
  # is documented as an array but the input is not
129
- if attributes[self.class.attribute_map[key]].is_a?(Array)
130
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
123
+ if attributes[attribute_map[key]].is_a?(Array)
124
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
131
125
  end
132
- elsif !attributes[self.class.attribute_map[key]].nil?
133
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
126
+ elsif !attributes[attribute_map[key]].nil?
127
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
134
128
  end
135
129
  end
136
-
137
- self
130
+ new(transformed_hash)
138
131
  end
139
132
 
140
133
  # Deserializes the data based on type
141
134
  # @param string type Data type
142
135
  # @param string value Value to be deserialized
143
136
  # @return [Object] Deserialized data
144
- def _deserialize(type, value)
137
+ def self._deserialize(type, value)
145
138
  case type.to_sym
146
139
  when :Time
147
140
  Time.parse(value)
@@ -176,7 +169,7 @@ module YNAB
176
169
  else # model
177
170
  # models (e.g. Pet) or oneOf
178
171
  klass = YNAB.const_get(type)
179
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
172
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
180
173
  end
181
174
  end
182
175
 
@@ -3,10 +3,10 @@
3
3
 
4
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.ynab.com
5
5
 
6
- The version of the OpenAPI document: 1.0.0
6
+ The version of the OpenAPI document: 1.70.0
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.6.0
9
+ Generator version: 7.6.0
10
10
 
11
11
  =end
12
12
 
@@ -101,37 +101,30 @@ module YNAB
101
101
  # @param [Hash] attributes Model attributes in the form of hash
102
102
  # @return [Object] Returns the model itself
103
103
  def self.build_from_hash(attributes)
104
- new.build_from_hash(attributes)
105
- end
106
-
107
- # Builds the object from hash
108
- # @param [Hash] attributes Model attributes in the form of hash
109
- # @return [Object] Returns the model itself
110
- def build_from_hash(attributes)
111
104
  return nil unless attributes.is_a?(Hash)
112
105
  attributes = attributes.transform_keys(&:to_sym)
113
- self.class.openapi_types.each_pair do |key, type|
114
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
115
- self.send("#{key}=", nil)
106
+ transformed_hash = {}
107
+ openapi_types.each_pair do |key, type|
108
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
109
+ transformed_hash["#{key}"] = nil
116
110
  elsif type =~ /\AArray<(.*)>/i
117
111
  # check to ensure the input is an array given that the attribute
118
112
  # is documented as an array but the input is not
119
- if attributes[self.class.attribute_map[key]].is_a?(Array)
120
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
113
+ if attributes[attribute_map[key]].is_a?(Array)
114
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
121
115
  end
122
- elsif !attributes[self.class.attribute_map[key]].nil?
123
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
116
+ elsif !attributes[attribute_map[key]].nil?
117
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
124
118
  end
125
119
  end
126
-
127
- self
120
+ new(transformed_hash)
128
121
  end
129
122
 
130
123
  # Deserializes the data based on type
131
124
  # @param string type Data type
132
125
  # @param string value Value to be deserialized
133
126
  # @return [Object] Deserialized data
134
- def _deserialize(type, value)
127
+ def self._deserialize(type, value)
135
128
  case type.to_sym
136
129
  when :Time
137
130
  Time.parse(value)
@@ -166,7 +159,7 @@ module YNAB
166
159
  else # model
167
160
  # models (e.g. Pet) or oneOf
168
161
  klass = YNAB.const_get(type)
169
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
162
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
170
163
  end
171
164
  end
172
165
 
@@ -0,0 +1,220 @@
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.ynab.com
5
+
6
+ The version of the OpenAPI document: 1.70.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.6.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module YNAB
17
+ class SavePayee
18
+ # The name of the payee. The name must be a maximum of 500 characters.
19
+ attr_accessor :name
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'name' => :'name'
25
+ }
26
+ end
27
+
28
+ # Returns all the JSON keys this model knows about
29
+ def self.acceptable_attributes
30
+ attribute_map.values
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.openapi_types
35
+ {
36
+ :'name' => :'String'
37
+ }
38
+ end
39
+
40
+ # List of attributes with nullable: true
41
+ def self.openapi_nullable
42
+ Set.new([
43
+ ])
44
+ end
45
+
46
+ # Initializes the object
47
+ # @param [Hash] attributes Model attributes in the form of hash
48
+ def initialize(attributes = {})
49
+ if (!attributes.is_a?(Hash))
50
+ fail ArgumentError, "The input argument (attributes) must be a hash in `YNAB::SavePayee` initialize method"
51
+ end
52
+
53
+ # check to see if the attribute exists and convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h|
55
+ if (!self.class.attribute_map.key?(k.to_sym))
56
+ fail ArgumentError, "`#{k}` is not a valid attribute in `YNAB::SavePayee`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
57
+ end
58
+ h[k.to_sym] = v
59
+ }
60
+
61
+ if attributes.key?(:'name')
62
+ self.name = attributes[:'name']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ return false if !@name.nil? && @name.to_s.length > 500
77
+ true
78
+ end
79
+
80
+ # Custom attribute writer method with validation
81
+ # @param [Object] name Value to be assigned
82
+ def name=(name)
83
+ @name = name
84
+ end
85
+
86
+ # Checks equality by comparing each attribute.
87
+ # @param [Object] Object to be compared
88
+ def ==(o)
89
+ return true if self.equal?(o)
90
+ self.class == o.class &&
91
+ name == o.name
92
+ end
93
+
94
+ # @see the `==` method
95
+ # @param [Object] Object to be compared
96
+ def eql?(o)
97
+ self == o
98
+ end
99
+
100
+ # Calculates hash code according to all attributes.
101
+ # @return [Integer] Hash code
102
+ def hash
103
+ [name].hash
104
+ end
105
+
106
+ # Builds the object from hash
107
+ # @param [Hash] attributes Model attributes in the form of hash
108
+ # @return [Object] Returns the model itself
109
+ def self.build_from_hash(attributes)
110
+ return nil unless attributes.is_a?(Hash)
111
+ attributes = attributes.transform_keys(&:to_sym)
112
+ transformed_hash = {}
113
+ openapi_types.each_pair do |key, type|
114
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
115
+ transformed_hash["#{key}"] = nil
116
+ elsif type =~ /\AArray<(.*)>/i
117
+ # check to ensure the input is an array given that the attribute
118
+ # is documented as an array but the input is not
119
+ if attributes[attribute_map[key]].is_a?(Array)
120
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
121
+ end
122
+ elsif !attributes[attribute_map[key]].nil?
123
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
124
+ end
125
+ end
126
+ new(transformed_hash)
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def self._deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+ when :Object
152
+ # generic object (usually a Hash), return directly
153
+ value
154
+ when /\AArray<(?<inner_type>.+)>\z/
155
+ inner_type = Regexp.last_match[:inner_type]
156
+ value.map { |v| _deserialize(inner_type, v) }
157
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
158
+ k_type = Regexp.last_match[:k_type]
159
+ v_type = Regexp.last_match[:v_type]
160
+ {}.tap do |hash|
161
+ value.each do |k, v|
162
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
163
+ end
164
+ end
165
+ else # model
166
+ # models (e.g. Pet) or oneOf
167
+ klass = YNAB.const_get(type)
168
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
169
+ end
170
+ end
171
+
172
+ # Returns the string representation of the object
173
+ # @return [String] String presentation of the object
174
+ def to_s
175
+ to_hash.to_s
176
+ end
177
+
178
+ # to_body is an alias to to_hash (backward compatibility)
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_body
181
+ to_hash
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = self.send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to? :to_hash
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end