ynab 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config.json +1 -1
- data/docs/HybridTransaction.md +21 -0
- data/docs/HybridTransactionsResponse.md +8 -0
- data/docs/HybridTransactionsWrapper.md +8 -0
- data/docs/ScheduledSubTransaction.md +1 -1
- data/docs/ScheduledTransactionDetail.md +4 -1
- data/docs/SubTransaction.md +1 -1
- data/docs/TransactionDetail.md +3 -1
- data/docs/TransactionsApi.md +4 -4
- data/lib/ynab.rb +4 -0
- data/lib/ynab/api/transactions_api.rb +6 -6
- data/lib/ynab/models/hybrid_transaction.rb +439 -0
- data/lib/ynab/models/hybrid_transactions_response.rb +193 -0
- data/lib/ynab/models/hybrid_transactions_wrapper.rb +195 -0
- data/lib/ynab/models/scheduled_sub_transaction.rb +1 -1
- data/lib/ynab/models/scheduled_transaction_detail.rb +44 -2
- data/lib/ynab/models/sub_transaction.rb +1 -1
- data/lib/ynab/models/transaction_detail.rb +30 -2
- data/lib/ynab/version.rb +1 -1
- data/spec-v1-swagger.json +79 -8
- data/spec/api/transactions_spec.rb +24 -2
- data/spec/fixtures/vcr_cassettes/category_transactions.yml +46 -0
- data/spec/fixtures/vcr_cassettes/payee_transactions.yml +46 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df9ea24b0ebeb3e14645747e918e4a3654ad7b8a
|
4
|
+
data.tar.gz: f552b0fba980ba2ec495c1bde80d814e165e4f43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30486289c7320d39173f8c1ed55ff4b422faef8de7dca4c5957275101360c61c44f85b4bd94c134a3bb8da76e5442b6c1041232ff840f6c416fc2ce7d75d4b43
|
7
|
+
data.tar.gz: 1e594649f9f6b50f3360da6eb96272a6354e81e0dc1735a1b0a5ea29143235c4045b54339dcc9e529f7d331f2d3adef412629c7cf7eaf066659a39f240f9d521
|
data/config.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"gemName": "ynab",
|
3
3
|
"moduleName": "YnabApi",
|
4
|
-
"gemVersion": "0.
|
4
|
+
"gemVersion": "0.5.0",
|
5
5
|
"gemDescription": "Ruby gem wrapper for the YNAB API. Read the documentation at https://api.youneedabudget.com",
|
6
6
|
"gemHomepage": "https://github.com/ynab/ynab-sdk-ruby",
|
7
7
|
"gemLicense": "Apache-2.0",
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# YnabApi::HybridTransaction
|
2
|
+
|
3
|
+
## Properties
|
4
|
+
Name | Type | Description | Notes
|
5
|
+
------------ | ------------- | ------------- | -------------
|
6
|
+
**id** | **String** | |
|
7
|
+
**date** | **Date** | |
|
8
|
+
**amount** | **Float** | The transaction amount in milliunits format |
|
9
|
+
**memo** | **String** | |
|
10
|
+
**cleared** | **String** | The cleared status of the transaction |
|
11
|
+
**approved** | **BOOLEAN** | Whether or not the transaction is approved |
|
12
|
+
**flag_color** | **String** | The transaction flag |
|
13
|
+
**account_id** | **String** | |
|
14
|
+
**payee_id** | **String** | |
|
15
|
+
**category_id** | **String** | |
|
16
|
+
**transfer_account_id** | **String** | |
|
17
|
+
**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. |
|
18
|
+
**type** | **String** | Whether the hybrid transaction represents a regular transaction or a subtransaction |
|
19
|
+
**parent_transaction_id** | **String** | For subtransaction types, this is the id of the pararent transaction. For transaction types, this id will be always be null. |
|
20
|
+
|
21
|
+
|
@@ -5,7 +5,7 @@ Name | Type | Description | Notes
|
|
5
5
|
------------ | ------------- | ------------- | -------------
|
6
6
|
**id** | **String** | |
|
7
7
|
**scheduled_transaction_id** | **String** | |
|
8
|
-
**amount** | **Float** | The scheduled
|
8
|
+
**amount** | **Float** | The scheduled subtransaction amount in milliunits format |
|
9
9
|
**memo** | **String** | |
|
10
10
|
**payee_id** | **String** | |
|
11
11
|
**category_id** | **String** | |
|
@@ -14,6 +14,9 @@ Name | Type | Description | Notes
|
|
14
14
|
**payee_id** | **String** | |
|
15
15
|
**category_id** | **String** | |
|
16
16
|
**transfer_account_id** | **String** | If a transfer, the account_id which the scheduled transaction transfers to |
|
17
|
-
**
|
17
|
+
**account_name** | **String** | |
|
18
|
+
**payee_name** | **String** | |
|
19
|
+
**category_name** | **String** | |
|
20
|
+
**subtransactions** | [**Array<ScheduledSubTransaction>**](ScheduledSubTransaction.md) | If a split scheduled transaction, the subtransactions. |
|
18
21
|
|
19
22
|
|
data/docs/SubTransaction.md
CHANGED
@@ -5,7 +5,7 @@ Name | Type | Description | Notes
|
|
5
5
|
------------ | ------------- | ------------- | -------------
|
6
6
|
**id** | **String** | |
|
7
7
|
**transaction_id** | **String** | |
|
8
|
-
**amount** | **Float** | The
|
8
|
+
**amount** | **Float** | The subtransaction amount in milliunits format |
|
9
9
|
**memo** | **String** | |
|
10
10
|
**payee_id** | **String** | |
|
11
11
|
**category_id** | **String** | |
|
data/docs/TransactionDetail.md
CHANGED
@@ -15,6 +15,8 @@ Name | Type | Description | Notes
|
|
15
15
|
**category_id** | **String** | |
|
16
16
|
**transfer_account_id** | **String** | |
|
17
17
|
**import_id** | **String** | If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'. |
|
18
|
-
**
|
18
|
+
**payee_name** | **String** | |
|
19
|
+
**category_name** | **String** | |
|
20
|
+
**subtransactions** | [**Array<SubTransaction>**](SubTransaction.md) | If a split transaction, the subtransactions. |
|
19
21
|
|
20
22
|
|
data/docs/TransactionsApi.md
CHANGED
@@ -250,7 +250,7 @@ Name | Type | Description | Notes
|
|
250
250
|
|
251
251
|
|
252
252
|
# **get_transactions_by_category**
|
253
|
-
>
|
253
|
+
> HybridTransactionsResponse get_transactions_by_category(budget_id, category_id, opts)
|
254
254
|
|
255
255
|
List category transactions
|
256
256
|
|
@@ -297,7 +297,7 @@ Name | Type | Description | Notes
|
|
297
297
|
|
298
298
|
### Return type
|
299
299
|
|
300
|
-
[**
|
300
|
+
[**HybridTransactionsResponse**](HybridTransactionsResponse.md)
|
301
301
|
|
302
302
|
### Authorization
|
303
303
|
|
@@ -368,7 +368,7 @@ Name | Type | Description | Notes
|
|
368
368
|
|
369
369
|
|
370
370
|
# **get_transactions_by_payee**
|
371
|
-
>
|
371
|
+
> HybridTransactionsResponse get_transactions_by_payee(budget_id, payee_id, opts)
|
372
372
|
|
373
373
|
List payee transactions
|
374
374
|
|
@@ -415,7 +415,7 @@ Name | Type | Description | Notes
|
|
415
415
|
|
416
416
|
### Return type
|
417
417
|
|
418
|
-
[**
|
418
|
+
[**HybridTransactionsResponse**](HybridTransactionsResponse.md)
|
419
419
|
|
420
420
|
### Authorization
|
421
421
|
|
data/lib/ynab.rb
CHANGED
@@ -74,6 +74,10 @@ require 'ynab/models/transaction_detail'
|
|
74
74
|
require 'ynab/models/bulk_id_wrapper'
|
75
75
|
require 'ynab/models/bulk_ids'
|
76
76
|
require 'ynab/models/bulk_response'
|
77
|
+
require 'ynab/models/hybrid_transactions_response'
|
78
|
+
require 'ynab/models/hybrid_transactions_wrapper'
|
79
|
+
require 'ynab/models/hybrid_transaction'
|
80
|
+
|
77
81
|
|
78
82
|
# APIs
|
79
83
|
require 'ynab/api/user_api'
|
@@ -268,7 +268,7 @@ module YnabApi
|
|
268
268
|
# @param category_id The ID of the Category.
|
269
269
|
# @param [Hash] opts the optional parameters
|
270
270
|
# @option opts [Date] :since_date Only return transactions on or after this date.
|
271
|
-
# @return [
|
271
|
+
# @return [HybridTransactionsResponse]
|
272
272
|
def get_transactions_by_category(budget_id, category_id, opts = {})
|
273
273
|
data, _status_code, _headers = get_transactions_by_category_with_http_info(budget_id, category_id, opts)
|
274
274
|
return data
|
@@ -280,7 +280,7 @@ module YnabApi
|
|
280
280
|
# @param category_id The ID of the Category.
|
281
281
|
# @param [Hash] opts the optional parameters
|
282
282
|
# @option opts [Date] :since_date Only return transactions on or after this date.
|
283
|
-
# @return [Array<(
|
283
|
+
# @return [Array<(HybridTransactionsResponse, Fixnum, Hash)>] HybridTransactionsResponse data, response status code and response headers
|
284
284
|
def get_transactions_by_category_with_http_info(budget_id, category_id, opts = {})
|
285
285
|
if @api_client.config.debugging
|
286
286
|
@api_client.config.logger.debug "Calling API: TransactionsApi.get_transactions_by_category ..."
|
@@ -317,7 +317,7 @@ module YnabApi
|
|
317
317
|
:form_params => form_params,
|
318
318
|
:body => post_body,
|
319
319
|
:auth_names => auth_names,
|
320
|
-
:return_type => '
|
320
|
+
:return_type => 'HybridTransactionsResponse')
|
321
321
|
if @api_client.config.debugging
|
322
322
|
@api_client.config.logger.debug "API called: TransactionsApi#get_transactions_by_category\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
323
323
|
end
|
@@ -389,7 +389,7 @@ module YnabApi
|
|
389
389
|
# @param payee_id The ID of the Payee.
|
390
390
|
# @param [Hash] opts the optional parameters
|
391
391
|
# @option opts [Date] :since_date Only return transactions on or after this date.
|
392
|
-
# @return [
|
392
|
+
# @return [HybridTransactionsResponse]
|
393
393
|
def get_transactions_by_payee(budget_id, payee_id, opts = {})
|
394
394
|
data, _status_code, _headers = get_transactions_by_payee_with_http_info(budget_id, payee_id, opts)
|
395
395
|
return data
|
@@ -401,7 +401,7 @@ module YnabApi
|
|
401
401
|
# @param payee_id The ID of the Payee.
|
402
402
|
# @param [Hash] opts the optional parameters
|
403
403
|
# @option opts [Date] :since_date Only return transactions on or after this date.
|
404
|
-
# @return [Array<(
|
404
|
+
# @return [Array<(HybridTransactionsResponse, Fixnum, Hash)>] HybridTransactionsResponse data, response status code and response headers
|
405
405
|
def get_transactions_by_payee_with_http_info(budget_id, payee_id, opts = {})
|
406
406
|
if @api_client.config.debugging
|
407
407
|
@api_client.config.logger.debug "Calling API: TransactionsApi.get_transactions_by_payee ..."
|
@@ -438,7 +438,7 @@ module YnabApi
|
|
438
438
|
:form_params => form_params,
|
439
439
|
:body => post_body,
|
440
440
|
:auth_names => auth_names,
|
441
|
-
:return_type => '
|
441
|
+
:return_type => 'HybridTransactionsResponse')
|
442
442
|
if @api_client.config.debugging
|
443
443
|
@api_client.config.logger.debug "API called: TransactionsApi#get_transactions_by_payee\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
444
444
|
end
|
@@ -0,0 +1,439 @@
|
|
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.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module YnabApi
|
16
|
+
|
17
|
+
class HybridTransaction
|
18
|
+
attr_accessor :id
|
19
|
+
|
20
|
+
attr_accessor :date
|
21
|
+
|
22
|
+
# The transaction amount in milliunits format
|
23
|
+
attr_accessor :amount
|
24
|
+
|
25
|
+
attr_accessor :memo
|
26
|
+
|
27
|
+
# The cleared status of the transaction
|
28
|
+
attr_accessor :cleared
|
29
|
+
|
30
|
+
# Whether or not the transaction is approved
|
31
|
+
attr_accessor :approved
|
32
|
+
|
33
|
+
# The transaction flag
|
34
|
+
attr_accessor :flag_color
|
35
|
+
|
36
|
+
attr_accessor :account_id
|
37
|
+
|
38
|
+
attr_accessor :payee_id
|
39
|
+
|
40
|
+
attr_accessor :category_id
|
41
|
+
|
42
|
+
attr_accessor :transfer_account_id
|
43
|
+
|
44
|
+
# If the Transaction was imported, this field is a unique (by account) import identifier. If this transaction was imported through File Based Import or Direct Import and not through the API, the import_id will have the format: 'YNAB:[milliunit_amount]:[iso_date]:[occurrence]'. For example, a transaction dated 2015-12-30 in the amount of -$294.23 USD would have an import_id of 'YNAB:-294230:2015-12-30:1'. If a second transaction on the same account was imported and had the same date and same amount, its import_id would be 'YNAB:-294230:2015-12-30:2'.
|
45
|
+
attr_accessor :import_id
|
46
|
+
|
47
|
+
# Whether the hybrid transaction represents a regular transaction or a subtransaction
|
48
|
+
attr_accessor :type
|
49
|
+
|
50
|
+
# For subtransaction types, this is the id of the pararent transaction. For transaction types, this id will be always be null.
|
51
|
+
attr_accessor :parent_transaction_id
|
52
|
+
|
53
|
+
class EnumAttributeValidator
|
54
|
+
attr_reader :datatype
|
55
|
+
attr_reader :allowable_values
|
56
|
+
|
57
|
+
def initialize(datatype, allowable_values)
|
58
|
+
@allowable_values = allowable_values.map do |value|
|
59
|
+
case datatype.to_s
|
60
|
+
when /Integer/i
|
61
|
+
value.to_i
|
62
|
+
when /Float/i
|
63
|
+
value.to_f
|
64
|
+
else
|
65
|
+
value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def valid?(value)
|
71
|
+
!value || allowable_values.include?(value)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
76
|
+
def self.attribute_map
|
77
|
+
{
|
78
|
+
:'id' => :'id',
|
79
|
+
:'date' => :'date',
|
80
|
+
:'amount' => :'amount',
|
81
|
+
:'memo' => :'memo',
|
82
|
+
:'cleared' => :'cleared',
|
83
|
+
:'approved' => :'approved',
|
84
|
+
:'flag_color' => :'flag_color',
|
85
|
+
:'account_id' => :'account_id',
|
86
|
+
:'payee_id' => :'payee_id',
|
87
|
+
:'category_id' => :'category_id',
|
88
|
+
:'transfer_account_id' => :'transfer_account_id',
|
89
|
+
:'import_id' => :'import_id',
|
90
|
+
:'type' => :'type',
|
91
|
+
:'parent_transaction_id' => :'parent_transaction_id'
|
92
|
+
}
|
93
|
+
end
|
94
|
+
|
95
|
+
# Attribute type mapping.
|
96
|
+
def self.swagger_types
|
97
|
+
{
|
98
|
+
:'id' => :'String',
|
99
|
+
:'date' => :'Date',
|
100
|
+
:'amount' => :'Float',
|
101
|
+
:'memo' => :'String',
|
102
|
+
:'cleared' => :'String',
|
103
|
+
:'approved' => :'BOOLEAN',
|
104
|
+
:'flag_color' => :'String',
|
105
|
+
:'account_id' => :'String',
|
106
|
+
:'payee_id' => :'String',
|
107
|
+
:'category_id' => :'String',
|
108
|
+
:'transfer_account_id' => :'String',
|
109
|
+
:'import_id' => :'String',
|
110
|
+
:'type' => :'String',
|
111
|
+
:'parent_transaction_id' => :'String'
|
112
|
+
}
|
113
|
+
end
|
114
|
+
|
115
|
+
# Initializes the object
|
116
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
117
|
+
def initialize(attributes = {})
|
118
|
+
return unless attributes.is_a?(Hash)
|
119
|
+
|
120
|
+
# convert string to symbol for hash key
|
121
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
122
|
+
|
123
|
+
if attributes.has_key?(:'id')
|
124
|
+
self.id = attributes[:'id']
|
125
|
+
end
|
126
|
+
|
127
|
+
if attributes.has_key?(:'date')
|
128
|
+
self.date = attributes[:'date']
|
129
|
+
end
|
130
|
+
|
131
|
+
if attributes.has_key?(:'amount')
|
132
|
+
self.amount = attributes[:'amount']
|
133
|
+
end
|
134
|
+
|
135
|
+
if attributes.has_key?(:'memo')
|
136
|
+
self.memo = attributes[:'memo']
|
137
|
+
end
|
138
|
+
|
139
|
+
if attributes.has_key?(:'cleared')
|
140
|
+
self.cleared = attributes[:'cleared']
|
141
|
+
end
|
142
|
+
|
143
|
+
if attributes.has_key?(:'approved')
|
144
|
+
self.approved = attributes[:'approved']
|
145
|
+
end
|
146
|
+
|
147
|
+
if attributes.has_key?(:'flag_color')
|
148
|
+
self.flag_color = attributes[:'flag_color']
|
149
|
+
end
|
150
|
+
|
151
|
+
if attributes.has_key?(:'account_id')
|
152
|
+
self.account_id = attributes[:'account_id']
|
153
|
+
end
|
154
|
+
|
155
|
+
if attributes.has_key?(:'payee_id')
|
156
|
+
self.payee_id = attributes[:'payee_id']
|
157
|
+
end
|
158
|
+
|
159
|
+
if attributes.has_key?(:'category_id')
|
160
|
+
self.category_id = attributes[:'category_id']
|
161
|
+
end
|
162
|
+
|
163
|
+
if attributes.has_key?(:'transfer_account_id')
|
164
|
+
self.transfer_account_id = attributes[:'transfer_account_id']
|
165
|
+
end
|
166
|
+
|
167
|
+
if attributes.has_key?(:'import_id')
|
168
|
+
self.import_id = attributes[:'import_id']
|
169
|
+
end
|
170
|
+
|
171
|
+
if attributes.has_key?(:'type')
|
172
|
+
self.type = attributes[:'type']
|
173
|
+
end
|
174
|
+
|
175
|
+
if attributes.has_key?(:'parent_transaction_id')
|
176
|
+
self.parent_transaction_id = attributes[:'parent_transaction_id']
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
182
|
+
# @return Array for valid properties with the reasons
|
183
|
+
def list_invalid_properties
|
184
|
+
invalid_properties = Array.new
|
185
|
+
if @id.nil?
|
186
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
187
|
+
end
|
188
|
+
|
189
|
+
if @date.nil?
|
190
|
+
invalid_properties.push("invalid value for 'date', date cannot be nil.")
|
191
|
+
end
|
192
|
+
|
193
|
+
if @amount.nil?
|
194
|
+
invalid_properties.push("invalid value for 'amount', amount cannot be nil.")
|
195
|
+
end
|
196
|
+
|
197
|
+
if @memo.nil?
|
198
|
+
invalid_properties.push("invalid value for 'memo', memo cannot be nil.")
|
199
|
+
end
|
200
|
+
|
201
|
+
if @cleared.nil?
|
202
|
+
invalid_properties.push("invalid value for 'cleared', cleared cannot be nil.")
|
203
|
+
end
|
204
|
+
|
205
|
+
if @approved.nil?
|
206
|
+
invalid_properties.push("invalid value for 'approved', approved cannot be nil.")
|
207
|
+
end
|
208
|
+
|
209
|
+
if @flag_color.nil?
|
210
|
+
invalid_properties.push("invalid value for 'flag_color', flag_color cannot be nil.")
|
211
|
+
end
|
212
|
+
|
213
|
+
if @account_id.nil?
|
214
|
+
invalid_properties.push("invalid value for 'account_id', account_id cannot be nil.")
|
215
|
+
end
|
216
|
+
|
217
|
+
if @payee_id.nil?
|
218
|
+
invalid_properties.push("invalid value for 'payee_id', payee_id cannot be nil.")
|
219
|
+
end
|
220
|
+
|
221
|
+
if @category_id.nil?
|
222
|
+
invalid_properties.push("invalid value for 'category_id', category_id cannot be nil.")
|
223
|
+
end
|
224
|
+
|
225
|
+
if @transfer_account_id.nil?
|
226
|
+
invalid_properties.push("invalid value for 'transfer_account_id', transfer_account_id cannot be nil.")
|
227
|
+
end
|
228
|
+
|
229
|
+
if @import_id.nil?
|
230
|
+
invalid_properties.push("invalid value for 'import_id', import_id cannot be nil.")
|
231
|
+
end
|
232
|
+
|
233
|
+
if @type.nil?
|
234
|
+
invalid_properties.push("invalid value for 'type', type cannot be nil.")
|
235
|
+
end
|
236
|
+
|
237
|
+
if @parent_transaction_id.nil?
|
238
|
+
invalid_properties.push("invalid value for 'parent_transaction_id', parent_transaction_id cannot be nil.")
|
239
|
+
end
|
240
|
+
|
241
|
+
return invalid_properties
|
242
|
+
end
|
243
|
+
|
244
|
+
# Check to see if the all the properties in the model are valid
|
245
|
+
# @return true if the model is valid
|
246
|
+
def valid?
|
247
|
+
return false if @id.nil?
|
248
|
+
return false if @date.nil?
|
249
|
+
return false if @amount.nil?
|
250
|
+
return false if @memo.nil?
|
251
|
+
return false if @cleared.nil?
|
252
|
+
cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
|
253
|
+
return false unless cleared_validator.valid?(@cleared)
|
254
|
+
return false if @approved.nil?
|
255
|
+
return false if @flag_color.nil?
|
256
|
+
flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
|
257
|
+
return false unless flag_color_validator.valid?(@flag_color)
|
258
|
+
return false if @account_id.nil?
|
259
|
+
return false if @payee_id.nil?
|
260
|
+
return false if @category_id.nil?
|
261
|
+
return false if @transfer_account_id.nil?
|
262
|
+
return false if @import_id.nil?
|
263
|
+
return false if @type.nil?
|
264
|
+
type_validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
|
265
|
+
return false unless type_validator.valid?(@type)
|
266
|
+
return false if @parent_transaction_id.nil?
|
267
|
+
return true
|
268
|
+
end
|
269
|
+
|
270
|
+
# Custom attribute writer method checking allowed values (enum).
|
271
|
+
# @param [Object] cleared Object to be assigned
|
272
|
+
def cleared=(cleared)
|
273
|
+
validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
|
274
|
+
unless validator.valid?(cleared)
|
275
|
+
fail ArgumentError, "invalid value for 'cleared', must be one of #{validator.allowable_values}."
|
276
|
+
end
|
277
|
+
@cleared = cleared
|
278
|
+
end
|
279
|
+
|
280
|
+
# Custom attribute writer method checking allowed values (enum).
|
281
|
+
# @param [Object] flag_color Object to be assigned
|
282
|
+
def flag_color=(flag_color)
|
283
|
+
validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
|
284
|
+
unless validator.valid?(flag_color)
|
285
|
+
fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
|
286
|
+
end
|
287
|
+
@flag_color = flag_color
|
288
|
+
end
|
289
|
+
|
290
|
+
# Custom attribute writer method checking allowed values (enum).
|
291
|
+
# @param [Object] type Object to be assigned
|
292
|
+
def type=(type)
|
293
|
+
validator = EnumAttributeValidator.new('String', ["transaction", "subtransaction"])
|
294
|
+
unless validator.valid?(type)
|
295
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
296
|
+
end
|
297
|
+
@type = type
|
298
|
+
end
|
299
|
+
|
300
|
+
# Checks equality by comparing each attribute.
|
301
|
+
# @param [Object] Object to be compared
|
302
|
+
def ==(o)
|
303
|
+
return true if self.equal?(o)
|
304
|
+
self.class == o.class &&
|
305
|
+
id == o.id &&
|
306
|
+
date == o.date &&
|
307
|
+
amount == o.amount &&
|
308
|
+
memo == o.memo &&
|
309
|
+
cleared == o.cleared &&
|
310
|
+
approved == o.approved &&
|
311
|
+
flag_color == o.flag_color &&
|
312
|
+
account_id == o.account_id &&
|
313
|
+
payee_id == o.payee_id &&
|
314
|
+
category_id == o.category_id &&
|
315
|
+
transfer_account_id == o.transfer_account_id &&
|
316
|
+
import_id == o.import_id &&
|
317
|
+
type == o.type &&
|
318
|
+
parent_transaction_id == o.parent_transaction_id
|
319
|
+
end
|
320
|
+
|
321
|
+
# @see the `==` method
|
322
|
+
# @param [Object] Object to be compared
|
323
|
+
def eql?(o)
|
324
|
+
self == o
|
325
|
+
end
|
326
|
+
|
327
|
+
# Calculates hash code according to all attributes.
|
328
|
+
# @return [Fixnum] Hash code
|
329
|
+
def hash
|
330
|
+
[id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, import_id, type, parent_transaction_id].hash
|
331
|
+
end
|
332
|
+
|
333
|
+
# Builds the object from hash
|
334
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
335
|
+
# @return [Object] Returns the model itself
|
336
|
+
def build_from_hash(attributes)
|
337
|
+
return nil unless attributes.is_a?(Hash)
|
338
|
+
self.class.swagger_types.each_pair do |key, type|
|
339
|
+
if type =~ /\AArray<(.*)>/i
|
340
|
+
# check to ensure the input is an array given that the the attribute
|
341
|
+
# is documented as an array but the input is not
|
342
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
343
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
344
|
+
end
|
345
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
346
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
347
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
348
|
+
end
|
349
|
+
|
350
|
+
self
|
351
|
+
end
|
352
|
+
|
353
|
+
# Deserializes the data based on type
|
354
|
+
# @param string type Data type
|
355
|
+
# @param string value Value to be deserialized
|
356
|
+
# @return [Object] Deserialized data
|
357
|
+
def _deserialize(type, value)
|
358
|
+
case type.to_sym
|
359
|
+
when :DateTime
|
360
|
+
DateTime.parse(value)
|
361
|
+
when :Date
|
362
|
+
Date.parse(value)
|
363
|
+
when :String
|
364
|
+
value.to_s
|
365
|
+
when :Integer
|
366
|
+
value.to_i
|
367
|
+
when :Float
|
368
|
+
value.to_f
|
369
|
+
when :BOOLEAN
|
370
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
371
|
+
true
|
372
|
+
else
|
373
|
+
false
|
374
|
+
end
|
375
|
+
when :Object
|
376
|
+
# generic object (usually a Hash), return directly
|
377
|
+
value
|
378
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
379
|
+
inner_type = Regexp.last_match[:inner_type]
|
380
|
+
value.map { |v| _deserialize(inner_type, v) }
|
381
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
382
|
+
k_type = Regexp.last_match[:k_type]
|
383
|
+
v_type = Regexp.last_match[:v_type]
|
384
|
+
{}.tap do |hash|
|
385
|
+
value.each do |k, v|
|
386
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
else # model
|
390
|
+
temp_model = YnabApi.const_get(type).new
|
391
|
+
temp_model.build_from_hash(value)
|
392
|
+
end
|
393
|
+
end
|
394
|
+
|
395
|
+
# Returns the string representation of the object
|
396
|
+
# @return [String] String presentation of the object
|
397
|
+
def to_s
|
398
|
+
to_hash.to_s
|
399
|
+
end
|
400
|
+
|
401
|
+
# to_body is an alias to to_hash (backward compatibility)
|
402
|
+
# @return [Hash] Returns the object in the form of hash
|
403
|
+
def to_body
|
404
|
+
to_hash
|
405
|
+
end
|
406
|
+
|
407
|
+
# Returns the object in the form of hash
|
408
|
+
# @return [Hash] Returns the object in the form of hash
|
409
|
+
def to_hash
|
410
|
+
hash = {}
|
411
|
+
self.class.attribute_map.each_pair do |attr, param|
|
412
|
+
value = self.send(attr)
|
413
|
+
next if value.nil?
|
414
|
+
hash[param] = _to_hash(value)
|
415
|
+
end
|
416
|
+
hash
|
417
|
+
end
|
418
|
+
|
419
|
+
# Outputs non-array value in the form of hash
|
420
|
+
# For object, use to_hash. Otherwise, just return the value
|
421
|
+
# @param [Object] value Any valid value
|
422
|
+
# @return [Hash] Returns the value in the form of hash
|
423
|
+
def _to_hash(value)
|
424
|
+
if value.is_a?(Array)
|
425
|
+
value.compact.map{ |v| _to_hash(v) }
|
426
|
+
elsif value.is_a?(Hash)
|
427
|
+
{}.tap do |hash|
|
428
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
429
|
+
end
|
430
|
+
elsif value.respond_to? :to_hash
|
431
|
+
value.to_hash
|
432
|
+
else
|
433
|
+
value
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
end
|
438
|
+
|
439
|
+
end
|