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,346 @@
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 SaveTransaction
18
+ attr_accessor :account_id
19
+
20
+ attr_accessor :date
21
+
22
+ # The transaction amount in milliunits format
23
+ attr_accessor :amount
24
+
25
+ # The payee for the transaction. Transfer payees are not permitted and will be ignored if supplied.
26
+ attr_accessor :payee_id
27
+
28
+ # The payee name. If a payee_name value is provided and payee_id is not included or has a null value, payee_name will be used to create or use an existing payee.
29
+ attr_accessor :payee_name
30
+
31
+ # The category for the transaction. Split and Credit Card Payment categories are not permitted and will be ignored if supplied.
32
+ attr_accessor :category_id
33
+
34
+ attr_accessor :memo
35
+
36
+ # The cleared status of the transaction
37
+ attr_accessor :cleared
38
+
39
+ # Whether or not the transaction is approved. If not supplied, transaction will be unapproved by default.
40
+ attr_accessor :approved
41
+
42
+ # The transaction flag
43
+ attr_accessor :flag_color
44
+
45
+ # If specified for a new transaction, the transaction will be treated as Imported and assigned this import_id. If another transaction on the same account with this same import_id is later attempted to be created, it will be skipped to prevent duplication. Transactions imported through File Based Import or Direct Import and not through the API, are assigned an import_id in 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'. Using a consistent format will prevent duplicates through Direct Import and File Based Import. If import_id is specified as null, the transaction will be treated as a user entered transaction.
46
+ attr_accessor :import_id
47
+
48
+ class EnumAttributeValidator
49
+ attr_reader :datatype
50
+ attr_reader :allowable_values
51
+
52
+ def initialize(datatype, allowable_values)
53
+ @allowable_values = allowable_values.map do |value|
54
+ case datatype.to_s
55
+ when /Integer/i
56
+ value.to_i
57
+ when /Float/i
58
+ value.to_f
59
+ else
60
+ value
61
+ end
62
+ end
63
+ end
64
+
65
+ def valid?(value)
66
+ !value || allowable_values.include?(value)
67
+ end
68
+ end
69
+
70
+ # Attribute mapping from ruby-style variable name to JSON key.
71
+ def self.attribute_map
72
+ {
73
+ :'account_id' => :'account_id',
74
+ :'date' => :'date',
75
+ :'amount' => :'amount',
76
+ :'payee_id' => :'payee_id',
77
+ :'payee_name' => :'payee_name',
78
+ :'category_id' => :'category_id',
79
+ :'memo' => :'memo',
80
+ :'cleared' => :'cleared',
81
+ :'approved' => :'approved',
82
+ :'flag_color' => :'flag_color',
83
+ :'import_id' => :'import_id'
84
+ }
85
+ end
86
+
87
+ # Attribute type mapping.
88
+ def self.swagger_types
89
+ {
90
+ :'account_id' => :'String',
91
+ :'date' => :'Date',
92
+ :'amount' => :'Float',
93
+ :'payee_id' => :'String',
94
+ :'payee_name' => :'String',
95
+ :'category_id' => :'String',
96
+ :'memo' => :'String',
97
+ :'cleared' => :'String',
98
+ :'approved' => :'BOOLEAN',
99
+ :'flag_color' => :'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?(:'account_id')
113
+ self.account_id = attributes[:'account_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?(:'payee_id')
125
+ self.payee_id = attributes[:'payee_id']
126
+ end
127
+
128
+ if attributes.has_key?(:'payee_name')
129
+ self.payee_name = attributes[:'payee_name']
130
+ end
131
+
132
+ if attributes.has_key?(:'category_id')
133
+ self.category_id = attributes[:'category_id']
134
+ end
135
+
136
+ if attributes.has_key?(:'memo')
137
+ self.memo = attributes[:'memo']
138
+ end
139
+
140
+ if attributes.has_key?(:'cleared')
141
+ self.cleared = attributes[:'cleared']
142
+ end
143
+
144
+ if attributes.has_key?(:'approved')
145
+ self.approved = attributes[:'approved']
146
+ end
147
+
148
+ if attributes.has_key?(:'flag_color')
149
+ self.flag_color = attributes[:'flag_color']
150
+ end
151
+
152
+ if attributes.has_key?(:'import_id')
153
+ self.import_id = attributes[:'import_id']
154
+ end
155
+
156
+ end
157
+
158
+ # Show invalid properties with the reasons. Usually used together with valid?
159
+ # @return Array for valid properties with the reasons
160
+ def list_invalid_properties
161
+ invalid_properties = Array.new
162
+ if @account_id.nil?
163
+ invalid_properties.push("invalid value for 'account_id', account_id cannot be nil.")
164
+ end
165
+
166
+ if @date.nil?
167
+ invalid_properties.push("invalid value for 'date', date cannot be nil.")
168
+ end
169
+
170
+ if @amount.nil?
171
+ invalid_properties.push("invalid value for 'amount', amount cannot be nil.")
172
+ end
173
+
174
+ return invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ return false if @account_id.nil?
181
+ return false if @date.nil?
182
+ return false if @amount.nil?
183
+ cleared_validator = EnumAttributeValidator.new('String', ["Cleared", "Uncleared", "Reconciled"])
184
+ return false unless cleared_validator.valid?(@cleared)
185
+ flag_color_validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
186
+ return false unless flag_color_validator.valid?(@flag_color)
187
+ return true
188
+ end
189
+
190
+ # Custom attribute writer method checking allowed values (enum).
191
+ # @param [Object] cleared Object to be assigned
192
+ def cleared=(cleared)
193
+ validator = EnumAttributeValidator.new('String', ["Cleared", "Uncleared", "Reconciled"])
194
+ unless validator.valid?(cleared)
195
+ fail ArgumentError, "invalid value for 'cleared', must be one of #{validator.allowable_values}."
196
+ end
197
+ @cleared = cleared
198
+ end
199
+
200
+ # Custom attribute writer method checking allowed values (enum).
201
+ # @param [Object] flag_color Object to be assigned
202
+ def flag_color=(flag_color)
203
+ validator = EnumAttributeValidator.new('String', ["red", "orange", "yellow", "green", "blue", "purple"])
204
+ unless validator.valid?(flag_color)
205
+ fail ArgumentError, "invalid value for 'flag_color', must be one of #{validator.allowable_values}."
206
+ end
207
+ @flag_color = flag_color
208
+ end
209
+
210
+ # Checks equality by comparing each attribute.
211
+ # @param [Object] Object to be compared
212
+ def ==(o)
213
+ return true if self.equal?(o)
214
+ self.class == o.class &&
215
+ account_id == o.account_id &&
216
+ date == o.date &&
217
+ amount == o.amount &&
218
+ payee_id == o.payee_id &&
219
+ payee_name == o.payee_name &&
220
+ category_id == o.category_id &&
221
+ memo == o.memo &&
222
+ cleared == o.cleared &&
223
+ approved == o.approved &&
224
+ flag_color == o.flag_color &&
225
+ import_id == o.import_id
226
+ end
227
+
228
+ # @see the `==` method
229
+ # @param [Object] Object to be compared
230
+ def eql?(o)
231
+ self == o
232
+ end
233
+
234
+ # Calculates hash code according to all attributes.
235
+ # @return [Fixnum] Hash code
236
+ def hash
237
+ [account_id, date, amount, payee_id, payee_name, category_id, memo, cleared, approved, flag_color, import_id].hash
238
+ end
239
+
240
+ # Builds the object from hash
241
+ # @param [Hash] attributes Model attributes in the form of hash
242
+ # @return [Object] Returns the model itself
243
+ def build_from_hash(attributes)
244
+ return nil unless attributes.is_a?(Hash)
245
+ self.class.swagger_types.each_pair do |key, type|
246
+ if type =~ /\AArray<(.*)>/i
247
+ # check to ensure the input is an array given that the the attribute
248
+ # is documented as an array but the input is not
249
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
250
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
251
+ end
252
+ elsif !attributes[self.class.attribute_map[key]].nil?
253
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
254
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
255
+ end
256
+
257
+ self
258
+ end
259
+
260
+ # Deserializes the data based on type
261
+ # @param string type Data type
262
+ # @param string value Value to be deserialized
263
+ # @return [Object] Deserialized data
264
+ def _deserialize(type, value)
265
+ case type.to_sym
266
+ when :DateTime
267
+ DateTime.parse(value)
268
+ when :Date
269
+ Date.parse(value)
270
+ when :String
271
+ value.to_s
272
+ when :Integer
273
+ value.to_i
274
+ when :Float
275
+ value.to_f
276
+ when :BOOLEAN
277
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
278
+ true
279
+ else
280
+ false
281
+ end
282
+ when :Object
283
+ # generic object (usually a Hash), return directly
284
+ value
285
+ when /\AArray<(?<inner_type>.+)>\z/
286
+ inner_type = Regexp.last_match[:inner_type]
287
+ value.map { |v| _deserialize(inner_type, v) }
288
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
289
+ k_type = Regexp.last_match[:k_type]
290
+ v_type = Regexp.last_match[:v_type]
291
+ {}.tap do |hash|
292
+ value.each do |k, v|
293
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
294
+ end
295
+ end
296
+ else # model
297
+ temp_model = YnabApi.const_get(type).new
298
+ temp_model.build_from_hash(value)
299
+ end
300
+ end
301
+
302
+ # Returns the string representation of the object
303
+ # @return [String] String presentation of the object
304
+ def to_s
305
+ to_hash.to_s
306
+ end
307
+
308
+ # to_body is an alias to to_hash (backward compatibility)
309
+ # @return [Hash] Returns the object in the form of hash
310
+ def to_body
311
+ to_hash
312
+ end
313
+
314
+ # Returns the object in the form of hash
315
+ # @return [Hash] Returns the object in the form of hash
316
+ def to_hash
317
+ hash = {}
318
+ self.class.attribute_map.each_pair do |attr, param|
319
+ value = self.send(attr)
320
+ next if value.nil?
321
+ hash[param] = _to_hash(value)
322
+ end
323
+ hash
324
+ end
325
+
326
+ # Outputs non-array value in the form of hash
327
+ # For object, use to_hash. Otherwise, just return the value
328
+ # @param [Object] value Any valid value
329
+ # @return [Hash] Returns the value in the form of hash
330
+ def _to_hash(value)
331
+ if value.is_a?(Array)
332
+ value.compact.map{ |v| _to_hash(v) }
333
+ elsif value.is_a?(Hash)
334
+ {}.tap do |hash|
335
+ value.each { |k, v| hash[k] = _to_hash(v) }
336
+ end
337
+ elsif value.respond_to? :to_hash
338
+ value.to_hash
339
+ else
340
+ value
341
+ end
342
+ end
343
+
344
+ end
345
+
346
+ end
@@ -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 SaveTransactionWrapper
18
+ attr_accessor :transaction
19
+
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'transaction' => :'transaction'
25
+ }
26
+ end
27
+
28
+ # Attribute type mapping.
29
+ def self.swagger_types
30
+ {
31
+ :'transaction' => :'SaveTransaction'
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?(:'transaction')
44
+ self.transaction = attributes[:'transaction']
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 @transaction.nil?
54
+ invalid_properties.push("invalid value for 'transaction', transaction 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 @transaction.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
+ transaction == o.transaction
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].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