ynab 1.22.0 → 1.26.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 585279e8e48808663d79a26e141548a96997dae0a279a7920ffae89c5897c0bb
4
- data.tar.gz: 6b00ac6af6f6e50e61990772e01e1e59fd0216d58142f18eed3fdd2e5b57aa43
3
+ metadata.gz: c60570689ff9349bf4c09b5a0fdacedca132aa4994faed38135771d3a0c4f1f1
4
+ data.tar.gz: 64d6e2b081628f6f603a5cea7d454a6d33be1da38f9f81c3a61266712d49a2e8
5
5
  SHA512:
6
- metadata.gz: '090f48a478f00c25deb2255ce0425aa79139970ddb8742d6bfc6eea39ee00386b7f724f8e142a6db93eb94edb70378e115bf43c9939a7d743adb136e816ae7c1'
7
- data.tar.gz: 62642efb9686af3297094407318fde6fc0daa5de20b1ca0f995fac84b245e6c444895621202a8047ad2f416abafef0829e14a0daaf80361ebd5a38f22da2a30a
6
+ metadata.gz: 6ada6ce8b9c20ecd6caeec7e509b3ab8e0f303e6a3654ee217cd29a126e3ddddd4454b118af15dc7404b2010a809e9483f6897d2132b5583627ae1d721867f61
7
+ data.tar.gz: 6cc4fae86a8aef0a4839ec22c10b928ff0ff11a095c93549ef9db0faa08d75d1390b5bc8ff2f93d1b2f09b49087745342e85d4ceb6d3720ff85dd1188799a4ea
data/README.md CHANGED
@@ -54,6 +54,7 @@ The following methods are available in this library.
54
54
  | | [accounts.get_account_by_id(budget_id, account_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/AccountsApi.md#get_account_by_id) | Returns a single account |
55
55
  | **Categories** | [categories.get_categories(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#get_categories) | Returns all categories grouped by category group. |
56
56
  | | [categories.get_category_by_id(budget_id, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/CategoriesApi.md#get_category_by_id) | Returns a single category |
57
+ | | [categories.get_month_category_by_id(budget_id, month, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#get_month_category_by_id) | Returns a single category for a specific budget month
57
58
  | **Payees** | [payees.get_payees(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeesApi.md#get_payees) | Returns all payees |
58
59
  | | [payees.get_payee_by_id(budget_id, payee_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeesApi.md#get_payee_by_id) | Returns single payee |
59
60
  | **Payee Locations** | [payee_locations.get_payee_locations(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeeLocationsApi.md#get_payee_locations) | Returns all payee locations |
@@ -61,17 +62,17 @@ The following methods are available in this library.
61
62
  | | [payee_locations.get_payee_locations_by_payee(budget_id, payee_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/PayeeLocationsApi.md#get_payee_locations_by_payee) | Returns all payee locations for the specified payee |
62
63
  | **Months** | [months.get_budget_months(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#get_budget_months) | Returns all budget months |
63
64
  | | [months.get_budget_month(budget_id, month)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#get_budget_month) | Returns a single budget month |
64
- | | [months.get_month_category_by_id(budget_id, month, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#get_month_category_by_id) | Returns a single category for a specific budget month |
65
65
  | | [months.update_month_category(budget_id, month, category_id, month_category)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/MonthsApi.md#update_month_category) | Update an existing month category |
66
66
  | **Transactions** | [transactions.get_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions) | Returns budget transactions |
67
67
  | | [transactions.get_transactions_by_account(budget_id, account_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions_by_account) | Returns all transactions for a specified account |
68
68
  | | [transactions.get_transactions_by_category(budget_id, category_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transactions_by_category) | Returns all transactions for a specified category |
69
69
  | | [transactions.get_transaction_by_id(budget_id, transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#get_transaction_by_id) | Returns a single transaction |
70
- | | [transactions.create_transaction(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates a single transaction |
71
- | | [transactions.create_transactions(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates multiple transactions |
72
- | | [transactions.update_transaction(budget_id, id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#update_transaction) | Updates a single transaction |
73
- | | [transactions.update_transactions(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#update_transactions) | Updates multiple transactions |
74
- | | [transactions.import_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#import_transactions) | Imports transactions |
70
+ | | [transactions.create_transaction(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates a single transaction |
71
+ | | [transactions.create_transactions(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#create_transaction) | Creates multiple transactions |
72
+ | | [transactions.update_transaction(budget_id, id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#update_transaction) | Updates a single transaction |
73
+ | | [transactions.update_transactions(budget_id, data)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#update_transactions) | Updates multiple transactions |
74
+ | | [transactions.delete_transaction(budget_id, transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#delete_transaction) | Imports transactions |
75
+ | | [transactions.import_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/TransactionsApi.md#import_transactions) | Deletes a single transaction |
75
76
  | **Scheduled Transactions** | [scheduled_transactions.get_scheduled_transactions(budget_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#get_scheduled_transactions) | Returns all scheduled transactions |
76
77
  | | [scheduled_transactions.get_scheduled_transaction_by_id(budget_id, scheduled_transaction_id)](https://github.com/ynab/ynab-sdk-ruby/blob/master/docs/ScheduledTransactionsApi.md#get_scheduled_transaction_by_id) | Returns a single scheduled transaction |
77
78
 
@@ -77,6 +77,64 @@ module YNAB
77
77
  end
78
78
  return data, status_code, headers
79
79
  end
80
+ # Deletes an existing transaction
81
+ # Deletes a transaction
82
+ # @param budget_id The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.youneedabudget.com/#oauth-default-budget).
83
+ # @param transaction_id The id of the transaction
84
+ # @param [Hash] opts the optional parameters
85
+ # @return [TransactionResponse]
86
+ def delete_transaction(budget_id, transaction_id, opts = {})
87
+ data, _status_code, _headers = delete_transaction_with_http_info(budget_id, transaction_id, opts)
88
+ data
89
+ end
90
+
91
+ # Deletes an existing transaction
92
+ # Deletes a transaction
93
+ # @param budget_id The id of the budget. \"last-used\" can be used to specify the last used budget and \"default\" can be used if default budget selection is enabled (see: https://api.youneedabudget.com/#oauth-default-budget).
94
+ # @param transaction_id The id of the transaction
95
+ # @param [Hash] opts the optional parameters
96
+ # @return [Array<(TransactionResponse, Fixnum, Hash)>] TransactionResponse data, response status code and response headers
97
+ def delete_transaction_with_http_info(budget_id, transaction_id, opts = {})
98
+ if @api_client.config.debugging
99
+ @api_client.config.logger.debug 'Calling API: TransactionsApi.delete_transaction ...'
100
+ end
101
+ # verify the required parameter 'budget_id' is set
102
+ if @api_client.config.client_side_validation && budget_id.nil?
103
+ fail ArgumentError, "Missing the required parameter 'budget_id' when calling TransactionsApi.delete_transaction"
104
+ end
105
+ # verify the required parameter 'transaction_id' is set
106
+ if @api_client.config.client_side_validation && transaction_id.nil?
107
+ fail ArgumentError, "Missing the required parameter 'transaction_id' when calling TransactionsApi.delete_transaction"
108
+ end
109
+ # resource path
110
+ local_var_path = '/budgets/{budget_id}/transactions/{transaction_id}'.sub('{' + 'budget_id' + '}', budget_id.to_s).sub('{' + 'transaction_id' + '}', transaction_id.to_s)
111
+
112
+ # query parameters
113
+ query_params = {}
114
+
115
+ # header parameters
116
+ header_params = {}
117
+ # HTTP header 'Accept' (if needed)
118
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
119
+
120
+ # form parameters
121
+ form_params = {}
122
+
123
+ # http body (model)
124
+ post_body = nil
125
+ auth_names = ['bearer']
126
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
127
+ :header_params => header_params,
128
+ :query_params => query_params,
129
+ :form_params => form_params,
130
+ :body => post_body,
131
+ :auth_names => auth_names,
132
+ :return_type => 'TransactionResponse')
133
+ if @api_client.config.debugging
134
+ @api_client.config.logger.debug "API called: TransactionsApi#delete_transaction\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
135
+ end
136
+ return data, status_code, headers
137
+ end
80
138
  # Single transaction
81
139
  # Returns a single transaction
82
140
  # @param budget_id The id of the budget. \&quot;last-used\&quot; can be used to specify the last used budget and \&quot;default\&quot; can be used if default budget selection is enabled (see: https://api.youneedabudget.com/#oauth-default-budget).
@@ -48,9 +48,15 @@ module YNAB
48
48
  # If transaction is matched, the id of the matched transaction
49
49
  attr_accessor :matched_transaction_id
50
50
 
51
- # 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'.
51
+ # 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'.
52
52
  attr_accessor :import_id
53
53
 
54
+ # If the transaction was imported, the payee name that was used when importing and before applying any payee rename rules
55
+ attr_accessor :import_payee_name
56
+
57
+ # If the transaction was imported, the original payee name as it appeared on the statement
58
+ attr_accessor :import_payee_name_original
59
+
54
60
  # Whether or not the transaction has been deleted. Deleted transactions will only be included in delta requests.
55
61
  attr_accessor :deleted
56
62
 
@@ -105,6 +111,8 @@ module YNAB
105
111
  :'transfer_transaction_id' => :'transfer_transaction_id',
106
112
  :'matched_transaction_id' => :'matched_transaction_id',
107
113
  :'import_id' => :'import_id',
114
+ :'import_payee_name' => :'import_payee_name',
115
+ :'import_payee_name_original' => :'import_payee_name_original',
108
116
  :'deleted' => :'deleted',
109
117
  :'type' => :'type',
110
118
  :'parent_transaction_id' => :'parent_transaction_id',
@@ -131,6 +139,8 @@ module YNAB
131
139
  :'transfer_transaction_id' => :'String',
132
140
  :'matched_transaction_id' => :'String',
133
141
  :'import_id' => :'String',
142
+ :'import_payee_name' => :'String',
143
+ :'import_payee_name_original' => :'String',
134
144
  :'deleted' => :'BOOLEAN',
135
145
  :'type' => :'String',
136
146
  :'parent_transaction_id' => :'String',
@@ -204,6 +214,14 @@ module YNAB
204
214
  self.import_id = attributes[:'import_id']
205
215
  end
206
216
 
217
+ if attributes.has_key?(:'import_payee_name')
218
+ self.import_payee_name = attributes[:'import_payee_name']
219
+ end
220
+
221
+ if attributes.has_key?(:'import_payee_name_original')
222
+ self.import_payee_name_original = attributes[:'import_payee_name_original']
223
+ end
224
+
207
225
  if attributes.has_key?(:'deleted')
208
226
  self.deleted = attributes[:'deleted']
209
227
  end
@@ -257,6 +275,14 @@ module YNAB
257
275
  invalid_properties.push('invalid value for "account_id", account_id cannot be nil.')
258
276
  end
259
277
 
278
+ if !@import_payee_name.nil? && @import_payee_name.to_s.length > 200
279
+ invalid_properties.push('invalid value for "import_payee_name", the character length must be smaller than or equal to 200.')
280
+ end
281
+
282
+ if !@import_payee_name_original.nil? && @import_payee_name_original.to_s.length > 200
283
+ invalid_properties.push('invalid value for "import_payee_name_original", the character length must be smaller than or equal to 200.')
284
+ end
285
+
260
286
  if @deleted.nil?
261
287
  invalid_properties.push('invalid value for "deleted", deleted cannot be nil.')
262
288
  end
@@ -285,6 +311,8 @@ module YNAB
285
311
  flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
286
312
  return false unless flag_color_validator.valid?(@flag_color)
287
313
  return false if @account_id.nil?
314
+ return false if !@import_payee_name.nil? && @import_payee_name.to_s.length > 200
315
+ return false if !@import_payee_name_original.nil? && @import_payee_name_original.to_s.length > 200
288
316
  return false if @deleted.nil?
289
317
  return false if @type.nil?
290
318
  type_validator = EnumAttributeValidator.new('String', ['transaction', 'subtransaction'])
@@ -305,6 +333,26 @@ module YNAB
305
333
  @flag_color = flag_color
306
334
  end
307
335
 
336
+ # Custom attribute writer method with validation
337
+ # @param [Object] import_payee_name Value to be assigned
338
+ def import_payee_name=(import_payee_name)
339
+ if !import_payee_name.nil? && import_payee_name.to_s.length > 200
340
+ fail ArgumentError, 'invalid value for "import_payee_name", the character length must be smaller than or equal to 200.'
341
+ end
342
+
343
+ @import_payee_name = import_payee_name
344
+ end
345
+
346
+ # Custom attribute writer method with validation
347
+ # @param [Object] import_payee_name_original Value to be assigned
348
+ def import_payee_name_original=(import_payee_name_original)
349
+ if !import_payee_name_original.nil? && import_payee_name_original.to_s.length > 200
350
+ fail ArgumentError, 'invalid value for "import_payee_name_original", the character length must be smaller than or equal to 200.'
351
+ end
352
+
353
+ @import_payee_name_original = import_payee_name_original
354
+ end
355
+
308
356
  # Custom attribute writer method checking allowed values (enum).
309
357
  # @param [Object] type Object to be assigned
310
358
  def type=(type)
@@ -330,6 +378,8 @@ module YNAB
330
378
  transfer_transaction_id == o.transfer_transaction_id &&
331
379
  matched_transaction_id == o.matched_transaction_id &&
332
380
  import_id == o.import_id &&
381
+ import_payee_name == o.import_payee_name &&
382
+ import_payee_name_original == o.import_payee_name_original &&
333
383
  deleted == o.deleted &&
334
384
  type == o.type &&
335
385
  parent_transaction_id == o.parent_transaction_id &&
@@ -347,7 +397,7 @@ module YNAB
347
397
  # Calculates hash code according to all attributes.
348
398
  # @return [Fixnum] Hash code
349
399
  def hash
350
- [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, matched_transaction_id, import_id, deleted, type, parent_transaction_id, account_name, payee_name, category_name].hash
400
+ [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, matched_transaction_id, import_id, import_payee_name, import_payee_name_original, deleted, type, parent_transaction_id, account_name, payee_name, category_name].hash
351
401
  end
352
402
  # Builds the object from hash
353
403
  # @param [Hash] attributes Model attributes in the form of hash
@@ -16,17 +16,22 @@ module YNAB
16
16
  class HybridTransactionsResponseData
17
17
  attr_accessor :transactions
18
18
 
19
+ # The knowledge of the server
20
+ attr_accessor :server_knowledge
21
+
19
22
  # Attribute mapping from ruby-style variable name to JSON key.
20
23
  def self.attribute_map
21
24
  {
22
- :'transactions' => :'transactions'
25
+ :'transactions' => :'transactions',
26
+ :'server_knowledge' => :'server_knowledge'
23
27
  }
24
28
  end
25
29
 
26
30
  # Attribute type mapping.
27
31
  def self.swagger_types
28
32
  {
29
- :'transactions' => :'Array<HybridTransaction>'
33
+ :'transactions' => :'Array<HybridTransaction>',
34
+ :'server_knowledge' => :'Integer'
30
35
  }
31
36
  end
32
37
 
@@ -43,6 +48,10 @@ module YNAB
43
48
  self.transactions = value
44
49
  end
45
50
  end
51
+
52
+ if attributes.has_key?(:'server_knowledge')
53
+ self.server_knowledge = attributes[:'server_knowledge']
54
+ end
46
55
  end
47
56
 
48
57
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -68,7 +77,8 @@ module YNAB
68
77
  def ==(o)
69
78
  return true if self.equal?(o)
70
79
  self.class == o.class &&
71
- transactions == o.transactions
80
+ transactions == o.transactions &&
81
+ server_knowledge == o.server_knowledge
72
82
  end
73
83
 
74
84
  # @see the `==` method
@@ -80,7 +90,7 @@ module YNAB
80
90
  # Calculates hash code according to all attributes.
81
91
  # @return [Fixnum] Hash code
82
92
  def hash
83
- [transactions].hash
93
+ [transactions, server_knowledge].hash
84
94
  end
85
95
  # Builds the object from hash
86
96
  # @param [Hash] attributes Model attributes in the form of hash
@@ -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.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module YNAB
16
+ class PatchMonthCategoryWrapper
17
+ attr_accessor :category
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'category' => :'category'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'category' => :'SaveMonthCategory'
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?(:'category')
42
+ self.category = attributes[:'category']
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 @category.nil?
51
+ invalid_properties.push('invalid value for "category", category 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 @category.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
+ category == o.category
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
+ [category].hash
82
+ end
83
+ # Builds the object from hash
84
+ # @param [Hash] attributes Model attributes in the form of hash
85
+ # @return [Object] Returns the model itself
86
+ def build_from_hash(attributes)
87
+ return nil unless attributes.is_a?(Hash)
88
+ self.class.swagger_types.each_pair do |key, type|
89
+ if type =~ /\AArray<(.*)>/i
90
+ # check to ensure the input is an array given that the attribute
91
+ # is documented as an array but the input is not
92
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
93
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
94
+ end
95
+ elsif !attributes[self.class.attribute_map[key]].nil?
96
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
97
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
98
+ end
99
+
100
+ self
101
+ end
102
+
103
+ # Deserializes the data based on type
104
+ # @param string type Data type
105
+ # @param string value Value to be deserialized
106
+ # @return [Object] Deserialized data
107
+ def _deserialize(type, value)
108
+ case type.to_sym
109
+ when :DateTime
110
+ DateTime.parse(value)
111
+ when :Date
112
+ Date.parse(value)
113
+ when :String
114
+ value.to_s
115
+ when :Integer
116
+ value.to_i
117
+ when :Float
118
+ value.to_f
119
+ when :BOOLEAN
120
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
121
+ true
122
+ else
123
+ false
124
+ end
125
+ when :Object
126
+ # generic object (usually a Hash), return directly
127
+ value
128
+ when /\AArray<(?<inner_type>.+)>\z/
129
+ inner_type = Regexp.last_match[:inner_type]
130
+ value.map { |v| _deserialize(inner_type, v) }
131
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
132
+ k_type = Regexp.last_match[:k_type]
133
+ v_type = Regexp.last_match[:v_type]
134
+ {}.tap do |hash|
135
+ value.each do |k, v|
136
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
137
+ end
138
+ end
139
+ else # model
140
+ temp_model = YNAB.const_get(type).new
141
+ temp_model.build_from_hash(value)
142
+ end
143
+ end
144
+
145
+ # Returns the string representation of the object
146
+ # @return [String] String presentation of the object
147
+ def to_s
148
+ to_hash.to_s
149
+ end
150
+
151
+ # to_body is an alias to to_hash (backward compatibility)
152
+ # @return [Hash] Returns the object in the form of hash
153
+ def to_body
154
+ to_hash
155
+ end
156
+
157
+ # Returns the object in the form of hash
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_hash
160
+ hash = {}
161
+ self.class.attribute_map.each_pair do |attr, param|
162
+ value = self.send(attr)
163
+ next if value.nil?
164
+ hash[param] = _to_hash(value)
165
+ end
166
+ hash
167
+ end
168
+
169
+ # Outputs non-array value in the form of hash
170
+ # For object, use to_hash. Otherwise, just return the value
171
+ # @param [Object] value Any valid value
172
+ # @return [Hash] Returns the value in the form of hash
173
+ def _to_hash(value)
174
+ if value.is_a?(Array)
175
+ value.compact.map { |v| _to_hash(v) }
176
+ elsif value.is_a?(Hash)
177
+ {}.tap do |hash|
178
+ value.each { |k, v| hash[k] = _to_hash(v) }
179
+ end
180
+ elsif value.respond_to? :to_hash
181
+ value.to_hash
182
+ else
183
+ value
184
+ end
185
+ end
186
+
187
+ end
188
+
189
+ end
@@ -0,0 +1,191 @@
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.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module YNAB
16
+ class PatchTransactionsWrapper
17
+ attr_accessor :transactions
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'transactions' => :'transactions'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'transactions' => :'Array<SaveTransactionWithId>'
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?(:'transactions')
42
+ if (value = attributes[:'transactions']).is_a?(Array)
43
+ self.transactions = value
44
+ end
45
+ end
46
+ end
47
+
48
+ # Show invalid properties with the reasons. Usually used together with valid?
49
+ # @return Array for valid properties with the reasons
50
+ def list_invalid_properties
51
+ invalid_properties = Array.new
52
+ if @transactions.nil?
53
+ invalid_properties.push('invalid value for "transactions", transactions cannot be nil.')
54
+ end
55
+
56
+ invalid_properties
57
+ end
58
+
59
+ # Check to see if the all the properties in the model are valid
60
+ # @return true if the model is valid
61
+ def valid?
62
+ return false if @transactions.nil?
63
+ true
64
+ end
65
+
66
+ # Checks equality by comparing each attribute.
67
+ # @param [Object] Object to be compared
68
+ def ==(o)
69
+ return true if self.equal?(o)
70
+ self.class == o.class &&
71
+ transactions == o.transactions
72
+ end
73
+
74
+ # @see the `==` method
75
+ # @param [Object] Object to be compared
76
+ def eql?(o)
77
+ self == o
78
+ end
79
+
80
+ # Calculates hash code according to all attributes.
81
+ # @return [Fixnum] Hash code
82
+ def hash
83
+ [transactions].hash
84
+ end
85
+ # Builds the object from hash
86
+ # @param [Hash] attributes Model attributes in the form of hash
87
+ # @return [Object] Returns the model itself
88
+ def build_from_hash(attributes)
89
+ return nil unless attributes.is_a?(Hash)
90
+ self.class.swagger_types.each_pair do |key, type|
91
+ if type =~ /\AArray<(.*)>/i
92
+ # check to ensure the input is an array given that the attribute
93
+ # is documented as an array but the input is not
94
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
95
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
96
+ end
97
+ elsif !attributes[self.class.attribute_map[key]].nil?
98
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
99
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
100
+ end
101
+
102
+ self
103
+ end
104
+
105
+ # Deserializes the data based on type
106
+ # @param string type Data type
107
+ # @param string value Value to be deserialized
108
+ # @return [Object] Deserialized data
109
+ def _deserialize(type, value)
110
+ case type.to_sym
111
+ when :DateTime
112
+ DateTime.parse(value)
113
+ when :Date
114
+ Date.parse(value)
115
+ when :String
116
+ value.to_s
117
+ when :Integer
118
+ value.to_i
119
+ when :Float
120
+ value.to_f
121
+ when :BOOLEAN
122
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
123
+ true
124
+ else
125
+ false
126
+ end
127
+ when :Object
128
+ # generic object (usually a Hash), return directly
129
+ value
130
+ when /\AArray<(?<inner_type>.+)>\z/
131
+ inner_type = Regexp.last_match[:inner_type]
132
+ value.map { |v| _deserialize(inner_type, v) }
133
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
134
+ k_type = Regexp.last_match[:k_type]
135
+ v_type = Regexp.last_match[:v_type]
136
+ {}.tap do |hash|
137
+ value.each do |k, v|
138
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
139
+ end
140
+ end
141
+ else # model
142
+ temp_model = YNAB.const_get(type).new
143
+ temp_model.build_from_hash(value)
144
+ end
145
+ end
146
+
147
+ # Returns the string representation of the object
148
+ # @return [String] String presentation of the object
149
+ def to_s
150
+ to_hash.to_s
151
+ end
152
+
153
+ # to_body is an alias to to_hash (backward compatibility)
154
+ # @return [Hash] Returns the object in the form of hash
155
+ def to_body
156
+ to_hash
157
+ end
158
+
159
+ # Returns the object in the form of hash
160
+ # @return [Hash] Returns the object in the form of hash
161
+ def to_hash
162
+ hash = {}
163
+ self.class.attribute_map.each_pair do |attr, param|
164
+ value = self.send(attr)
165
+ next if value.nil?
166
+ hash[param] = _to_hash(value)
167
+ end
168
+ hash
169
+ end
170
+
171
+ # Outputs non-array value in the form of hash
172
+ # For object, use to_hash. Otherwise, just return the value
173
+ # @param [Object] value Any valid value
174
+ # @return [Hash] Returns the value in the form of hash
175
+ def _to_hash(value)
176
+ if value.is_a?(Array)
177
+ value.compact.map { |v| _to_hash(v) }
178
+ elsif value.is_a?(Hash)
179
+ {}.tap do |hash|
180
+ value.each { |k, v| hash[k] = _to_hash(v) }
181
+ end
182
+ elsif value.respond_to? :to_hash
183
+ value.to_hash
184
+ else
185
+ value
186
+ end
187
+ end
188
+
189
+ end
190
+
191
+ end