ynab 1.14.0 → 1.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/ynab.rb +11 -8
- data/lib/ynab/api/accounts_api.rb +3 -3
- data/lib/ynab/api/budgets_api.rb +6 -3
- data/lib/ynab/api/categories_api.rb +7 -7
- data/lib/ynab/api/deprecated_api.rb +1 -1
- data/lib/ynab/api/months_api.rb +3 -3
- data/lib/ynab/api/payee_locations_api.rb +1 -1
- data/lib/ynab/api/payees_api.rb +3 -3
- data/lib/ynab/api/scheduled_transactions_api.rb +3 -3
- data/lib/ynab/api/transactions_api.rb +77 -25
- data/lib/ynab/api/user_api.rb +1 -1
- data/lib/ynab/api_client.rb +3 -2
- data/lib/ynab/configuration.rb +2 -3
- data/lib/ynab/models/account.rb +4 -12
- data/lib/ynab/models/account_response.rb +4 -3
- data/lib/ynab/models/account_response_data.rb +4 -3
- data/lib/ynab/models/accounts_response.rb +4 -3
- data/lib/ynab/models/accounts_response_data.rb +4 -3
- data/lib/ynab/models/budget_detail.rb +4 -3
- data/lib/ynab/models/budget_detail_response.rb +4 -3
- data/lib/ynab/models/budget_detail_response_data.rb +4 -3
- data/lib/ynab/models/budget_settings.rb +4 -3
- data/lib/ynab/models/budget_settings_response.rb +4 -3
- data/lib/ynab/models/budget_settings_response_data.rb +4 -3
- data/lib/ynab/models/budget_summary.rb +20 -7
- data/lib/ynab/models/budget_summary_response.rb +4 -3
- data/lib/ynab/models/budget_summary_response_data.rb +4 -3
- data/lib/ynab/models/bulk_response.rb +4 -3
- data/lib/ynab/models/bulk_response_data.rb +4 -3
- data/lib/ynab/models/bulk_response_data_bulk.rb +5 -4
- data/lib/ynab/models/bulk_transactions.rb +4 -3
- data/lib/ynab/models/categories_response.rb +4 -3
- data/lib/ynab/models/categories_response_data.rb +4 -3
- data/lib/ynab/models/category.rb +6 -39
- data/lib/ynab/models/category_group.rb +4 -3
- data/lib/ynab/models/category_group_with_categories.rb +4 -3
- data/lib/ynab/models/category_response.rb +4 -3
- data/lib/ynab/models/category_response_data.rb +4 -3
- data/lib/ynab/models/currency_format.rb +4 -3
- data/lib/ynab/models/date_format.rb +4 -3
- data/lib/ynab/models/error_detail.rb +4 -3
- data/lib/ynab/models/error_response.rb +4 -3
- data/lib/ynab/models/hybrid_transaction.rb +4 -15
- data/lib/ynab/models/hybrid_transactions_response.rb +4 -3
- data/lib/ynab/models/hybrid_transactions_response_data.rb +4 -3
- data/lib/ynab/models/month_detail.rb +6 -5
- data/lib/ynab/models/month_detail_response.rb +4 -3
- data/lib/ynab/models/month_detail_response_data.rb +4 -3
- data/lib/ynab/models/month_summaries_response.rb +4 -3
- data/lib/ynab/models/month_summaries_response_data.rb +4 -3
- data/lib/ynab/models/month_summary.rb +6 -5
- data/lib/ynab/models/payee.rb +5 -4
- data/lib/ynab/models/payee_location.rb +4 -3
- data/lib/ynab/models/payee_location_response.rb +4 -3
- data/lib/ynab/models/payee_location_response_data.rb +4 -3
- data/lib/ynab/models/payee_locations_response.rb +4 -3
- data/lib/ynab/models/payee_locations_response_data.rb +4 -3
- data/lib/ynab/models/payee_response.rb +4 -3
- data/lib/ynab/models/payee_response_data.rb +4 -3
- data/lib/ynab/models/payees_response.rb +4 -3
- data/lib/ynab/models/payees_response_data.rb +4 -3
- data/lib/ynab/models/save_category_response.rb +4 -3
- data/lib/ynab/models/save_category_response_data.rb +4 -3
- data/lib/ynab/models/save_month_category.rb +4 -3
- data/lib/ynab/models/save_month_category_wrapper.rb +4 -3
- data/lib/ynab/models/save_sub_transaction.rb +259 -0
- data/lib/ynab/models/save_transaction.rb +24 -19
- data/lib/ynab/models/save_transaction_wrapper.rb +4 -3
- data/lib/ynab/models/save_transactions_response.rb +4 -3
- data/lib/ynab/models/save_transactions_response_data.rb +5 -4
- data/lib/ynab/models/save_transactions_wrapper.rb +4 -3
- data/lib/ynab/models/scheduled_sub_transaction.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_detail.rb +4 -11
- data/lib/ynab/models/scheduled_transaction_response.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_response_data.rb +4 -3
- data/lib/ynab/models/scheduled_transaction_summary.rb +4 -11
- data/lib/ynab/models/scheduled_transactions_response.rb +4 -3
- data/lib/ynab/models/scheduled_transactions_response_data.rb +4 -3
- data/lib/ynab/models/sub_transaction.rb +33 -4
- data/lib/ynab/models/transaction_detail.rb +4 -11
- data/lib/ynab/models/transaction_response.rb +4 -3
- data/lib/ynab/models/transaction_response_data.rb +4 -3
- data/lib/ynab/models/transaction_summary.rb +4 -11
- data/lib/ynab/models/transactions_import_response.rb +189 -0
- data/lib/ynab/models/transactions_import_response_data.rb +192 -0
- data/lib/ynab/models/transactions_response.rb +4 -3
- data/lib/ynab/models/transactions_response_data.rb +4 -3
- data/lib/ynab/models/update_transaction.rb +18 -27
- data/lib/ynab/models/update_transactions_wrapper.rb +4 -3
- data/lib/ynab/models/user.rb +4 -3
- data/lib/ynab/models/user_response.rb +4 -3
- data/lib/ynab/models/user_response_data.rb +4 -3
- data/lib/ynab/version.rb +1 -1
- data/spec/api/transactions_spec.rb +11 -0
- data/spec/fixtures/vcr_cassettes/import_transactions.yml +50 -0
- data/spec/models/transaction_detail_spec.rb +11 -0
- metadata +22 -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.
|
9
|
+
Swagger Codegen version: 2.4.15
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -287,20 +287,12 @@ module YNAB
|
|
287
287
|
# Custom attribute writer method checking allowed values (enum).
|
288
288
|
# @param [Object] cleared Object to be assigned
|
289
289
|
def cleared=(cleared)
|
290
|
-
validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
|
291
|
-
unless validator.valid?(cleared)
|
292
|
-
fail ArgumentError, 'invalid value for "cleared", must be one of #{validator.allowable_values}.'
|
293
|
-
end
|
294
290
|
@cleared = cleared
|
295
291
|
end
|
296
292
|
|
297
293
|
# Custom attribute writer method checking allowed values (enum).
|
298
294
|
# @param [Object] flag_color Object to be assigned
|
299
295
|
def flag_color=(flag_color)
|
300
|
-
validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
|
301
|
-
unless validator.valid?(flag_color)
|
302
|
-
fail ArgumentError, 'invalid value for "flag_color", must be one of #{validator.allowable_values}.'
|
303
|
-
end
|
304
296
|
@flag_color = flag_color
|
305
297
|
end
|
306
298
|
|
@@ -341,7 +333,6 @@ module YNAB
|
|
341
333
|
def hash
|
342
334
|
[id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, matched_transaction_id, import_id, deleted, account_name, payee_name, category_name, subtransactions].hash
|
343
335
|
end
|
344
|
-
|
345
336
|
# Builds the object from hash
|
346
337
|
# @param [Hash] attributes Model attributes in the form of hash
|
347
338
|
# @return [Object] Returns the model itself
|
@@ -349,7 +340,7 @@ module YNAB
|
|
349
340
|
return nil unless attributes.is_a?(Hash)
|
350
341
|
self.class.swagger_types.each_pair do |key, type|
|
351
342
|
if type =~ /\AArray<(.*)>/i
|
352
|
-
# check to ensure the input is an array given that the
|
343
|
+
# check to ensure the input is an array given that the attribute
|
353
344
|
# is documented as an array but the input is not
|
354
345
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
355
346
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -445,5 +436,7 @@ module YNAB
|
|
445
436
|
value
|
446
437
|
end
|
447
438
|
end
|
439
|
+
|
448
440
|
end
|
441
|
+
|
449
442
|
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.
|
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
|
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.
|
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
|
[transaction].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
|
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.
|
9
|
+
Swagger Codegen version: 2.4.15
|
10
10
|
|
11
11
|
=end
|
12
12
|
|
@@ -242,20 +242,12 @@ module YNAB
|
|
242
242
|
# Custom attribute writer method checking allowed values (enum).
|
243
243
|
# @param [Object] cleared Object to be assigned
|
244
244
|
def cleared=(cleared)
|
245
|
-
validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
|
246
|
-
unless validator.valid?(cleared)
|
247
|
-
fail ArgumentError, 'invalid value for "cleared", must be one of #{validator.allowable_values}.'
|
248
|
-
end
|
249
245
|
@cleared = cleared
|
250
246
|
end
|
251
247
|
|
252
248
|
# Custom attribute writer method checking allowed values (enum).
|
253
249
|
# @param [Object] flag_color Object to be assigned
|
254
250
|
def flag_color=(flag_color)
|
255
|
-
validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
|
256
|
-
unless validator.valid?(flag_color)
|
257
|
-
fail ArgumentError, 'invalid value for "flag_color", must be one of #{validator.allowable_values}.'
|
258
|
-
end
|
259
251
|
@flag_color = flag_color
|
260
252
|
end
|
261
253
|
|
@@ -292,7 +284,6 @@ module YNAB
|
|
292
284
|
def hash
|
293
285
|
[id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, matched_transaction_id, import_id, deleted].hash
|
294
286
|
end
|
295
|
-
|
296
287
|
# Builds the object from hash
|
297
288
|
# @param [Hash] attributes Model attributes in the form of hash
|
298
289
|
# @return [Object] Returns the model itself
|
@@ -300,7 +291,7 @@ module YNAB
|
|
300
291
|
return nil unless attributes.is_a?(Hash)
|
301
292
|
self.class.swagger_types.each_pair do |key, type|
|
302
293
|
if type =~ /\AArray<(.*)>/i
|
303
|
-
# check to ensure the input is an array given that the
|
294
|
+
# check to ensure the input is an array given that the attribute
|
304
295
|
# is documented as an array but the input is not
|
305
296
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
306
297
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -396,5 +387,7 @@ module YNAB
|
|
396
387
|
value
|
397
388
|
end
|
398
389
|
end
|
390
|
+
|
399
391
|
end
|
392
|
+
|
400
393
|
end
|
@@ -0,0 +1,189 @@
|
|
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 TransactionsImportResponse
|
17
|
+
attr_accessor :data
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'data' => :'data'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'data' => :'TransactionsImportResponseData'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Initializes the object
|
34
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
35
|
+
def initialize(attributes = {})
|
36
|
+
return unless attributes.is_a?(Hash)
|
37
|
+
|
38
|
+
# convert string to symbol for hash key
|
39
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
40
|
+
|
41
|
+
if attributes.has_key?(:'data')
|
42
|
+
self.data = attributes[:'data']
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
47
|
+
# @return Array for valid properties with the reasons
|
48
|
+
def list_invalid_properties
|
49
|
+
invalid_properties = Array.new
|
50
|
+
if @data.nil?
|
51
|
+
invalid_properties.push('invalid value for "data", data cannot be nil.')
|
52
|
+
end
|
53
|
+
|
54
|
+
invalid_properties
|
55
|
+
end
|
56
|
+
|
57
|
+
# Check to see if the all the properties in the model are valid
|
58
|
+
# @return true if the model is valid
|
59
|
+
def valid?
|
60
|
+
return false if @data.nil?
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
# Checks equality by comparing each attribute.
|
65
|
+
# @param [Object] Object to be compared
|
66
|
+
def ==(o)
|
67
|
+
return true if self.equal?(o)
|
68
|
+
self.class == o.class &&
|
69
|
+
data == o.data
|
70
|
+
end
|
71
|
+
|
72
|
+
# @see the `==` method
|
73
|
+
# @param [Object] Object to be compared
|
74
|
+
def eql?(o)
|
75
|
+
self == o
|
76
|
+
end
|
77
|
+
|
78
|
+
# Calculates hash code according to all attributes.
|
79
|
+
# @return [Fixnum] Hash code
|
80
|
+
def hash
|
81
|
+
[data].hash
|
82
|
+
end
|
83
|
+
# Builds the object from hash
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
+
# @return [Object] Returns the model itself
|
86
|
+
def build_from_hash(attributes)
|
87
|
+
return nil unless attributes.is_a?(Hash)
|
88
|
+
self.class.swagger_types.each_pair do |key, type|
|
89
|
+
if type =~ /\AArray<(.*)>/i
|
90
|
+
# check to ensure the input is an array given that the attribute
|
91
|
+
# is documented as an array but the input is not
|
92
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
93
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
94
|
+
end
|
95
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
96
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
97
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
98
|
+
end
|
99
|
+
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
# Deserializes the data based on type
|
104
|
+
# @param string type Data type
|
105
|
+
# @param string value Value to be deserialized
|
106
|
+
# @return [Object] Deserialized data
|
107
|
+
def _deserialize(type, value)
|
108
|
+
case type.to_sym
|
109
|
+
when :DateTime
|
110
|
+
DateTime.parse(value)
|
111
|
+
when :Date
|
112
|
+
Date.parse(value)
|
113
|
+
when :String
|
114
|
+
value.to_s
|
115
|
+
when :Integer
|
116
|
+
value.to_i
|
117
|
+
when :Float
|
118
|
+
value.to_f
|
119
|
+
when :BOOLEAN
|
120
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
121
|
+
true
|
122
|
+
else
|
123
|
+
false
|
124
|
+
end
|
125
|
+
when :Object
|
126
|
+
# generic object (usually a Hash), return directly
|
127
|
+
value
|
128
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
129
|
+
inner_type = Regexp.last_match[:inner_type]
|
130
|
+
value.map { |v| _deserialize(inner_type, v) }
|
131
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
132
|
+
k_type = Regexp.last_match[:k_type]
|
133
|
+
v_type = Regexp.last_match[:v_type]
|
134
|
+
{}.tap do |hash|
|
135
|
+
value.each do |k, v|
|
136
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
else # model
|
140
|
+
temp_model = YNAB.const_get(type).new
|
141
|
+
temp_model.build_from_hash(value)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
# Returns the string representation of the object
|
146
|
+
# @return [String] String presentation of the object
|
147
|
+
def to_s
|
148
|
+
to_hash.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# to_body is an alias to to_hash (backward compatibility)
|
152
|
+
# @return [Hash] Returns the object in the form of hash
|
153
|
+
def to_body
|
154
|
+
to_hash
|
155
|
+
end
|
156
|
+
|
157
|
+
# Returns the object in the form of hash
|
158
|
+
# @return [Hash] Returns the object in the form of hash
|
159
|
+
def to_hash
|
160
|
+
hash = {}
|
161
|
+
self.class.attribute_map.each_pair do |attr, param|
|
162
|
+
value = self.send(attr)
|
163
|
+
next if value.nil?
|
164
|
+
hash[param] = _to_hash(value)
|
165
|
+
end
|
166
|
+
hash
|
167
|
+
end
|
168
|
+
|
169
|
+
# Outputs non-array value in the form of hash
|
170
|
+
# For object, use to_hash. Otherwise, just return the value
|
171
|
+
# @param [Object] value Any valid value
|
172
|
+
# @return [Hash] Returns the value in the form of hash
|
173
|
+
def _to_hash(value)
|
174
|
+
if value.is_a?(Array)
|
175
|
+
value.compact.map { |v| _to_hash(v) }
|
176
|
+
elsif value.is_a?(Hash)
|
177
|
+
{}.tap do |hash|
|
178
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
179
|
+
end
|
180
|
+
elsif value.respond_to? :to_hash
|
181
|
+
value.to_hash
|
182
|
+
else
|
183
|
+
value
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
end
|
@@ -0,0 +1,192 @@
|
|
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 TransactionsImportResponseData
|
17
|
+
# The list of transaction ids that were imported.
|
18
|
+
attr_accessor :transaction_ids
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'transaction_ids' => :'transaction_ids'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.swagger_types
|
29
|
+
{
|
30
|
+
:'transaction_ids' => :'Array<String>'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
return unless attributes.is_a?(Hash)
|
38
|
+
|
39
|
+
# convert string to symbol for hash key
|
40
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
41
|
+
|
42
|
+
if attributes.has_key?(:'transaction_ids')
|
43
|
+
if (value = attributes[:'transaction_ids']).is_a?(Array)
|
44
|
+
self.transaction_ids = value
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
50
|
+
# @return Array for valid properties with the reasons
|
51
|
+
def list_invalid_properties
|
52
|
+
invalid_properties = Array.new
|
53
|
+
if @transaction_ids.nil?
|
54
|
+
invalid_properties.push('invalid value for "transaction_ids", transaction_ids cannot be nil.')
|
55
|
+
end
|
56
|
+
|
57
|
+
invalid_properties
|
58
|
+
end
|
59
|
+
|
60
|
+
# Check to see if the all the properties in the model are valid
|
61
|
+
# @return true if the model is valid
|
62
|
+
def valid?
|
63
|
+
return false if @transaction_ids.nil?
|
64
|
+
true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Checks equality by comparing each attribute.
|
68
|
+
# @param [Object] Object to be compared
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
transaction_ids == o.transaction_ids
|
73
|
+
end
|
74
|
+
|
75
|
+
# @see the `==` method
|
76
|
+
# @param [Object] Object to be compared
|
77
|
+
def eql?(o)
|
78
|
+
self == o
|
79
|
+
end
|
80
|
+
|
81
|
+
# Calculates hash code according to all attributes.
|
82
|
+
# @return [Fixnum] Hash code
|
83
|
+
def hash
|
84
|
+
[transaction_ids].hash
|
85
|
+
end
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
self.class.swagger_types.each_pair do |key, type|
|
92
|
+
if type =~ /\AArray<(.*)>/i
|
93
|
+
# check to ensure the input is an array given that the attribute
|
94
|
+
# is documented as an array but the input is not
|
95
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
96
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
97
|
+
end
|
98
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
99
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
100
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
101
|
+
end
|
102
|
+
|
103
|
+
self
|
104
|
+
end
|
105
|
+
|
106
|
+
# Deserializes the data based on type
|
107
|
+
# @param string type Data type
|
108
|
+
# @param string value Value to be deserialized
|
109
|
+
# @return [Object] Deserialized data
|
110
|
+
def _deserialize(type, value)
|
111
|
+
case type.to_sym
|
112
|
+
when :DateTime
|
113
|
+
DateTime.parse(value)
|
114
|
+
when :Date
|
115
|
+
Date.parse(value)
|
116
|
+
when :String
|
117
|
+
value.to_s
|
118
|
+
when :Integer
|
119
|
+
value.to_i
|
120
|
+
when :Float
|
121
|
+
value.to_f
|
122
|
+
when :BOOLEAN
|
123
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
124
|
+
true
|
125
|
+
else
|
126
|
+
false
|
127
|
+
end
|
128
|
+
when :Object
|
129
|
+
# generic object (usually a Hash), return directly
|
130
|
+
value
|
131
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
132
|
+
inner_type = Regexp.last_match[:inner_type]
|
133
|
+
value.map { |v| _deserialize(inner_type, v) }
|
134
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
135
|
+
k_type = Regexp.last_match[:k_type]
|
136
|
+
v_type = Regexp.last_match[:v_type]
|
137
|
+
{}.tap do |hash|
|
138
|
+
value.each do |k, v|
|
139
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
else # model
|
143
|
+
temp_model = YNAB.const_get(type).new
|
144
|
+
temp_model.build_from_hash(value)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Returns the string representation of the object
|
149
|
+
# @return [String] String presentation of the object
|
150
|
+
def to_s
|
151
|
+
to_hash.to_s
|
152
|
+
end
|
153
|
+
|
154
|
+
# to_body is an alias to to_hash (backward compatibility)
|
155
|
+
# @return [Hash] Returns the object in the form of hash
|
156
|
+
def to_body
|
157
|
+
to_hash
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the object in the form of hash
|
161
|
+
# @return [Hash] Returns the object in the form of hash
|
162
|
+
def to_hash
|
163
|
+
hash = {}
|
164
|
+
self.class.attribute_map.each_pair do |attr, param|
|
165
|
+
value = self.send(attr)
|
166
|
+
next if value.nil?
|
167
|
+
hash[param] = _to_hash(value)
|
168
|
+
end
|
169
|
+
hash
|
170
|
+
end
|
171
|
+
|
172
|
+
# Outputs non-array value in the form of hash
|
173
|
+
# For object, use to_hash. Otherwise, just return the value
|
174
|
+
# @param [Object] value Any valid value
|
175
|
+
# @return [Hash] Returns the value in the form of hash
|
176
|
+
def _to_hash(value)
|
177
|
+
if value.is_a?(Array)
|
178
|
+
value.compact.map { |v| _to_hash(v) }
|
179
|
+
elsif value.is_a?(Hash)
|
180
|
+
{}.tap do |hash|
|
181
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
182
|
+
end
|
183
|
+
elsif value.respond_to? :to_hash
|
184
|
+
value.to_hash
|
185
|
+
else
|
186
|
+
value
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|