ynab 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module YnabApi
19
19
 
20
20
  attr_accessor :transaction_id
21
21
 
22
- # The sub-transaction amount in milliunits format
22
+ # The subtransaction amount in milliunits format
23
23
  attr_accessor :amount
24
24
 
25
25
  attr_accessor :memo
@@ -44,7 +44,11 @@ module YnabApi
44
44
  # 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'.
45
45
  attr_accessor :import_id
46
46
 
47
- # If a split transaction, the sub-transactions.
47
+ attr_accessor :payee_name
48
+
49
+ attr_accessor :category_name
50
+
51
+ # If a split transaction, the subtransactions.
48
52
  attr_accessor :subtransactions
49
53
 
50
54
  class EnumAttributeValidator
@@ -84,6 +88,8 @@ module YnabApi
84
88
  :'category_id' => :'category_id',
85
89
  :'transfer_account_id' => :'transfer_account_id',
86
90
  :'import_id' => :'import_id',
91
+ :'payee_name' => :'payee_name',
92
+ :'category_name' => :'category_name',
87
93
  :'subtransactions' => :'subtransactions'
88
94
  }
89
95
  end
@@ -103,6 +109,8 @@ module YnabApi
103
109
  :'category_id' => :'String',
104
110
  :'transfer_account_id' => :'String',
105
111
  :'import_id' => :'String',
112
+ :'payee_name' => :'String',
113
+ :'category_name' => :'String',
106
114
  :'subtransactions' => :'Array<SubTransaction>'
107
115
  }
108
116
  end
@@ -163,6 +171,14 @@ module YnabApi
163
171
  self.import_id = attributes[:'import_id']
164
172
  end
165
173
 
174
+ if attributes.has_key?(:'payee_name')
175
+ self.payee_name = attributes[:'payee_name']
176
+ end
177
+
178
+ if attributes.has_key?(:'category_name')
179
+ self.category_name = attributes[:'category_name']
180
+ end
181
+
166
182
  if attributes.has_key?(:'subtransactions')
167
183
  if (value = attributes[:'subtransactions']).is_a?(Array)
168
184
  self.subtransactions = value
@@ -223,6 +239,14 @@ module YnabApi
223
239
  invalid_properties.push("invalid value for 'import_id', import_id cannot be nil.")
224
240
  end
225
241
 
242
+ if @payee_name.nil?
243
+ invalid_properties.push("invalid value for 'payee_name', payee_name cannot be nil.")
244
+ end
245
+
246
+ if @category_name.nil?
247
+ invalid_properties.push("invalid value for 'category_name', category_name cannot be nil.")
248
+ end
249
+
226
250
  if @subtransactions.nil?
227
251
  invalid_properties.push("invalid value for 'subtransactions', subtransactions cannot be nil.")
228
252
  end
@@ -249,6 +273,8 @@ module YnabApi
249
273
  return false if @category_id.nil?
250
274
  return false if @transfer_account_id.nil?
251
275
  return false if @import_id.nil?
276
+ return false if @payee_name.nil?
277
+ return false if @category_name.nil?
252
278
  return false if @subtransactions.nil?
253
279
  return true
254
280
  end
@@ -290,6 +316,8 @@ module YnabApi
290
316
  category_id == o.category_id &&
291
317
  transfer_account_id == o.transfer_account_id &&
292
318
  import_id == o.import_id &&
319
+ payee_name == o.payee_name &&
320
+ category_name == o.category_name &&
293
321
  subtransactions == o.subtransactions
294
322
  end
295
323
 
@@ -302,7 +330,7 @@ module YnabApi
302
330
  # Calculates hash code according to all attributes.
303
331
  # @return [Fixnum] Hash code
304
332
  def hash
305
- [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, import_id, subtransactions].hash
333
+ [id, date, amount, memo, cleared, approved, flag_color, account_id, payee_id, category_id, transfer_account_id, import_id, payee_name, category_name, subtransactions].hash
306
334
  end
307
335
 
308
336
  # Builds the object from hash
data/lib/ynab/version.rb CHANGED
@@ -11,5 +11,5 @@ Swagger Codegen version: 2.3.1
11
11
  =end
12
12
 
13
13
  module YnabApi
14
- VERSION = "0.4.0"
14
+ VERSION = "0.5.0"
15
15
  end
data/spec-v1-swagger.json CHANGED
@@ -869,7 +869,7 @@
869
869
  "200": {
870
870
  "description": "The list of requested Transactions.",
871
871
  "schema": {
872
- "$ref": "#/definitions/TransactionsResponse"
872
+ "$ref": "#/definitions/HybridTransactionsResponse"
873
873
  }
874
874
  },
875
875
  "404": {
@@ -924,7 +924,7 @@
924
924
  "200": {
925
925
  "description": "The list of requested Transactions.",
926
926
  "schema": {
927
- "$ref": "#/definitions/TransactionsResponse"
927
+ "$ref": "#/definitions/HybridTransactionsResponse"
928
928
  }
929
929
  },
930
930
  "404": {
@@ -1276,6 +1276,7 @@
1276
1276
  "$ref": "#/definitions/BudgetSummary"
1277
1277
  },
1278
1278
  {
1279
+ "type": "object",
1279
1280
  "properties": {
1280
1281
  "accounts": {
1281
1282
  "type": "array",
@@ -1510,6 +1511,7 @@
1510
1511
  "$ref": "#/definitions/CategoryGroup"
1511
1512
  },
1512
1513
  {
1514
+ "type": "object",
1513
1515
  "required": ["categories"],
1514
1516
  "properties": {
1515
1517
  "categories": {
@@ -1705,6 +1707,27 @@
1705
1707
  }
1706
1708
  }
1707
1709
  },
1710
+ "HybridTransactionsResponse": {
1711
+ "type": "object",
1712
+ "required": ["data"],
1713
+ "properties": {
1714
+ "data": {
1715
+ "$ref": "#/definitions/HybridTransactionsWrapper"
1716
+ }
1717
+ }
1718
+ },
1719
+ "HybridTransactionsWrapper": {
1720
+ "type": "object",
1721
+ "required": ["transactions"],
1722
+ "properties": {
1723
+ "transactions": {
1724
+ "type": "array",
1725
+ "items": {
1726
+ "$ref": "#/definitions/HybridTransaction"
1727
+ }
1728
+ }
1729
+ }
1730
+ },
1708
1731
  "TransactionResponse": {
1709
1732
  "type": "object",
1710
1733
  "required": ["data"],
@@ -1799,11 +1822,18 @@
1799
1822
  "$ref": "#/definitions/TransactionSummary"
1800
1823
  },
1801
1824
  {
1802
- "required": ["subtransactions"],
1825
+ "type": "object",
1826
+ "required": ["payee_name", "category_name", "subtransactions"],
1803
1827
  "properties": {
1828
+ "payee_name": {
1829
+ "type": "string"
1830
+ },
1831
+ "category_name": {
1832
+ "type": "string"
1833
+ },
1804
1834
  "subtransactions": {
1805
1835
  "type": "array",
1806
- "description": "If a split transaction, the sub-transactions.",
1836
+ "description": "If a split transaction, the subtransactions.",
1807
1837
  "items": {
1808
1838
  "$ref": "#/definitions/SubTransaction"
1809
1839
  }
@@ -1812,6 +1842,31 @@
1812
1842
  }
1813
1843
  ]
1814
1844
  },
1845
+ "HybridTransaction": {
1846
+ "allOf": [
1847
+ {
1848
+ "$ref": "#/definitions/TransactionSummary"
1849
+ },
1850
+ {
1851
+ "type": "object",
1852
+ "required": ["type", "parent_transaction_id"],
1853
+ "properties": {
1854
+ "type": {
1855
+ "type": "string",
1856
+ "enum": ["transaction", "subtransaction"],
1857
+ "description":
1858
+ "Whether the hybrid transaction represents a regular transaction or a subtransaction"
1859
+ },
1860
+ "parent_transaction_id": {
1861
+ "type": "string",
1862
+ "format": "uuid",
1863
+ "description":
1864
+ "For subtransaction types, this is the id of the pararent transaction. For transaction types, this id will be always be null."
1865
+ }
1866
+ }
1867
+ }
1868
+ ]
1869
+ },
1815
1870
  "SaveTransactionWrapper": {
1816
1871
  "type": "object",
1817
1872
  "required": ["transaction"],
@@ -1954,7 +2009,7 @@
1954
2009
  "amount": {
1955
2010
  "type": "number",
1956
2011
  "format": "1234000",
1957
- "description": "The sub-transaction amount in milliunits format"
2012
+ "description": "The subtransaction amount in milliunits format"
1958
2013
  },
1959
2014
  "memo": {
1960
2015
  "type": "string"
@@ -2103,12 +2158,27 @@
2103
2158
  "$ref": "#/definitions/ScheduledTransactionSummary"
2104
2159
  },
2105
2160
  {
2106
- "required": ["subtransactions"],
2161
+ "type": "object",
2162
+ "required": [
2163
+ "account_name",
2164
+ "payee_name",
2165
+ "category_name",
2166
+ "subtransactions"
2167
+ ],
2107
2168
  "properties": {
2169
+ "account_name": {
2170
+ "type": "string"
2171
+ },
2172
+ "payee_name": {
2173
+ "type": "string"
2174
+ },
2175
+ "category_name": {
2176
+ "type": "string"
2177
+ },
2108
2178
  "subtransactions": {
2109
2179
  "type": "array",
2110
2180
  "description":
2111
- "If a split scheduled transaction, the sub-transactions.",
2181
+ "If a split scheduled transaction, the subtransactions.",
2112
2182
  "items": {
2113
2183
  "$ref": "#/definitions/ScheduledSubTransaction"
2114
2184
  }
@@ -2141,7 +2211,7 @@
2141
2211
  "type": "number",
2142
2212
  "format": "1234000",
2143
2213
  "description":
2144
- "The scheduled sub-transaction amount in milliunits format"
2214
+ "The scheduled subtransaction amount in milliunits format"
2145
2215
  },
2146
2216
  "memo": {
2147
2217
  "type": "string"
@@ -2229,6 +2299,7 @@
2229
2299
  "$ref": "#/definitions/MonthSummary"
2230
2300
  },
2231
2301
  {
2302
+ "type": "object",
2232
2303
  "required": ["categories"],
2233
2304
  "properties": {
2234
2305
  "categories": {
@@ -4,6 +4,8 @@ require 'pp'
4
4
  describe 'transactions' do
5
5
  let(:access_token) { '9f1a2c4842b614a771aaae9220fc54ae835e298c4654dc2c9205fc1d7bd1a045' }
6
6
  let(:budget_id) { 'f419ac25-6217-4175-88dc-c3136ff5f6fd' }
7
+ let(:category_id) { '84ffe61c-081c-44db-ad23-6ee809206c40' }
8
+ let(:payee_id) { '2676f959-c5de-4db2-8d3f-2503777b25fb' }
7
9
  let(:client) { YnabApi::Client.new(access_token, 'api.localhost:3000', false) }
8
10
  let (:instance) { client.transactions }
9
11
 
@@ -45,8 +47,28 @@ describe 'transactions' do
45
47
  end
46
48
  end
47
49
 
48
- describe 'GET /budgets/{budget_id}/transaction/{payee_id}' do
49
- it "returns a payee" do
50
+ describe 'GET /budgets/{budget_id}/category/{category_id}/transactions' do
51
+ it "returns a list of transactions for a category" do
52
+ VCR.use_cassette("category_transactions") do
53
+ response = instance.get_transactions_by_category(budget_id, category_id)
54
+ expect(client.last_request.response.options[:code]).to be 200
55
+ expect(response.data.transactions.length).to be 3
56
+ end
57
+ end
58
+ end
59
+
60
+ describe 'GET /budgets/{budget_id}/category/{payee_id}/transactions' do
61
+ it "returns a list of transactions for a payee" do
62
+ VCR.use_cassette("payee_transactions") do
63
+ response = instance.get_transactions_by_payee(budget_id, payee_id)
64
+ expect(client.last_request.response.options[:code]).to be 200
65
+ expect(response.data.transactions.length).to be 2
66
+ end
67
+ end
68
+ end
69
+
70
+ describe 'GET /budgets/{budget_id}/transaction/{transaction_id}' do
71
+ it "returns a transaction" do
50
72
  VCR.use_cassette("transaction") do
51
73
  response = instance.get_transactions_by_id(budget_id, '81c374ff-74ab-4d6d-8d5a-ba3ad3fa68e4')
52
74
  expect(response.data.transaction).to be
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/categories/84ffe61c-081c-44db-ad23-6ee809206c40/transactions
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - api_client/ruby/0.4.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: 200
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Vary:
28
+ - Accept-Encoding, Origin
29
+ ETag:
30
+ - W/"34c52d2665519c44aa89bfb862b99e7e"
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - 0e4f8e02-620d-4433-8a88-f776fdafc165
35
+ X-Runtime:
36
+ - '0.376111'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"data":{"transactions":[{"type":"subtransaction","id":"4a675c31-f5f1-43ba-8c9a-6cd7d5b0cac4","parent_transaction_id":"56a3ae86-ce55-4e23-923b-6cb59add860b","date":"2018-03-26","amount":-50000,"memo":"","cleared":"uncleared","approved":true,"flag_color":null,"account_id":"16addaa3-cfaf-4e57-933c-7e1645f000f0","payee_id":null,"category_id":"84ffe61c-081c-44db-ad23-6ee809206c40","transfer_account_id":null,"import_id":null},{"type":"subtransaction","id":"4c3f5877-b4b9-4d5a-9177-be7dfcd86c6e","parent_transaction_id":"910a79e1-29f5-4789-a2a0-2a69c2f94a2b","date":"2018-03-26","amount":-25000,"memo":"","cleared":"uncleared","approved":true,"flag_color":null,"account_id":"16addaa3-cfaf-4e57-933c-7e1645f000f0","payee_id":null,"category_id":"84ffe61c-081c-44db-ad23-6ee809206c40","transfer_account_id":null,"import_id":null},{"type":"transaction","id":"d477e91a-1f2b-4df5-8069-6b61dee51259","parent_transaction_id":null,"date":"2018-03-27","amount":-13000,"memo":"","cleared":"uncleared","approved":true,"flag_color":null,"account_id":"16addaa3-cfaf-4e57-933c-7e1645f000f0","payee_id":"2676f959-c5de-4db2-8d3f-2503777b25fb","category_id":"84ffe61c-081c-44db-ad23-6ee809206c40","transfer_account_id":null,"import_id":null}]}}'
42
+ http_version: '1.1'
43
+ adapter_metadata:
44
+ effective_url: http://api.localhost:3000/v1/budgets/6e6aa585-8537-4afc-950f-93d55fac17fa/categories/84ffe61c-081c-44db-ad23-6ee809206c40/transactions
45
+ recorded_at: Tue, 27 Mar 2018 17:02:30 GMT
46
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,46 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/payees/2676f959-c5de-4db2-8d3f-2503777b25fb/transactions
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - api_client/ruby/0.4.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: 200
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ Vary:
28
+ - Accept-Encoding, Origin
29
+ ETag:
30
+ - W/"d2b4b29be1231be9847defe032df6712"
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - b79f3971-7666-4b04-8d8b-bd5258dd02bc
35
+ X-Runtime:
36
+ - '0.186443'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"data":{"transactions":[{"type":"subtransaction","id":"008908a3-07c2-4684-b4c1-6f1024814f8d","parent_transaction_id":"910a79e1-29f5-4789-a2a0-2a69c2f94a2b","date":"2018-03-26","amount":-15000,"memo":"","cleared":"uncleared","approved":true,"flag_color":null,"account_id":"16addaa3-cfaf-4e57-933c-7e1645f000f0","payee_id":"2676f959-c5de-4db2-8d3f-2503777b25fb","category_id":"b457e34a-234e-40b2-992e-40055171e644","transfer_account_id":null,"import_id":null},{"type":"transaction","id":"d477e91a-1f2b-4df5-8069-6b61dee51259","parent_transaction_id":null,"date":"2018-03-27","amount":-13000,"memo":"","cleared":"uncleared","approved":true,"flag_color":null,"account_id":"16addaa3-cfaf-4e57-933c-7e1645f000f0","payee_id":"2676f959-c5de-4db2-8d3f-2503777b25fb","category_id":"84ffe61c-081c-44db-ad23-6ee809206c40","transfer_account_id":null,"import_id":null}]}}'
42
+ http_version: '1.1'
43
+ adapter_metadata:
44
+ effective_url: http://api.localhost:3000/v1/budgets/6e6aa585-8537-4afc-950f-93d55fac17fa/payees/2676f959-c5de-4db2-8d3f-2503777b25fb/transactions
45
+ recorded_at: Tue, 27 Mar 2018 17:03:22 GMT
46
+ 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: 0.4.0
4
+ version: 0.5.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: 2018-03-22 00:00:00.000000000 Z
11
+ date: 2018-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -134,6 +134,9 @@ files:
134
134
  - docs/DateFormat.md
135
135
  - docs/ErrorDetail.md
136
136
  - docs/ErrorResponse.md
137
+ - docs/HybridTransaction.md
138
+ - docs/HybridTransactionsResponse.md
139
+ - docs/HybridTransactionsWrapper.md
137
140
  - docs/MonthDetail.md
138
141
  - docs/MonthDetailResponse.md
139
142
  - docs/MonthDetailWrapper.md
@@ -219,6 +222,9 @@ files:
219
222
  - lib/ynab/models/date_format.rb
220
223
  - lib/ynab/models/error_detail.rb
221
224
  - lib/ynab/models/error_response.rb
225
+ - lib/ynab/models/hybrid_transaction.rb
226
+ - lib/ynab/models/hybrid_transactions_response.rb
227
+ - lib/ynab/models/hybrid_transactions_wrapper.rb
222
228
  - lib/ynab/models/month_detail.rb
223
229
  - lib/ynab/models/month_detail_response.rb
224
230
  - lib/ynab/models/month_detail_wrapper.rb
@@ -275,6 +281,7 @@ files:
275
281
  - spec/fixtures/vcr_cassettes/categories.yml
276
282
  - spec/fixtures/vcr_cassettes/categories_unauthorized.yml
277
283
  - spec/fixtures/vcr_cassettes/category.yml
284
+ - spec/fixtures/vcr_cassettes/category_transactions.yml
278
285
  - spec/fixtures/vcr_cassettes/create_transaction.yml
279
286
  - spec/fixtures/vcr_cassettes/month.yml
280
287
  - spec/fixtures/vcr_cassettes/months.yml
@@ -283,6 +290,7 @@ files:
283
290
  - spec/fixtures/vcr_cassettes/payee_location.yml
284
291
  - spec/fixtures/vcr_cassettes/payee_locations.yml
285
292
  - spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml
293
+ - spec/fixtures/vcr_cassettes/payee_transactions.yml
286
294
  - spec/fixtures/vcr_cassettes/payees.yml
287
295
  - spec/fixtures/vcr_cassettes/payees_unauthorized.yml
288
296
  - spec/fixtures/vcr_cassettes/scheduled_transaction.yml
@@ -330,6 +338,7 @@ test_files:
330
338
  - spec/api/months_spec.rb
331
339
  - spec/api/transactions_spec.rb
332
340
  - spec/fixtures/.DS_Store
341
+ - spec/fixtures/vcr_cassettes/payee_transactions.yml
333
342
  - spec/fixtures/vcr_cassettes/categories.yml
334
343
  - spec/fixtures/vcr_cassettes/scheduled_transactions.yml
335
344
  - spec/fixtures/vcr_cassettes/accounts_unauthorized.yml
@@ -339,6 +348,7 @@ test_files:
339
348
  - spec/fixtures/vcr_cassettes/payees_unauthorized.yml
340
349
  - spec/fixtures/vcr_cassettes/create_transaction.yml
341
350
  - spec/fixtures/vcr_cassettes/budgets.yml
351
+ - spec/fixtures/vcr_cassettes/category_transactions.yml
342
352
  - spec/fixtures/vcr_cassettes/accounts.yml
343
353
  - spec/fixtures/vcr_cassettes/payee.yml
344
354
  - spec/fixtures/vcr_cassettes/payee_location.yml