ynab 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (194) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +44 -0
  4. data/LICENSE.md +201 -0
  5. data/README.md +57 -0
  6. data/Rakefile +31 -0
  7. data/config.json +10 -0
  8. data/docs/Account.md +16 -0
  9. data/docs/AccountResponse.md +8 -0
  10. data/docs/AccountWrapper.md +8 -0
  11. data/docs/AccountsApi.md +121 -0
  12. data/docs/AccountsResponse.md +8 -0
  13. data/docs/AccountsWrapper.md +8 -0
  14. data/docs/BudgetDetail.md +22 -0
  15. data/docs/BudgetDetailResponse.md +8 -0
  16. data/docs/BudgetDetailWrapper.md +9 -0
  17. data/docs/BudgetSummary.md +12 -0
  18. data/docs/BudgetSummaryResponse.md +8 -0
  19. data/docs/BudgetSummaryWrapper.md +8 -0
  20. data/docs/BudgetsApi.md +116 -0
  21. data/docs/BulkIdWrapper.md +8 -0
  22. data/docs/BulkIds.md +9 -0
  23. data/docs/BulkResponse.md +8 -0
  24. data/docs/BulkTransactionCreateResponse.md +8 -0
  25. data/docs/BulkTransactionIds.md +8 -0
  26. data/docs/BulkTransactions.md +8 -0
  27. data/docs/CategoriesApi.md +121 -0
  28. data/docs/CategoriesResponse.md +8 -0
  29. data/docs/Category.md +15 -0
  30. data/docs/CategoryGroup.md +10 -0
  31. data/docs/CategoryGroupWithCategories.md +11 -0
  32. data/docs/CategoryGroupsWrapper.md +8 -0
  33. data/docs/CategoryResponse.md +8 -0
  34. data/docs/CategoryWrapper.md +8 -0
  35. data/docs/CurrencyFormat.md +8 -0
  36. data/docs/DateFormat.md +8 -0
  37. data/docs/ErrorDetail.md +10 -0
  38. data/docs/ErrorResponse.md +8 -0
  39. data/docs/MonthDetail.md +12 -0
  40. data/docs/MonthDetailResponse.md +8 -0
  41. data/docs/MonthDetailWrapper.md +8 -0
  42. data/docs/MonthSummariesResponse.md +8 -0
  43. data/docs/MonthSummariesWrapper.md +8 -0
  44. data/docs/MonthSummary.md +11 -0
  45. data/docs/MonthsApi.md +121 -0
  46. data/docs/Payee.md +10 -0
  47. data/docs/PayeeLocation.md +11 -0
  48. data/docs/PayeeLocationResponse.md +8 -0
  49. data/docs/PayeeLocationWrapper.md +8 -0
  50. data/docs/PayeeLocationsApi.md +179 -0
  51. data/docs/PayeeLocationsResponse.md +8 -0
  52. data/docs/PayeeLocationsWrapper.md +8 -0
  53. data/docs/PayeeResponse.md +8 -0
  54. data/docs/PayeeWrapper.md +8 -0
  55. data/docs/PayeesApi.md +121 -0
  56. data/docs/PayeesResponse.md +8 -0
  57. data/docs/PayeesWrapper.md +8 -0
  58. data/docs/SaveTransaction.md +18 -0
  59. data/docs/SaveTransactionWrapper.md +8 -0
  60. data/docs/ScheduledSubTransaction.md +14 -0
  61. data/docs/ScheduledTransactionDetail.md +19 -0
  62. data/docs/ScheduledTransactionResponse.md +8 -0
  63. data/docs/ScheduledTransactionSummary.md +18 -0
  64. data/docs/ScheduledTransactionWrapper.md +8 -0
  65. data/docs/ScheduledTransactionsApi.md +121 -0
  66. data/docs/ScheduledTransactionsResponse.md +8 -0
  67. data/docs/ScheduledTransactionsWrapper.md +8 -0
  68. data/docs/SubTransaction.md +14 -0
  69. data/docs/TransactionDetail.md +20 -0
  70. data/docs/TransactionResponse.md +8 -0
  71. data/docs/TransactionSummary.md +19 -0
  72. data/docs/TransactionWrapper.md +8 -0
  73. data/docs/TransactionsApi.md +428 -0
  74. data/docs/TransactionsResponse.md +8 -0
  75. data/docs/TransactionsWrapper.md +8 -0
  76. data/examples/budget-list.rb +25 -0
  77. data/examples/budget-month.rb +36 -0
  78. data/examples/category-balance.rb +27 -0
  79. data/lib/ynab.rb +136 -0
  80. data/lib/ynab/api/accounts_api.rb +135 -0
  81. data/lib/ynab/api/budgets_api.rb +126 -0
  82. data/lib/ynab/api/categories_api.rb +135 -0
  83. data/lib/ynab/api/months_api.rb +135 -0
  84. data/lib/ynab/api/payee_locations_api.rb +194 -0
  85. data/lib/ynab/api/payees_api.rb +135 -0
  86. data/lib/ynab/api/scheduled_transactions_api.rb +135 -0
  87. data/lib/ynab/api/transactions_api.rb +451 -0
  88. data/lib/ynab/api_client.rb +392 -0
  89. data/lib/ynab/api_error.rb +38 -0
  90. data/lib/ynab/configuration.rb +209 -0
  91. data/lib/ynab/models/account.rb +343 -0
  92. data/lib/ynab/models/account_response.rb +193 -0
  93. data/lib/ynab/models/account_wrapper.rb +193 -0
  94. data/lib/ynab/models/accounts_response.rb +193 -0
  95. data/lib/ynab/models/accounts_wrapper.rb +195 -0
  96. data/lib/ynab/models/budget_detail.rb +345 -0
  97. data/lib/ynab/models/budget_detail_response.rb +193 -0
  98. data/lib/ynab/models/budget_detail_wrapper.rb +208 -0
  99. data/lib/ynab/models/budget_summary.rb +235 -0
  100. data/lib/ynab/models/budget_summary_response.rb +193 -0
  101. data/lib/ynab/models/budget_summary_wrapper.rb +195 -0
  102. data/lib/ynab/models/bulk_id_wrapper.rb +193 -0
  103. data/lib/ynab/models/bulk_ids.rb +213 -0
  104. data/lib/ynab/models/bulk_response.rb +193 -0
  105. data/lib/ynab/models/bulk_transaction_create_response.rb +193 -0
  106. data/lib/ynab/models/bulk_transaction_ids.rb +195 -0
  107. data/lib/ynab/models/bulk_transactions.rb +195 -0
  108. data/lib/ynab/models/categories_response.rb +193 -0
  109. data/lib/ynab/models/category.rb +295 -0
  110. data/lib/ynab/models/category_group.rb +222 -0
  111. data/lib/ynab/models/category_group_with_categories.rb +239 -0
  112. data/lib/ynab/models/category_groups_wrapper.rb +195 -0
  113. data/lib/ynab/models/category_response.rb +193 -0
  114. data/lib/ynab/models/category_wrapper.rb +193 -0
  115. data/lib/ynab/models/currency_format.rb +193 -0
  116. data/lib/ynab/models/date_format.rb +193 -0
  117. data/lib/ynab/models/error_detail.rb +221 -0
  118. data/lib/ynab/models/error_response.rb +193 -0
  119. data/lib/ynab/models/month_detail.rb +253 -0
  120. data/lib/ynab/models/month_detail_response.rb +193 -0
  121. data/lib/ynab/models/month_detail_wrapper.rb +193 -0
  122. data/lib/ynab/models/month_summaries_response.rb +193 -0
  123. data/lib/ynab/models/month_summaries_wrapper.rb +195 -0
  124. data/lib/ynab/models/month_summary.rb +236 -0
  125. data/lib/ynab/models/payee.rb +222 -0
  126. data/lib/ynab/models/payee_location.rb +235 -0
  127. data/lib/ynab/models/payee_location_response.rb +193 -0
  128. data/lib/ynab/models/payee_location_wrapper.rb +193 -0
  129. data/lib/ynab/models/payee_locations_response.rb +193 -0
  130. data/lib/ynab/models/payee_locations_wrapper.rb +195 -0
  131. data/lib/ynab/models/payee_response.rb +193 -0
  132. data/lib/ynab/models/payee_wrapper.rb +193 -0
  133. data/lib/ynab/models/payees_response.rb +193 -0
  134. data/lib/ynab/models/payees_wrapper.rb +195 -0
  135. data/lib/ynab/models/save_transaction.rb +346 -0
  136. data/lib/ynab/models/save_transaction_wrapper.rb +193 -0
  137. data/lib/ynab/models/scheduled_sub_transaction.rb +279 -0
  138. data/lib/ynab/models/scheduled_transaction_detail.rb +387 -0
  139. data/lib/ynab/models/scheduled_transaction_response.rb +193 -0
  140. data/lib/ynab/models/scheduled_transaction_summary.rb +370 -0
  141. data/lib/ynab/models/scheduled_transaction_wrapper.rb +193 -0
  142. data/lib/ynab/models/scheduled_transactions_response.rb +193 -0
  143. data/lib/ynab/models/scheduled_transactions_wrapper.rb +195 -0
  144. data/lib/ynab/models/sub_transaction.rb +279 -0
  145. data/lib/ynab/models/transaction_detail.rb +401 -0
  146. data/lib/ynab/models/transaction_response.rb +193 -0
  147. data/lib/ynab/models/transaction_summary.rb +384 -0
  148. data/lib/ynab/models/transaction_wrapper.rb +193 -0
  149. data/lib/ynab/models/transactions_response.rb +193 -0
  150. data/lib/ynab/models/transactions_wrapper.rb +195 -0
  151. data/lib/ynab/version.rb +15 -0
  152. data/pkg/ynab-0.1.0.gem +0 -0
  153. data/spec-v1-swagger.json +2121 -0
  154. data/spec/api/accounts_spec.rb +56 -0
  155. data/spec/api/budgets_spec.rb +55 -0
  156. data/spec/api/categories_spec.rb +57 -0
  157. data/spec/api/months_spec.rb +57 -0
  158. data/spec/api/payee_locations_spec.rb +57 -0
  159. data/spec/api/payees_spec.rb +56 -0
  160. data/spec/api/scheduled_transactions_spec.rb +56 -0
  161. data/spec/api/transactions_spec.rb +122 -0
  162. data/spec/fixtures/.DS_Store +0 -0
  163. data/spec/fixtures/vcr_cassettes/account.yml +46 -0
  164. data/spec/fixtures/vcr_cassettes/accounts.yml +46 -0
  165. data/spec/fixtures/vcr_cassettes/accounts_unauthorized.yml +49 -0
  166. data/spec/fixtures/vcr_cassettes/budget.yml +1413 -0
  167. data/spec/fixtures/vcr_cassettes/budgets.yml +49 -0
  168. data/spec/fixtures/vcr_cassettes/budgets_unauthorized.yml +49 -0
  169. data/spec/fixtures/vcr_cassettes/bulk_transactions.yml +46 -0
  170. data/spec/fixtures/vcr_cassettes/categories.yml +67 -0
  171. data/spec/fixtures/vcr_cassettes/categories_unauthorized.yml +49 -0
  172. data/spec/fixtures/vcr_cassettes/category.yml +46 -0
  173. data/spec/fixtures/vcr_cassettes/create_transaction.yml +46 -0
  174. data/spec/fixtures/vcr_cassettes/month.yml +59 -0
  175. data/spec/fixtures/vcr_cassettes/months.yml +47 -0
  176. data/spec/fixtures/vcr_cassettes/months_unauthorized.yml +49 -0
  177. data/spec/fixtures/vcr_cassettes/payee.yml +47 -0
  178. data/spec/fixtures/vcr_cassettes/payee_location.yml +46 -0
  179. data/spec/fixtures/vcr_cassettes/payee_locations.yml +46 -0
  180. data/spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml +49 -0
  181. data/spec/fixtures/vcr_cassettes/payees.yml +51 -0
  182. data/spec/fixtures/vcr_cassettes/payees_unauthorized.yml +49 -0
  183. data/spec/fixtures/vcr_cassettes/scheduled_transaction.yml +46 -0
  184. data/spec/fixtures/vcr_cassettes/scheduled_transactions.yml +46 -0
  185. data/spec/fixtures/vcr_cassettes/scheduled_transactions_unauthorized.yml +49 -0
  186. data/spec/fixtures/vcr_cassettes/transaction.yml +46 -0
  187. data/spec/fixtures/vcr_cassettes/transactions.yml +46 -0
  188. data/spec/fixtures/vcr_cassettes/transactions_unauthorized.yml +49 -0
  189. data/spec/fixtures/vcr_cassettes/update_transaction.yml +46 -0
  190. data/spec/spec_helper.rb +18 -0
  191. data/swagger-templates/api_client.mustache +386 -0
  192. data/swagger-templates/gemspec.mustache +37 -0
  193. data/ynab.gemspec +40 -0
  194. metadata +353 -0
@@ -0,0 +1,193 @@
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 TransactionResponse
18
+ attr_accessor :data
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'data' => :'data'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'data' => :'TransactionWrapper'
32
+ }
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ return unless attributes.is_a?(Hash)
39
+
40
+ # convert string to symbol for hash key
41
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
42
+
43
+ if attributes.has_key?(:'data')
44
+ self.data = attributes[:'data']
45
+ end
46
+
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 @data.nil?
54
+ invalid_properties.push("invalid value for 'data', data cannot be nil.")
55
+ end
56
+
57
+ return 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 @data.nil?
64
+ return 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
+ data == o.data
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
+ [data].hash
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.swagger_types.each_pair do |key, type|
93
+ if type =~ /\AArray<(.*)>/i
94
+ # check to ensure the input is an array given that the the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
97
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+
104
+ self
105
+ end
106
+
107
+ # Deserializes the data based on type
108
+ # @param string type Data type
109
+ # @param string value Value to be deserialized
110
+ # @return [Object] Deserialized data
111
+ def _deserialize(type, value)
112
+ case type.to_sym
113
+ when :DateTime
114
+ DateTime.parse(value)
115
+ when :Date
116
+ Date.parse(value)
117
+ when :String
118
+ value.to_s
119
+ when :Integer
120
+ value.to_i
121
+ when :Float
122
+ value.to_f
123
+ when :BOOLEAN
124
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
+ true
126
+ else
127
+ false
128
+ end
129
+ when :Object
130
+ # generic object (usually a Hash), return directly
131
+ value
132
+ when /\AArray<(?<inner_type>.+)>\z/
133
+ inner_type = Regexp.last_match[:inner_type]
134
+ value.map { |v| _deserialize(inner_type, v) }
135
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
136
+ k_type = Regexp.last_match[:k_type]
137
+ v_type = Regexp.last_match[:v_type]
138
+ {}.tap do |hash|
139
+ value.each do |k, v|
140
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
141
+ end
142
+ end
143
+ else # model
144
+ temp_model = YnabApi.const_get(type).new
145
+ temp_model.build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ next if value.nil?
168
+ hash[param] = _to_hash(value)
169
+ end
170
+ hash
171
+ end
172
+
173
+ # Outputs non-array value in the form of hash
174
+ # For object, use to_hash. Otherwise, just return the value
175
+ # @param [Object] value Any valid value
176
+ # @return [Hash] Returns the value in the form of hash
177
+ def _to_hash(value)
178
+ if value.is_a?(Array)
179
+ value.compact.map{ |v| _to_hash(v) }
180
+ elsif value.is_a?(Hash)
181
+ {}.tap do |hash|
182
+ value.each { |k, v| hash[k] = _to_hash(v) }
183
+ end
184
+ elsif value.respond_to? :to_hash
185
+ value.to_hash
186
+ else
187
+ value
188
+ end
189
+ end
190
+
191
+ end
192
+
193
+ end
@@ -0,0 +1,384 @@
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 TransactionSummary
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
+ attr_accessor :flag_color
34
+
35
+ attr_accessor :account_id
36
+
37
+ attr_accessor :payee_id
38
+
39
+ attr_accessor :category_id
40
+
41
+ attr_accessor :transfer_account_id
42
+
43
+ # 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]:[occurance]'. 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'.
44
+ attr_accessor :import_id
45
+
46
+ class EnumAttributeValidator
47
+ attr_reader :datatype
48
+ attr_reader :allowable_values
49
+
50
+ def initialize(datatype, allowable_values)
51
+ @allowable_values = allowable_values.map do |value|
52
+ case datatype.to_s
53
+ when /Integer/i
54
+ value.to_i
55
+ when /Float/i
56
+ value.to_f
57
+ else
58
+ value
59
+ end
60
+ end
61
+ end
62
+
63
+ def valid?(value)
64
+ !value || allowable_values.include?(value)
65
+ end
66
+ end
67
+
68
+ # Attribute mapping from ruby-style variable name to JSON key.
69
+ def self.attribute_map
70
+ {
71
+ :'id' => :'id',
72
+ :'date' => :'date',
73
+ :'amount' => :'amount',
74
+ :'memo' => :'memo',
75
+ :'cleared' => :'cleared',
76
+ :'approved' => :'approved',
77
+ :'flag_color' => :'flag_color',
78
+ :'account_id' => :'account_id',
79
+ :'payee_id' => :'payee_id',
80
+ :'category_id' => :'category_id',
81
+ :'transfer_account_id' => :'transfer_account_id',
82
+ :'import_id' => :'import_id'
83
+ }
84
+ end
85
+
86
+ # Attribute type mapping.
87
+ def self.swagger_types
88
+ {
89
+ :'id' => :'String',
90
+ :'date' => :'Date',
91
+ :'amount' => :'Float',
92
+ :'memo' => :'String',
93
+ :'cleared' => :'String',
94
+ :'approved' => :'BOOLEAN',
95
+ :'flag_color' => :'String',
96
+ :'account_id' => :'String',
97
+ :'payee_id' => :'String',
98
+ :'category_id' => :'String',
99
+ :'transfer_account_id' => :'String',
100
+ :'import_id' => :'String'
101
+ }
102
+ end
103
+
104
+ # Initializes the object
105
+ # @param [Hash] attributes Model attributes in the form of hash
106
+ def initialize(attributes = {})
107
+ return unless attributes.is_a?(Hash)
108
+
109
+ # convert string to symbol for hash key
110
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
111
+
112
+ if attributes.has_key?(:'id')
113
+ self.id = attributes[:'id']
114
+ end
115
+
116
+ if attributes.has_key?(:'date')
117
+ self.date = attributes[:'date']
118
+ end
119
+
120
+ if attributes.has_key?(:'amount')
121
+ self.amount = attributes[:'amount']
122
+ end
123
+
124
+ if attributes.has_key?(:'memo')
125
+ self.memo = attributes[:'memo']
126
+ end
127
+
128
+ if attributes.has_key?(:'cleared')
129
+ self.cleared = attributes[:'cleared']
130
+ end
131
+
132
+ if attributes.has_key?(:'approved')
133
+ self.approved = attributes[:'approved']
134
+ end
135
+
136
+ if attributes.has_key?(:'flag_color')
137
+ self.flag_color = attributes[:'flag_color']
138
+ end
139
+
140
+ if attributes.has_key?(:'account_id')
141
+ self.account_id = attributes[:'account_id']
142
+ end
143
+
144
+ if attributes.has_key?(:'payee_id')
145
+ self.payee_id = attributes[:'payee_id']
146
+ end
147
+
148
+ if attributes.has_key?(:'category_id')
149
+ self.category_id = attributes[:'category_id']
150
+ end
151
+
152
+ if attributes.has_key?(:'transfer_account_id')
153
+ self.transfer_account_id = attributes[:'transfer_account_id']
154
+ end
155
+
156
+ if attributes.has_key?(:'import_id')
157
+ self.import_id = attributes[:'import_id']
158
+ end
159
+
160
+ end
161
+
162
+ # Show invalid properties with the reasons. Usually used together with valid?
163
+ # @return Array for valid properties with the reasons
164
+ def list_invalid_properties
165
+ invalid_properties = Array.new
166
+ if @id.nil?
167
+ invalid_properties.push("invalid value for 'id', id cannot be nil.")
168
+ end
169
+
170
+ if @date.nil?
171
+ invalid_properties.push("invalid value for 'date', date cannot be nil.")
172
+ end
173
+
174
+ if @amount.nil?
175
+ invalid_properties.push("invalid value for 'amount', amount cannot be nil.")
176
+ end
177
+
178
+ if @memo.nil?
179
+ invalid_properties.push("invalid value for 'memo', memo cannot be nil.")
180
+ end
181
+
182
+ if @cleared.nil?
183
+ invalid_properties.push("invalid value for 'cleared', cleared cannot be nil.")
184
+ end
185
+
186
+ if @approved.nil?
187
+ invalid_properties.push("invalid value for 'approved', approved cannot be nil.")
188
+ end
189
+
190
+ if @flag_color.nil?
191
+ invalid_properties.push("invalid value for 'flag_color', flag_color cannot be nil.")
192
+ end
193
+
194
+ if @account_id.nil?
195
+ invalid_properties.push("invalid value for 'account_id', account_id cannot be nil.")
196
+ end
197
+
198
+ if @payee_id.nil?
199
+ invalid_properties.push("invalid value for 'payee_id', payee_id cannot be nil.")
200
+ end
201
+
202
+ if @category_id.nil?
203
+ invalid_properties.push("invalid value for 'category_id', category_id cannot be nil.")
204
+ end
205
+
206
+ if @transfer_account_id.nil?
207
+ invalid_properties.push("invalid value for 'transfer_account_id', transfer_account_id cannot be nil.")
208
+ end
209
+
210
+ if @import_id.nil?
211
+ invalid_properties.push("invalid value for 'import_id', import_id cannot be nil.")
212
+ end
213
+
214
+ return invalid_properties
215
+ end
216
+
217
+ # Check to see if the all the properties in the model are valid
218
+ # @return true if the model is valid
219
+ def valid?
220
+ return false if @id.nil?
221
+ return false if @date.nil?
222
+ return false if @amount.nil?
223
+ return false if @memo.nil?
224
+ return false if @cleared.nil?
225
+ cleared_validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
226
+ return false unless cleared_validator.valid?(@cleared)
227
+ return false if @approved.nil?
228
+ return false if @flag_color.nil?
229
+ return false if @account_id.nil?
230
+ return false if @payee_id.nil?
231
+ return false if @category_id.nil?
232
+ return false if @transfer_account_id.nil?
233
+ return false if @import_id.nil?
234
+ return true
235
+ end
236
+
237
+ # Custom attribute writer method checking allowed values (enum).
238
+ # @param [Object] cleared Object to be assigned
239
+ def cleared=(cleared)
240
+ validator = EnumAttributeValidator.new('String', ["cleared", "uncleared", "reconciled"])
241
+ unless validator.valid?(cleared)
242
+ fail ArgumentError, "invalid value for 'cleared', must be one of #{validator.allowable_values}."
243
+ end
244
+ @cleared = cleared
245
+ end
246
+
247
+ # Checks equality by comparing each attribute.
248
+ # @param [Object] Object to be compared
249
+ def ==(o)
250
+ return true if self.equal?(o)
251
+ self.class == o.class &&
252
+ id == o.id &&
253
+ date == o.date &&
254
+ amount == o.amount &&
255
+ memo == o.memo &&
256
+ cleared == o.cleared &&
257
+ approved == o.approved &&
258
+ flag_color == o.flag_color &&
259
+ account_id == o.account_id &&
260
+ payee_id == o.payee_id &&
261
+ category_id == o.category_id &&
262
+ transfer_account_id == o.transfer_account_id &&
263
+ import_id == o.import_id
264
+ end
265
+
266
+ # @see the `==` method
267
+ # @param [Object] Object to be compared
268
+ def eql?(o)
269
+ self == o
270
+ end
271
+
272
+ # Calculates hash code according to all attributes.
273
+ # @return [Fixnum] Hash code
274
+ def hash
275
+ [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, import_id].hash
276
+ end
277
+
278
+ # Builds the object from hash
279
+ # @param [Hash] attributes Model attributes in the form of hash
280
+ # @return [Object] Returns the model itself
281
+ def build_from_hash(attributes)
282
+ return nil unless attributes.is_a?(Hash)
283
+ self.class.swagger_types.each_pair do |key, type|
284
+ if type =~ /\AArray<(.*)>/i
285
+ # check to ensure the input is an array given that the the attribute
286
+ # is documented as an array but the input is not
287
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
288
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
289
+ end
290
+ elsif !attributes[self.class.attribute_map[key]].nil?
291
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
292
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
293
+ end
294
+
295
+ self
296
+ end
297
+
298
+ # Deserializes the data based on type
299
+ # @param string type Data type
300
+ # @param string value Value to be deserialized
301
+ # @return [Object] Deserialized data
302
+ def _deserialize(type, value)
303
+ case type.to_sym
304
+ when :DateTime
305
+ DateTime.parse(value)
306
+ when :Date
307
+ Date.parse(value)
308
+ when :String
309
+ value.to_s
310
+ when :Integer
311
+ value.to_i
312
+ when :Float
313
+ value.to_f
314
+ when :BOOLEAN
315
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
316
+ true
317
+ else
318
+ false
319
+ end
320
+ when :Object
321
+ # generic object (usually a Hash), return directly
322
+ value
323
+ when /\AArray<(?<inner_type>.+)>\z/
324
+ inner_type = Regexp.last_match[:inner_type]
325
+ value.map { |v| _deserialize(inner_type, v) }
326
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
327
+ k_type = Regexp.last_match[:k_type]
328
+ v_type = Regexp.last_match[:v_type]
329
+ {}.tap do |hash|
330
+ value.each do |k, v|
331
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
332
+ end
333
+ end
334
+ else # model
335
+ temp_model = YnabApi.const_get(type).new
336
+ temp_model.build_from_hash(value)
337
+ end
338
+ end
339
+
340
+ # Returns the string representation of the object
341
+ # @return [String] String presentation of the object
342
+ def to_s
343
+ to_hash.to_s
344
+ end
345
+
346
+ # to_body is an alias to to_hash (backward compatibility)
347
+ # @return [Hash] Returns the object in the form of hash
348
+ def to_body
349
+ to_hash
350
+ end
351
+
352
+ # Returns the object in the form of hash
353
+ # @return [Hash] Returns the object in the form of hash
354
+ def to_hash
355
+ hash = {}
356
+ self.class.attribute_map.each_pair do |attr, param|
357
+ value = self.send(attr)
358
+ next if value.nil?
359
+ hash[param] = _to_hash(value)
360
+ end
361
+ hash
362
+ end
363
+
364
+ # Outputs non-array value in the form of hash
365
+ # For object, use to_hash. Otherwise, just return the value
366
+ # @param [Object] value Any valid value
367
+ # @return [Hash] Returns the value in the form of hash
368
+ def _to_hash(value)
369
+ if value.is_a?(Array)
370
+ value.compact.map{ |v| _to_hash(v) }
371
+ elsif value.is_a?(Hash)
372
+ {}.tap do |hash|
373
+ value.each { |k, v| hash[k] = _to_hash(v) }
374
+ end
375
+ elsif value.respond_to? :to_hash
376
+ value.to_hash
377
+ else
378
+ value
379
+ end
380
+ end
381
+
382
+ end
383
+
384
+ end