ynab 3.5.0 → 3.6.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: dc994f9a63594e32cb1b9c8b13306f18f2733eb431053f8dcfef284f7895403b
4
- data.tar.gz: 9c28e134e2a37ee05170523094f73f92cb4ee1c66bb031b9fa87720211fb8e2c
3
+ metadata.gz: 4e7cc95c27139444ec433935a9fc17e06f771ae4a4d021f4fbecade36387cb18
4
+ data.tar.gz: e7c5352cfdc082da9f48a8a2f66a1b0c174eab6337c6be50e3a16360a4ba1527
5
5
  SHA512:
6
- metadata.gz: dc6b6d5d897605e05ab6b3ecbbf980dabee50e595fb37b2daba30cf4c0374a1b5ab5dfe7292bfd33dcb031f9ff70728201c7de3f49e024dfe3e4a3a93f0adb6e
7
- data.tar.gz: 8fb3ed8420ca14192b5fc275762c28ffce341f611a5010f2f7cc3eb41f4249631c0ec24000877e8e8cf2bf0f45e306061ef93d6191f829456feba5b3125d4bb1
6
+ metadata.gz: ca7f1029e4c876b0d4e877ec7c26de5ed44bf3af089a57171ba299e9de169ad5e5ec53619d667cdb65c41be338654fea9b1529365220ec8e5af353dc758c3193
7
+ data.tar.gz: 51f288bf18cc87fe4ac2994b409eac0396afdc7dcea6e802fed6c3bff3f69a8e16962dd7a04df4eb36bb58940a722382bf9e6382fd5ceb0a74e685adb57d7d53
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ynab (3.4.0)
4
+ ynab (3.5.0)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
@@ -41,8 +41,12 @@ module YNAB
41
41
  # @param [String] The enum value in the form of the string
42
42
  # @return [String] The enum value
43
43
  def build_from_hash(value)
44
- return value if AccountType.all_vars.include?(value)
45
- raise "Invalid ENUM value #{value} for class #AccountType"
44
+ if AccountType.all_vars.include?(value)
45
+ return value
46
+ else
47
+ return nil
48
+ end
46
49
  end
47
50
  end
51
+
48
52
  end
@@ -41,8 +41,12 @@ module YNAB
41
41
  # @param [String] The enum value in the form of the string
42
42
  # @return [String] The enum value
43
43
  def build_from_hash(value)
44
- return value if ScheduledTransactionFrequency.all_vars.include?(value)
45
- raise "Invalid ENUM value #{value} for class #ScheduledTransactionFrequency"
44
+ if ScheduledTransactionFrequency.all_vars.include?(value)
45
+ return value
46
+ else
47
+ return nil
48
+ end
46
49
  end
47
50
  end
51
+
48
52
  end
@@ -31,8 +31,12 @@ module YNAB
31
31
  # @param [String] The enum value in the form of the string
32
32
  # @return [String] The enum value
33
33
  def build_from_hash(value)
34
- return value if TransactionClearedStatus.all_vars.include?(value)
35
- raise "Invalid ENUM value #{value} for class #TransactionClearedStatus"
34
+ if TransactionClearedStatus.all_vars.include?(value)
35
+ return value
36
+ else
37
+ return nil
38
+ end
36
39
  end
37
40
  end
41
+
38
42
  end
@@ -35,8 +35,12 @@ module YNAB
35
35
  # @param [String] The enum value in the form of the string
36
36
  # @return [String] The enum value
37
37
  def build_from_hash(value)
38
- return value if TransactionFlagColor.all_vars.include?(value)
39
- raise "Invalid ENUM value #{value} for class #TransactionFlagColor"
38
+ if TransactionFlagColor.all_vars.include?(value)
39
+ return value
40
+ else
41
+ return nil
42
+ end
40
43
  end
41
44
  end
45
+
42
46
  end
data/lib/ynab/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module YNAB
2
- VERSION = '3.5.0'
2
+ VERSION = '3.6.0'
3
3
  end
@@ -44,6 +44,18 @@ describe 'transactions' do
44
44
  expect(response.data.transactions.length).to be 2
45
45
  end
46
46
  end
47
+
48
+ it 'gracefully handles invalid flag_color values' do
49
+ # transactions_invalid_flags contains transactions with invalid/unsupported flag_color values
50
+ VCR.use_cassette("transactions_invalid_flags") do
51
+ response = instance.get_transactions(budget_id)
52
+ expect(client.last_request.response.options[:code]).to be 200
53
+ expect(response.data.transactions.length).to be 2
54
+ # We expect the flag_color to have been converted to nil for these transactions
55
+ expect(response.data.transactions[0].flag_color).to be_nil
56
+ expect(response.data.transactions[1].flag_color).to be_nil
57
+ end
58
+ end
47
59
  end
48
60
 
49
61
  describe 'GET /budgets/{budget_id}/category/{category_id}/transactions' do
@@ -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/transactions
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - api_client/ruby/0.1.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/"faa32c94f0e94eebee572fe3def08d83"
31
+ Cache-Control:
32
+ - max-age=0, private, must-revalidate
33
+ X-Request-Id:
34
+ - d290c58c-2261-4564-a267-5ea1ec878fdf
35
+ X-Runtime:
36
+ - '0.197369'
37
+ Transfer-Encoding:
38
+ - chunked
39
+ body:
40
+ encoding: UTF-8
41
+ string: '{"data":{"transactions":[{"id":"1f9d45f6-8ba5-476b-8cff-209b3791bd83","date":"2018-02-15","amount":1000000,"memo":null,"cleared":"cleared","approved":true,"flag_color":"","account_id":"5982e895-98e5-41ca-9681-0b6de1036a1c","payee_id":"2141b5d8-5b9b-4a17-be45-3f4a9ac397ec","category_id":"26513650-523e-4e7a-ac0d-f6e78d0a8a03","transfer_account_id":null,"import_id":null,"subtransactions":[]},{"id":"81c374ff-74ab-4d6d-8d5a-ba3ad3fa68e4","date":"2018-02-15","amount":-2000,"memo":"","cleared":"uncleared","approved":true,"flag_color":"invalid","account_id":"5982e895-98e5-41ca-9681-0b6de1036a1c","payee_id":"200e6eb1-02fc-4af6-be26-27c5740bb949","category_id":null,"transfer_account_id":null,"import_id":null,"subtransactions":[]}]}}'
42
+ http_version: '1.1'
43
+ adapter_metadata:
44
+ effective_url: http://api.localhost:3000/v1/budgets/f419ac25-6217-4175-88dc-c3136ff5f6fd/transactions
45
+ recorded_at: Thu, 15 Feb 2018 19:00:01 GMT
46
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,26 @@
1
+ class {{classname}}{{#allowableValues}}{{#enumVars}}
2
+ {{{name}}} = {{{value}}}.freeze{{/enumVars}}
3
+
4
+ {{/allowableValues}}
5
+ def self.all_vars
6
+ @all_vars ||= [{{#allowableValues}}{{#enumVars}}{{{name}}}{{^-last}}, {{/-last}}{{/enumVars}}{{/allowableValues}}].freeze
7
+ end
8
+
9
+ # Builds the enum from string
10
+ # @param [String] The enum value in the form of the string
11
+ # @return [String] The enum value
12
+ def self.build_from_hash(value)
13
+ new.build_from_hash(value)
14
+ end
15
+
16
+ # Builds the enum from string
17
+ # @param [String] The enum value in the form of the string
18
+ # @return [String] The enum value
19
+ def build_from_hash(value)
20
+ if {{classname}}.all_vars.include?(value)
21
+ return value
22
+ else
23
+ return nil
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ynab
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.0
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YNAB
@@ -65,7 +65,6 @@ files:
65
65
  - LICENSE.md
66
66
  - README.md
67
67
  - Rakefile
68
- - config.json
69
68
  - config.yaml
70
69
  - docs/Account.md
71
70
  - docs/AccountResponse.md
@@ -333,6 +332,7 @@ files:
333
332
  - spec/fixtures/vcr_cassettes/scheduled_transactions_unauthorized.yml
334
333
  - spec/fixtures/vcr_cassettes/transaction.yml
335
334
  - spec/fixtures/vcr_cassettes/transactions.yml
335
+ - spec/fixtures/vcr_cassettes/transactions_invalid_flags.yml
336
336
  - spec/fixtures/vcr_cassettes/transactions_unauthorized.yml
337
337
  - spec/fixtures/vcr_cassettes/update_transaction.yml
338
338
  - spec/fixtures/vcr_cassettes/update_transactions.yml
@@ -345,6 +345,7 @@ files:
345
345
  - templates/api_info.mustache
346
346
  - templates/gem.mustache
347
347
  - templates/gemspec.mustache
348
+ - templates/partial_model_enum_class.mustache
348
349
  - templates/partial_model_generic.mustache
349
350
  - templates/partial_model_generic_doc.mustache
350
351
  - ynab.gemspec
@@ -401,6 +402,7 @@ test_files:
401
402
  - spec/fixtures/vcr_cassettes/patch_month_category.yml
402
403
  - spec/fixtures/vcr_cassettes/payee_locations_unauthorized.yml
403
404
  - spec/fixtures/vcr_cassettes/payee_location.yml
405
+ - spec/fixtures/vcr_cassettes/transactions_invalid_flags.yml
404
406
  - spec/fixtures/vcr_cassettes/payee_transactions.yml
405
407
  - spec/fixtures/vcr_cassettes/accounts.yml
406
408
  - spec/fixtures/vcr_cassettes/categories_unauthorized.yml
data/config.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "gemName": "ynab",
3
- "moduleName": "YNAB",
4
- "gemDescription": "Ruby gem wrapper for the YNAB API. Read the documentation at https://api.ynab.com",
5
- "gemHomepage": "https://github.com/ynab/ynab-sdk-ruby",
6
- "gemLicense": "Apache-2.0",
7
- "gemAuthor": "YNAB",
8
- "gemAuthorEmail": "api@ynab.com"
9
- }