ynab 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile.lock +2 -2
  3. data/README.md +37 -27
  4. data/Rakefile +0 -6
  5. data/config.json +1 -1
  6. data/docs/Account.md +1 -0
  7. data/docs/AccountsApi.md +3 -3
  8. data/docs/BudgetsApi.md +4 -4
  9. data/docs/CategoriesApi.md +45 -4
  10. data/docs/HybridTransaction.md +2 -1
  11. data/docs/MonthDetail.md +1 -1
  12. data/docs/MonthsApi.md +3 -3
  13. data/docs/PayeeLocationsApi.md +4 -4
  14. data/docs/PayeesApi.md +3 -3
  15. data/docs/SaveMonthCategory.md +8 -0
  16. data/docs/SaveMonthCategoryWrapper.md +8 -0
  17. data/docs/SaveTransaction.md +2 -2
  18. data/docs/SaveTransactionsResponse.md +8 -0
  19. data/docs/SaveTransactionsResponseData.md +11 -0
  20. data/docs/SaveTransactionsWrapper.md +9 -0
  21. data/docs/ScheduledTransactionsApi.md +3 -3
  22. data/docs/TransactionDetail.md +2 -1
  23. data/docs/TransactionSummary.md +2 -1
  24. data/docs/TransactionsApi.md +25 -25
  25. data/docs/UserApi.md +1 -1
  26. data/examples/create-multiple-transactions.rb +44 -0
  27. data/examples/update-category-budgeted.rb +23 -0
  28. data/lib/ynab.rb +5 -0
  29. data/lib/ynab/api/accounts_api.rb +6 -6
  30. data/lib/ynab/api/budgets_api.rb +8 -8
  31. data/lib/ynab/api/categories_api.rb +142 -8
  32. data/lib/ynab/api/months_api.rb +6 -6
  33. data/lib/ynab/api/payee_locations_api.rb +8 -8
  34. data/lib/ynab/api/payees_api.rb +6 -6
  35. data/lib/ynab/api/scheduled_transactions_api.rb +6 -6
  36. data/lib/ynab/api/transactions_api.rb +54 -54
  37. data/lib/ynab/api/user_api.rb +2 -2
  38. data/lib/ynab/models/account.rb +16 -1
  39. data/lib/ynab/models/hybrid_transaction.rb +17 -1
  40. data/lib/ynab/models/month_detail.rb +1 -1
  41. data/lib/ynab/models/save_month_category.rb +189 -0
  42. data/lib/ynab/models/save_month_category_wrapper.rb +188 -0
  43. data/lib/ynab/models/save_transaction.rb +2 -2
  44. data/lib/ynab/models/save_transactions_response.rb +188 -0
  45. data/lib/ynab/models/save_transactions_response_data.rb +225 -0
  46. data/lib/ynab/models/save_transactions_wrapper.rb +194 -0
  47. data/lib/ynab/models/transaction_detail.rb +17 -1
  48. data/lib/ynab/models/transaction_summary.rb +17 -1
  49. data/lib/ynab/version.rb +1 -1
  50. data/pkg/ynab-1.4.0.gem +0 -0
  51. data/spec-v1-swagger.json +413 -245
  52. data/spec/api/categories_spec.rb +14 -2
  53. data/spec/api/transactions_spec.rb +31 -0
  54. data/spec/fixtures/vcr_cassettes/category.yml +1 -1
  55. data/spec/fixtures/vcr_cassettes/multiple_transactions.yml +46 -0
  56. data/spec/fixtures/vcr_cassettes/patch_month_category.yml +46 -0
  57. metadata +20 -3
@@ -38,8 +38,12 @@ module YNAB
38
38
 
39
39
  attr_accessor :category_id
40
40
 
41
+ # If a transfer transaction, the account to which it transfers
41
42
  attr_accessor :transfer_account_id
42
43
 
44
+ # If a transfer transaction, the id of transaction on the other side of the transfer
45
+ attr_accessor :transfer_transaction_id
46
+
43
47
  # 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'.
44
48
  attr_accessor :import_id
45
49
 
@@ -94,6 +98,7 @@ module YNAB
94
98
  :'payee_id' => :'payee_id',
95
99
  :'category_id' => :'category_id',
96
100
  :'transfer_account_id' => :'transfer_account_id',
101
+ :'transfer_transaction_id' => :'transfer_transaction_id',
97
102
  :'import_id' => :'import_id',
98
103
  :'deleted' => :'deleted',
99
104
  :'type' => :'type',
@@ -118,6 +123,7 @@ module YNAB
118
123
  :'payee_id' => :'String',
119
124
  :'category_id' => :'String',
120
125
  :'transfer_account_id' => :'String',
126
+ :'transfer_transaction_id' => :'String',
121
127
  :'import_id' => :'String',
122
128
  :'deleted' => :'BOOLEAN',
123
129
  :'type' => :'String',
@@ -180,6 +186,10 @@ module YNAB
180
186
  self.transfer_account_id = attributes[:'transfer_account_id']
181
187
  end
182
188
 
189
+ if attributes.has_key?(:'transfer_transaction_id')
190
+ self.transfer_transaction_id = attributes[:'transfer_transaction_id']
191
+ end
192
+
183
193
  if attributes.has_key?(:'import_id')
184
194
  self.import_id = attributes[:'import_id']
185
195
  end
@@ -257,6 +267,10 @@ module YNAB
257
267
  invalid_properties.push('invalid value for "transfer_account_id", transfer_account_id cannot be nil.')
258
268
  end
259
269
 
270
+ if @transfer_transaction_id.nil?
271
+ invalid_properties.push('invalid value for "transfer_transaction_id", transfer_transaction_id cannot be nil.')
272
+ end
273
+
260
274
  if @import_id.nil?
261
275
  invalid_properties.push('invalid value for "import_id", import_id cannot be nil.')
262
276
  end
@@ -306,6 +320,7 @@ module YNAB
306
320
  return false if @payee_id.nil?
307
321
  return false if @category_id.nil?
308
322
  return false if @transfer_account_id.nil?
323
+ return false if @transfer_transaction_id.nil?
309
324
  return false if @import_id.nil?
310
325
  return false if @deleted.nil?
311
326
  return false if @type.nil?
@@ -364,6 +379,7 @@ module YNAB
364
379
  payee_id == o.payee_id &&
365
380
  category_id == o.category_id &&
366
381
  transfer_account_id == o.transfer_account_id &&
382
+ transfer_transaction_id == o.transfer_transaction_id &&
367
383
  import_id == o.import_id &&
368
384
  deleted == o.deleted &&
369
385
  type == o.type &&
@@ -382,7 +398,7 @@ module YNAB
382
398
  # Calculates hash code according to all attributes.
383
399
  # @return [Fixnum] Hash code
384
400
  def hash
385
- [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, import_id, deleted, type, parent_transaction_id, account_name, payee_name, category_name].hash
401
+ [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, transfer_transaction_id, import_id, deleted, type, parent_transaction_id, account_name, payee_name, category_name].hash
386
402
  end
387
403
 
388
404
  # Builds the object from hash
@@ -33,7 +33,7 @@ module YNAB
33
33
  # The Age of Money as of the month
34
34
  attr_accessor :age_of_money
35
35
 
36
- # The budget month categories
36
+ # the budget month categories
37
37
  attr_accessor :categories
38
38
 
39
39
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -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.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module YNAB
16
+ class SaveMonthCategory
17
+ # Budgeted amount in milliunits format
18
+ attr_accessor :budgeted
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :'budgeted' => :'budgeted'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.swagger_types
29
+ {
30
+ :'budgeted' => :'Integer'
31
+ }
32
+ end
33
+
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
36
+ def initialize(attributes = {})
37
+ return unless attributes.is_a?(Hash)
38
+
39
+ # convert string to symbol for hash key
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
41
+
42
+ if attributes.has_key?(:'budgeted')
43
+ self.budgeted = attributes[:'budgeted']
44
+ end
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ if @budgeted.nil?
52
+ invalid_properties.push('invalid value for "budgeted", budgeted cannot be nil.')
53
+ end
54
+
55
+ invalid_properties
56
+ end
57
+
58
+ # Check to see if the all the properties in the model are valid
59
+ # @return true if the model is valid
60
+ def valid?
61
+ return false if @budgeted.nil?
62
+ true
63
+ end
64
+
65
+ # Checks equality by comparing each attribute.
66
+ # @param [Object] Object to be compared
67
+ def ==(o)
68
+ return true if self.equal?(o)
69
+ self.class == o.class &&
70
+ budgeted == o.budgeted
71
+ end
72
+
73
+ # @see the `==` method
74
+ # @param [Object] Object to be compared
75
+ def eql?(o)
76
+ self == o
77
+ end
78
+
79
+ # Calculates hash code according to all attributes.
80
+ # @return [Fixnum] Hash code
81
+ def hash
82
+ [budgeted].hash
83
+ end
84
+
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 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
+ end
189
+ end
@@ -0,0 +1,188 @@
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.0-SNAPSHOT
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module YNAB
16
+ class SaveMonthCategoryWrapper
17
+ attr_accessor :month_category
18
+
19
+ # Attribute mapping from ruby-style variable name to JSON key.
20
+ def self.attribute_map
21
+ {
22
+ :'month_category' => :'month_category'
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.swagger_types
28
+ {
29
+ :'month_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?(:'month_category')
42
+ self.month_category = attributes[:'month_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 @month_category.nil?
51
+ invalid_properties.push('invalid value for "month_category", month_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 @month_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
+ month_category == o.month_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
+ [month_category].hash
82
+ end
83
+
84
+ # Builds the object from hash
85
+ # @param [Hash] attributes Model attributes in the form of hash
86
+ # @return [Object] Returns the model itself
87
+ def build_from_hash(attributes)
88
+ return nil unless attributes.is_a?(Hash)
89
+ self.class.swagger_types.each_pair do |key, type|
90
+ if type =~ /\AArray<(.*)>/i
91
+ # check to ensure the input is an array given that the the attribute
92
+ # is documented as an array but the input is not
93
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
94
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
95
+ end
96
+ elsif !attributes[self.class.attribute_map[key]].nil?
97
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
98
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
99
+ end
100
+
101
+ self
102
+ end
103
+
104
+ # Deserializes the data based on type
105
+ # @param string type Data type
106
+ # @param string value Value to be deserialized
107
+ # @return [Object] Deserialized data
108
+ def _deserialize(type, value)
109
+ case type.to_sym
110
+ when :DateTime
111
+ DateTime.parse(value)
112
+ when :Date
113
+ Date.parse(value)
114
+ when :String
115
+ value.to_s
116
+ when :Integer
117
+ value.to_i
118
+ when :Float
119
+ value.to_f
120
+ when :BOOLEAN
121
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
122
+ true
123
+ else
124
+ false
125
+ end
126
+ when :Object
127
+ # generic object (usually a Hash), return directly
128
+ value
129
+ when /\AArray<(?<inner_type>.+)>\z/
130
+ inner_type = Regexp.last_match[:inner_type]
131
+ value.map { |v| _deserialize(inner_type, v) }
132
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
133
+ k_type = Regexp.last_match[:k_type]
134
+ v_type = Regexp.last_match[:v_type]
135
+ {}.tap do |hash|
136
+ value.each do |k, v|
137
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
138
+ end
139
+ end
140
+ else # model
141
+ temp_model = YNAB.const_get(type).new
142
+ temp_model.build_from_hash(value)
143
+ end
144
+ end
145
+
146
+ # Returns the string representation of the object
147
+ # @return [String] String presentation of the object
148
+ def to_s
149
+ to_hash.to_s
150
+ end
151
+
152
+ # to_body is an alias to to_hash (backward compatibility)
153
+ # @return [Hash] Returns the object in the form of hash
154
+ def to_body
155
+ to_hash
156
+ end
157
+
158
+ # Returns the object in the form of hash
159
+ # @return [Hash] Returns the object in the form of hash
160
+ def to_hash
161
+ hash = {}
162
+ self.class.attribute_map.each_pair do |attr, param|
163
+ value = self.send(attr)
164
+ next if value.nil?
165
+ hash[param] = _to_hash(value)
166
+ end
167
+ hash
168
+ end
169
+
170
+ # Outputs non-array value in the form of hash
171
+ # For object, use to_hash. Otherwise, just return the value
172
+ # @param [Object] value Any valid value
173
+ # @return [Hash] Returns the value in the form of hash
174
+ def _to_hash(value)
175
+ if value.is_a?(Array)
176
+ value.compact.map { |v| _to_hash(v) }
177
+ elsif value.is_a?(Hash)
178
+ {}.tap do |hash|
179
+ value.each { |k, v| hash[k] = _to_hash(v) }
180
+ end
181
+ elsif value.respond_to? :to_hash
182
+ value.to_hash
183
+ else
184
+ value
185
+ end
186
+ end
187
+ end
188
+ end