ynab 1.15.0 → 1.20.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 +13 -8
- data/lib/ynab/api/accounts_api.rb +65 -7
- data/lib/ynab/api/budgets_api.rb +10 -7
- data/lib/ynab/api/categories_api.rb +15 -15
- data/lib/ynab/api/deprecated_api.rb +3 -3
- data/lib/ynab/api/months_api.rb +7 -7
- data/lib/ynab/api/payee_locations_api.rb +7 -7
- data/lib/ynab/api/payees_api.rb +7 -7
- data/lib/ynab/api/scheduled_transactions_api.rb +7 -7
- data/lib/ynab/api/transactions_api.rb +93 -41
- 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 -7
- 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 -9
- 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_account.rb +250 -0
- data/lib/ynab/models/save_account_wrapper.rb +189 -0
- 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/accounts_spec.rb +19 -10
- data/spec/api/budgets_spec.rb +4 -4
- data/spec/api/categories_spec.rb +5 -5
- data/spec/api/months_spec.rb +4 -4
- data/spec/api/payee_locations_spec.rb +4 -4
- data/spec/api/payees_spec.rb +4 -4
- data/spec/api/scheduled_transactions_spec.rb +4 -4
- data/spec/api/transactions_spec.rb +23 -13
- data/spec/fixtures/vcr_cassettes/create_account.yml +51 -0
- data/spec/fixtures/vcr_cassettes/import_transactions.yml +50 -0
- data/spec/models/transaction_detail_spec.rb +11 -0
- metadata +26 -15
@@ -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 SaveAccountWrapper
|
17
|
+
attr_accessor :account
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'account' => :'account'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.swagger_types
|
28
|
+
{
|
29
|
+
:'account' => :'SaveAccount'
|
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?(:'account')
|
42
|
+
self.account = attributes[:'account']
|
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 @account.nil?
|
51
|
+
invalid_properties.push('invalid value for "account", account 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 @account.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
|
+
account == o.account
|
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
|
+
[account].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
|
@@ -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
|
|
@@ -95,7 +95,6 @@ module YNAB
|
|
95
95
|
def hash
|
96
96
|
[category, server_knowledge].hash
|
97
97
|
end
|
98
|
-
|
99
98
|
# Builds the object from hash
|
100
99
|
# @param [Hash] attributes Model attributes in the form of hash
|
101
100
|
# @return [Object] Returns the model itself
|
@@ -103,7 +102,7 @@ module YNAB
|
|
103
102
|
return nil unless attributes.is_a?(Hash)
|
104
103
|
self.class.swagger_types.each_pair do |key, type|
|
105
104
|
if type =~ /\AArray<(.*)>/i
|
106
|
-
# check to ensure the input is an array given that the
|
105
|
+
# check to ensure the input is an array given that the attribute
|
107
106
|
# is documented as an array but the input is not
|
108
107
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
109
108
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -199,5 +198,7 @@ module YNAB
|
|
199
198
|
value
|
200
199
|
end
|
201
200
|
end
|
201
|
+
|
202
202
|
end
|
203
|
+
|
203
204
|
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
|
|
@@ -81,7 +81,6 @@ module YNAB
|
|
81
81
|
def hash
|
82
82
|
[budgeted].hash
|
83
83
|
end
|
84
|
-
|
85
84
|
# Builds the object from hash
|
86
85
|
# @param [Hash] attributes Model attributes in the form of hash
|
87
86
|
# @return [Object] Returns the model itself
|
@@ -89,7 +88,7 @@ module YNAB
|
|
89
88
|
return nil unless attributes.is_a?(Hash)
|
90
89
|
self.class.swagger_types.each_pair do |key, type|
|
91
90
|
if type =~ /\AArray<(.*)>/i
|
92
|
-
# check to ensure the input is an array given that the
|
91
|
+
# check to ensure the input is an array given that the attribute
|
93
92
|
# is documented as an array but the input is not
|
94
93
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
95
94
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
@@ -185,5 +184,7 @@ module YNAB
|
|
185
184
|
value
|
186
185
|
end
|
187
186
|
end
|
187
|
+
|
188
188
|
end
|
189
|
+
|
189
190
|
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
|
[category].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
|
@@ -0,0 +1,259 @@
|
|
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 SaveSubTransaction
|
17
|
+
# The subtransaction amount in milliunits format.
|
18
|
+
attr_accessor :amount
|
19
|
+
|
20
|
+
# The payee for the subtransaction.
|
21
|
+
attr_accessor :payee_id
|
22
|
+
|
23
|
+
# The payee name. If a `payee_name` value is provided and `payee_id` has a null value, the `payee_name` value will be used to resolve the payee by either (1) a matching payee rename rule (only if import_id is also specified on parent transaction) or (2) a payee with the same name or (3) creation of a new payee.
|
24
|
+
attr_accessor :payee_name
|
25
|
+
|
26
|
+
# The category for the subtransaction. Credit Card Payment categories are not permitted and will be ignored if supplied.
|
27
|
+
attr_accessor :category_id
|
28
|
+
|
29
|
+
attr_accessor :memo
|
30
|
+
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
32
|
+
def self.attribute_map
|
33
|
+
{
|
34
|
+
:'amount' => :'amount',
|
35
|
+
:'payee_id' => :'payee_id',
|
36
|
+
:'payee_name' => :'payee_name',
|
37
|
+
:'category_id' => :'category_id',
|
38
|
+
:'memo' => :'memo'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# Attribute type mapping.
|
43
|
+
def self.swagger_types
|
44
|
+
{
|
45
|
+
:'amount' => :'Integer',
|
46
|
+
:'payee_id' => :'String',
|
47
|
+
:'payee_name' => :'String',
|
48
|
+
:'category_id' => :'String',
|
49
|
+
:'memo' => :'String'
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
return unless attributes.is_a?(Hash)
|
57
|
+
|
58
|
+
# convert string to symbol for hash key
|
59
|
+
attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
|
60
|
+
|
61
|
+
if attributes.has_key?(:'amount')
|
62
|
+
self.amount = attributes[:'amount']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes.has_key?(:'payee_id')
|
66
|
+
self.payee_id = attributes[:'payee_id']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes.has_key?(:'payee_name')
|
70
|
+
self.payee_name = attributes[:'payee_name']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'category_id')
|
74
|
+
self.category_id = attributes[:'category_id']
|
75
|
+
end
|
76
|
+
|
77
|
+
if attributes.has_key?(:'memo')
|
78
|
+
self.memo = attributes[:'memo']
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
83
|
+
# @return Array for valid properties with the reasons
|
84
|
+
def list_invalid_properties
|
85
|
+
invalid_properties = Array.new
|
86
|
+
if @amount.nil?
|
87
|
+
invalid_properties.push('invalid value for "amount", amount cannot be nil.')
|
88
|
+
end
|
89
|
+
|
90
|
+
if !@payee_name.nil? && @payee_name.to_s.length > 50
|
91
|
+
invalid_properties.push('invalid value for "payee_name", the character length must be smaller than or equal to 50.')
|
92
|
+
end
|
93
|
+
|
94
|
+
if !@memo.nil? && @memo.to_s.length > 200
|
95
|
+
invalid_properties.push('invalid value for "memo", the character length must be smaller than or equal to 200.')
|
96
|
+
end
|
97
|
+
|
98
|
+
invalid_properties
|
99
|
+
end
|
100
|
+
|
101
|
+
# Check to see if the all the properties in the model are valid
|
102
|
+
# @return true if the model is valid
|
103
|
+
def valid?
|
104
|
+
return false if @amount.nil?
|
105
|
+
return false if !@payee_name.nil? && @payee_name.to_s.length > 50
|
106
|
+
return false if !@memo.nil? && @memo.to_s.length > 200
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
110
|
+
# Custom attribute writer method with validation
|
111
|
+
# @param [Object] payee_name Value to be assigned
|
112
|
+
def payee_name=(payee_name)
|
113
|
+
if !payee_name.nil? && payee_name.to_s.length > 50
|
114
|
+
fail ArgumentError, 'invalid value for "payee_name", the character length must be smaller than or equal to 50.'
|
115
|
+
end
|
116
|
+
|
117
|
+
@payee_name = payee_name
|
118
|
+
end
|
119
|
+
|
120
|
+
# Custom attribute writer method with validation
|
121
|
+
# @param [Object] memo Value to be assigned
|
122
|
+
def memo=(memo)
|
123
|
+
if !memo.nil? && memo.to_s.length > 200
|
124
|
+
fail ArgumentError, 'invalid value for "memo", the character length must be smaller than or equal to 200.'
|
125
|
+
end
|
126
|
+
|
127
|
+
@memo = memo
|
128
|
+
end
|
129
|
+
|
130
|
+
# Checks equality by comparing each attribute.
|
131
|
+
# @param [Object] Object to be compared
|
132
|
+
def ==(o)
|
133
|
+
return true if self.equal?(o)
|
134
|
+
self.class == o.class &&
|
135
|
+
amount == o.amount &&
|
136
|
+
payee_id == o.payee_id &&
|
137
|
+
payee_name == o.payee_name &&
|
138
|
+
category_id == o.category_id &&
|
139
|
+
memo == o.memo
|
140
|
+
end
|
141
|
+
|
142
|
+
# @see the `==` method
|
143
|
+
# @param [Object] Object to be compared
|
144
|
+
def eql?(o)
|
145
|
+
self == o
|
146
|
+
end
|
147
|
+
|
148
|
+
# Calculates hash code according to all attributes.
|
149
|
+
# @return [Fixnum] Hash code
|
150
|
+
def hash
|
151
|
+
[amount, payee_id, payee_name, category_id, memo].hash
|
152
|
+
end
|
153
|
+
# Builds the object from hash
|
154
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
+
# @return [Object] Returns the model itself
|
156
|
+
def build_from_hash(attributes)
|
157
|
+
return nil unless attributes.is_a?(Hash)
|
158
|
+
self.class.swagger_types.each_pair do |key, type|
|
159
|
+
if type =~ /\AArray<(.*)>/i
|
160
|
+
# check to ensure the input is an array given that the attribute
|
161
|
+
# is documented as an array but the input is not
|
162
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
163
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
164
|
+
end
|
165
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
166
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
167
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
168
|
+
end
|
169
|
+
|
170
|
+
self
|
171
|
+
end
|
172
|
+
|
173
|
+
# Deserializes the data based on type
|
174
|
+
# @param string type Data type
|
175
|
+
# @param string value Value to be deserialized
|
176
|
+
# @return [Object] Deserialized data
|
177
|
+
def _deserialize(type, value)
|
178
|
+
case type.to_sym
|
179
|
+
when :DateTime
|
180
|
+
DateTime.parse(value)
|
181
|
+
when :Date
|
182
|
+
Date.parse(value)
|
183
|
+
when :String
|
184
|
+
value.to_s
|
185
|
+
when :Integer
|
186
|
+
value.to_i
|
187
|
+
when :Float
|
188
|
+
value.to_f
|
189
|
+
when :BOOLEAN
|
190
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
191
|
+
true
|
192
|
+
else
|
193
|
+
false
|
194
|
+
end
|
195
|
+
when :Object
|
196
|
+
# generic object (usually a Hash), return directly
|
197
|
+
value
|
198
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
199
|
+
inner_type = Regexp.last_match[:inner_type]
|
200
|
+
value.map { |v| _deserialize(inner_type, v) }
|
201
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
202
|
+
k_type = Regexp.last_match[:k_type]
|
203
|
+
v_type = Regexp.last_match[:v_type]
|
204
|
+
{}.tap do |hash|
|
205
|
+
value.each do |k, v|
|
206
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
else # model
|
210
|
+
temp_model = YNAB.const_get(type).new
|
211
|
+
temp_model.build_from_hash(value)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# Returns the string representation of the object
|
216
|
+
# @return [String] String presentation of the object
|
217
|
+
def to_s
|
218
|
+
to_hash.to_s
|
219
|
+
end
|
220
|
+
|
221
|
+
# to_body is an alias to to_hash (backward compatibility)
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
223
|
+
def to_body
|
224
|
+
to_hash
|
225
|
+
end
|
226
|
+
|
227
|
+
# Returns the object in the form of hash
|
228
|
+
# @return [Hash] Returns the object in the form of hash
|
229
|
+
def to_hash
|
230
|
+
hash = {}
|
231
|
+
self.class.attribute_map.each_pair do |attr, param|
|
232
|
+
value = self.send(attr)
|
233
|
+
next if value.nil?
|
234
|
+
hash[param] = _to_hash(value)
|
235
|
+
end
|
236
|
+
hash
|
237
|
+
end
|
238
|
+
|
239
|
+
# Outputs non-array value in the form of hash
|
240
|
+
# For object, use to_hash. Otherwise, just return the value
|
241
|
+
# @param [Object] value Any valid value
|
242
|
+
# @return [Hash] Returns the value in the form of hash
|
243
|
+
def _to_hash(value)
|
244
|
+
if value.is_a?(Array)
|
245
|
+
value.compact.map { |v| _to_hash(v) }
|
246
|
+
elsif value.is_a?(Hash)
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
249
|
+
end
|
250
|
+
elsif value.respond_to? :to_hash
|
251
|
+
value.to_hash
|
252
|
+
else
|
253
|
+
value
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|