ynab 1.13.0 → 1.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -0
  3. data/lib/ynab.rb +6 -1
  4. data/lib/ynab/api/accounts_api.rb +3 -3
  5. data/lib/ynab/api/budgets_api.rb +6 -3
  6. data/lib/ynab/api/categories_api.rb +7 -7
  7. data/lib/ynab/api/deprecated_api.rb +1 -1
  8. data/lib/ynab/api/months_api.rb +3 -3
  9. data/lib/ynab/api/payee_locations_api.rb +1 -1
  10. data/lib/ynab/api/payees_api.rb +3 -3
  11. data/lib/ynab/api/scheduled_transactions_api.rb +3 -3
  12. data/lib/ynab/api/transactions_api.rb +77 -25
  13. data/lib/ynab/api/user_api.rb +1 -1
  14. data/lib/ynab/api_client.rb +3 -2
  15. data/lib/ynab/configuration.rb +2 -3
  16. data/lib/ynab/models/account.rb +3 -7
  17. data/lib/ynab/models/account_response.rb +3 -2
  18. data/lib/ynab/models/account_response_data.rb +3 -2
  19. data/lib/ynab/models/accounts_response.rb +3 -2
  20. data/lib/ynab/models/accounts_response_data.rb +3 -2
  21. data/lib/ynab/models/budget_detail.rb +3 -2
  22. data/lib/ynab/models/budget_detail_response.rb +3 -2
  23. data/lib/ynab/models/budget_detail_response_data.rb +3 -2
  24. data/lib/ynab/models/budget_settings.rb +3 -2
  25. data/lib/ynab/models/budget_settings_response.rb +3 -2
  26. data/lib/ynab/models/budget_settings_response_data.rb +3 -2
  27. data/lib/ynab/models/budget_summary.rb +19 -6
  28. data/lib/ynab/models/budget_summary_response.rb +3 -2
  29. data/lib/ynab/models/budget_summary_response_data.rb +3 -7
  30. data/lib/ynab/models/bulk_response.rb +3 -2
  31. data/lib/ynab/models/bulk_response_data.rb +3 -2
  32. data/lib/ynab/models/bulk_response_data_bulk.rb +4 -3
  33. data/lib/ynab/models/bulk_transactions.rb +3 -2
  34. data/lib/ynab/models/categories_response.rb +3 -2
  35. data/lib/ynab/models/categories_response_data.rb +3 -2
  36. data/lib/ynab/models/category.rb +7 -36
  37. data/lib/ynab/models/category_group.rb +3 -2
  38. data/lib/ynab/models/category_group_with_categories.rb +3 -2
  39. data/lib/ynab/models/category_response.rb +3 -2
  40. data/lib/ynab/models/category_response_data.rb +3 -2
  41. data/lib/ynab/models/currency_format.rb +3 -2
  42. data/lib/ynab/models/date_format.rb +3 -2
  43. data/lib/ynab/models/error_detail.rb +3 -2
  44. data/lib/ynab/models/error_response.rb +3 -2
  45. data/lib/ynab/models/hybrid_transaction.rb +4 -58
  46. data/lib/ynab/models/hybrid_transactions_response.rb +3 -2
  47. data/lib/ynab/models/hybrid_transactions_response_data.rb +3 -2
  48. data/lib/ynab/models/month_detail.rb +5 -14
  49. data/lib/ynab/models/month_detail_response.rb +3 -2
  50. data/lib/ynab/models/month_detail_response_data.rb +3 -2
  51. data/lib/ynab/models/month_summaries_response.rb +3 -2
  52. data/lib/ynab/models/month_summaries_response_data.rb +3 -2
  53. data/lib/ynab/models/month_summary.rb +5 -14
  54. data/lib/ynab/models/payee.rb +4 -8
  55. data/lib/ynab/models/payee_location.rb +3 -2
  56. data/lib/ynab/models/payee_location_response.rb +3 -2
  57. data/lib/ynab/models/payee_location_response_data.rb +3 -2
  58. data/lib/ynab/models/payee_locations_response.rb +3 -2
  59. data/lib/ynab/models/payee_locations_response_data.rb +3 -2
  60. data/lib/ynab/models/payee_response.rb +3 -2
  61. data/lib/ynab/models/payee_response_data.rb +3 -2
  62. data/lib/ynab/models/payees_response.rb +3 -2
  63. data/lib/ynab/models/payees_response_data.rb +3 -2
  64. data/lib/ynab/models/save_category_response.rb +3 -2
  65. data/lib/ynab/models/save_category_response_data.rb +3 -2
  66. data/lib/ynab/models/save_month_category.rb +3 -2
  67. data/lib/ynab/models/save_month_category_wrapper.rb +3 -2
  68. data/lib/ynab/models/save_sub_transaction.rb +259 -0
  69. data/lib/ynab/models/save_transaction.rb +23 -10
  70. data/lib/ynab/models/save_transaction_wrapper.rb +3 -2
  71. data/lib/ynab/models/save_transactions_response.rb +3 -2
  72. data/lib/ynab/models/save_transactions_response_data.rb +4 -3
  73. data/lib/ynab/models/save_transactions_wrapper.rb +3 -2
  74. data/lib/ynab/models/scheduled_sub_transaction.rb +3 -22
  75. data/lib/ynab/models/scheduled_transaction_detail.rb +3 -37
  76. data/lib/ynab/models/scheduled_transaction_response.rb +3 -2
  77. data/lib/ynab/models/scheduled_transaction_response_data.rb +3 -2
  78. data/lib/ynab/models/scheduled_transaction_summary.rb +3 -27
  79. data/lib/ynab/models/scheduled_transactions_response.rb +3 -2
  80. data/lib/ynab/models/scheduled_transactions_response_data.rb +3 -2
  81. data/lib/ynab/models/sub_transaction.rb +22 -23
  82. data/lib/ynab/models/transaction_detail.rb +3 -52
  83. data/lib/ynab/models/transaction_response.rb +3 -2
  84. data/lib/ynab/models/transaction_response_data.rb +3 -2
  85. data/lib/ynab/models/transaction_summary.rb +3 -42
  86. data/lib/ynab/models/transactions_import_response.rb +189 -0
  87. data/lib/ynab/models/transactions_import_response_data.rb +192 -0
  88. data/lib/ynab/models/transactions_response.rb +3 -2
  89. data/lib/ynab/models/transactions_response_data.rb +3 -2
  90. data/lib/ynab/models/update_transaction.rb +415 -0
  91. data/lib/ynab/models/update_transactions_wrapper.rb +191 -0
  92. data/lib/ynab/models/user.rb +3 -2
  93. data/lib/ynab/models/user_response.rb +3 -2
  94. data/lib/ynab/models/user_response_data.rb +3 -2
  95. data/lib/ynab/version.rb +1 -1
  96. data/spec/api/transactions_spec.rb +11 -0
  97. data/spec/fixtures/vcr_cassettes/import_transactions.yml +50 -0
  98. metadata +10 -3
@@ -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 UpdateTransactionsWrapper
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<UpdateTransaction>'
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
+
86
+ # Builds the object from hash
87
+ # @param [Hash] attributes Model attributes in the form of hash
88
+ # @return [Object] Returns the model itself
89
+ def build_from_hash(attributes)
90
+ return nil unless attributes.is_a?(Hash)
91
+ self.class.swagger_types.each_pair do |key, type|
92
+ if type =~ /\AArray<(.*)>/i
93
+ # check to ensure the input is an array given that the attribute
94
+ # is documented as an array but the input is not
95
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
96
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
97
+ end
98
+ elsif !attributes[self.class.attribute_map[key]].nil?
99
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
100
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
101
+ end
102
+
103
+ self
104
+ end
105
+
106
+ # Deserializes the data based on type
107
+ # @param string type Data type
108
+ # @param string value Value to be deserialized
109
+ # @return [Object] Deserialized data
110
+ def _deserialize(type, value)
111
+ case type.to_sym
112
+ when :DateTime
113
+ DateTime.parse(value)
114
+ when :Date
115
+ Date.parse(value)
116
+ when :String
117
+ value.to_s
118
+ when :Integer
119
+ value.to_i
120
+ when :Float
121
+ value.to_f
122
+ when :BOOLEAN
123
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
124
+ true
125
+ else
126
+ false
127
+ end
128
+ when :Object
129
+ # generic object (usually a Hash), return directly
130
+ value
131
+ when /\AArray<(?<inner_type>.+)>\z/
132
+ inner_type = Regexp.last_match[:inner_type]
133
+ value.map { |v| _deserialize(inner_type, v) }
134
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
135
+ k_type = Regexp.last_match[:k_type]
136
+ v_type = Regexp.last_match[:v_type]
137
+ {}.tap do |hash|
138
+ value.each do |k, v|
139
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
140
+ end
141
+ end
142
+ else # model
143
+ temp_model = YNAB.const_get(type).new
144
+ temp_model.build_from_hash(value)
145
+ end
146
+ end
147
+
148
+ # Returns the string representation of the object
149
+ # @return [String] String presentation of the object
150
+ def to_s
151
+ to_hash.to_s
152
+ end
153
+
154
+ # to_body is an alias to to_hash (backward compatibility)
155
+ # @return [Hash] Returns the object in the form of hash
156
+ def to_body
157
+ to_hash
158
+ end
159
+
160
+ # Returns the object in the form of hash
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_hash
163
+ hash = {}
164
+ self.class.attribute_map.each_pair do |attr, param|
165
+ value = self.send(attr)
166
+ next if value.nil?
167
+ hash[param] = _to_hash(value)
168
+ end
169
+ hash
170
+ end
171
+
172
+ # Outputs non-array value in the form of hash
173
+ # For object, use to_hash. Otherwise, just return the value
174
+ # @param [Object] value Any valid value
175
+ # @return [Hash] Returns the value in the form of hash
176
+ def _to_hash(value)
177
+ if value.is_a?(Array)
178
+ value.compact.map { |v| _to_hash(v) }
179
+ elsif value.is_a?(Hash)
180
+ {}.tap do |hash|
181
+ value.each { |k, v| hash[k] = _to_hash(v) }
182
+ end
183
+ elsif value.respond_to? :to_hash
184
+ value.to_hash
185
+ else
186
+ value
187
+ end
188
+ end
189
+
190
+ end
191
+ end
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -88,7 +88,7 @@ module YNAB
88
88
  return nil unless attributes.is_a?(Hash)
89
89
  self.class.swagger_types.each_pair do |key, type|
90
90
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
91
+ # check to ensure the input is an array given that the attribute
92
92
  # is documented as an array but the input is not
93
93
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
94
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +184,6 @@ module YNAB
184
184
  value
185
185
  end
186
186
  end
187
+
187
188
  end
188
189
  end
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -88,7 +88,7 @@ module YNAB
88
88
  return nil unless attributes.is_a?(Hash)
89
89
  self.class.swagger_types.each_pair do |key, type|
90
90
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
91
+ # check to ensure the input is an array given that the attribute
92
92
  # is documented as an array but the input is not
93
93
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
94
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +184,6 @@ module YNAB
184
184
  value
185
185
  end
186
186
  end
187
+
187
188
  end
188
189
  end
@@ -6,7 +6,7 @@
6
6
  OpenAPI spec version: 1.0.0
7
7
 
8
8
  Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.4.0-SNAPSHOT
9
+ Swagger Codegen version: 2.4.14
10
10
 
11
11
  =end
12
12
 
@@ -88,7 +88,7 @@ module YNAB
88
88
  return nil unless attributes.is_a?(Hash)
89
89
  self.class.swagger_types.each_pair do |key, type|
90
90
  if type =~ /\AArray<(.*)>/i
91
- # check to ensure the input is an array given that the the attribute
91
+ # check to ensure the input is an array given that the attribute
92
92
  # is documented as an array but the input is not
93
93
  if attributes[self.class.attribute_map[key]].is_a?(Array)
94
94
  self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
@@ -184,5 +184,6 @@ module YNAB
184
184
  value
185
185
  end
186
186
  end
187
+
187
188
  end
188
189
  end
@@ -11,5 +11,5 @@ Swagger Codegen version: 2.4.0-SNAPSHOT
11
11
  =end
12
12
 
13
13
  module YNAB
14
- VERSION = '1.13.0'
14
+ VERSION = '1.18.0'
15
15
  end
@@ -188,6 +188,17 @@ describe 'transactions' do
188
188
  end
189
189
  end
190
190
 
191
+ describe 'POST /budgets/{budget_id}/transactions/import' do
192
+ it "import transactions" do
193
+ VCR.use_cassette("import_transactions") do
194
+ response = instance.import_transactions(budget_id)
195
+ expect(client.last_request.response.options[:code]).to be 201
196
+ expect(response.data.transaction_ids.length).to eq 1
197
+ expect(response.data.transaction_ids).to include '07b68f11-98bd-4184-8866-83268a654318'
198
+ end
199
+ end
200
+ end
201
+
191
202
  describe 'POST /budgets/{budget_id}/transactions/bulk' do
192
203
  it "bulk creations transactions" do
193
204
  VCR.use_cassette("bulk_transactions") do
@@ -0,0 +1,50 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/transactions/import
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - api_client/ruby/1.17.0
12
+ Content-Type:
13
+ - application/json
14
+ Accept:
15
+ - application/json
16
+ Authorization:
17
+ - Bearer 9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045
18
+ Expect:
19
+ - ''
20
+ response:
21
+ status:
22
+ code: 201
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ X-Content-Type-Options:
28
+ - nosniff
29
+ X-Frame-Options:
30
+ - deny
31
+ Vary:
32
+ - Accept-Encoding, Origin
33
+ ETag:
34
+ - W/"59dad611fef6101f6355d263fe3c332d"
35
+ Cache-Control:
36
+ - max-age=0, private, must-revalidate
37
+ X-Request-Id:
38
+ - b9d42c37-15d3-4c4c-98d3-7b33da03a745
39
+ X-Runtime:
40
+ - '0.518840'
41
+ Transfer-Encoding:
42
+ - chunked
43
+ body:
44
+ encoding: UTF-8
45
+ string: '{"data":{"transaction_ids":["07b68f11-98bd-4184-8866-83268a654318"]}}'
46
+ http_version: '1.1'
47
+ adapter_metadata:
48
+ effective_url: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/transactions/import
49
+ recorded_at: Tue, 28 Apr 2020 19:10:16 GMT
50
+ recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ynab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.18.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - You Need A Budget, LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-06 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -165,6 +165,7 @@ files:
165
165
  - lib/ynab/models/save_category_response_data.rb
166
166
  - lib/ynab/models/save_month_category.rb
167
167
  - lib/ynab/models/save_month_category_wrapper.rb
168
+ - lib/ynab/models/save_sub_transaction.rb
168
169
  - lib/ynab/models/save_transaction.rb
169
170
  - lib/ynab/models/save_transaction_wrapper.rb
170
171
  - lib/ynab/models/save_transactions_response.rb
@@ -182,8 +183,12 @@ files:
182
183
  - lib/ynab/models/transaction_response.rb
183
184
  - lib/ynab/models/transaction_response_data.rb
184
185
  - lib/ynab/models/transaction_summary.rb
186
+ - lib/ynab/models/transactions_import_response.rb
187
+ - lib/ynab/models/transactions_import_response_data.rb
185
188
  - lib/ynab/models/transactions_response.rb
186
189
  - lib/ynab/models/transactions_response_data.rb
190
+ - lib/ynab/models/update_transaction.rb
191
+ - lib/ynab/models/update_transactions_wrapper.rb
187
192
  - lib/ynab/models/user.rb
188
193
  - lib/ynab/models/user_response.rb
189
194
  - lib/ynab/models/user_response_data.rb
@@ -211,6 +216,7 @@ files:
211
216
  - spec/fixtures/vcr_cassettes/category_transactions.yml
212
217
  - spec/fixtures/vcr_cassettes/create_transaction.yml
213
218
  - spec/fixtures/vcr_cassettes/create_transactions.yml
219
+ - spec/fixtures/vcr_cassettes/import_transactions.yml
214
220
  - spec/fixtures/vcr_cassettes/month.yml
215
221
  - spec/fixtures/vcr_cassettes/months.yml
216
222
  - spec/fixtures/vcr_cassettes/months_unauthorized.yml
@@ -251,7 +257,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
257
  - !ruby/object:Gem::Version
252
258
  version: '0'
253
259
  requirements: []
254
- rubygems_version: 3.0.4
260
+ rubygems_version: 3.0.3
255
261
  signing_key:
256
262
  specification_version: 4
257
263
  summary: YNAB API Endpoints Ruby Gem
@@ -283,6 +289,7 @@ test_files:
283
289
  - spec/fixtures/vcr_cassettes/payee.yml
284
290
  - spec/fixtures/vcr_cassettes/payee_location.yml
285
291
  - spec/fixtures/vcr_cassettes/update_transactions.yml
292
+ - spec/fixtures/vcr_cassettes/import_transactions.yml
286
293
  - spec/fixtures/vcr_cassettes/bulk_transactions.yml
287
294
  - spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml
288
295
  - spec/fixtures/vcr_cassettes/payees.yml