money-open-exchange-rates 1.4.0 → 1.4.1

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: 213847dd55f3bbc717a20dc056e61510f4b00ede31bce5b1c7022b16eedc875e
4
- data.tar.gz: e245e87886f4c2fc2d8ae6fcf25c80d5f7797ffc3d877eaafab18abd2f911050
3
+ metadata.gz: a8d1aa20a7e00ad9b92ff6f516af74c9f26a0b4a4cfacdbab246833806976cb7
4
+ data.tar.gz: 61646aab5bbcfb00e362df9f6fe8e0bc80b9ef553a99ac6bfd26fa1c7d8f5c93
5
5
  SHA512:
6
- metadata.gz: 7a63501cb0baad531f152bedc2a232697f9c64da9bfeef9dd576ecbcda9dceaed83aba902f272c5cd4d44af20e9a55bd7654e1c244a60a5620b9db6f033c6f4b
7
- data.tar.gz: 0c5466657cac8fb4e826d7d9e24ac354778eca529ac156385d3dc44070ed78d3e9278ffc2e17ccad705311195fdaa2822d17855cbcd2e721d90cab37ebe1c0c2
6
+ metadata.gz: 61eea8294a9b0b0a311db01d9b792c3831adc1d1711af486f9c43bac434bb5ced1dde20527624f16054e56cda867306bbf43f63dda9a17ef536da302cc77c250
7
+ data.tar.gz: 118f24d214bd24f7264aa575e87de2f04e115ebca9d83ce70c24abdd1cc0d93b2995f192ec760314717bbbed846ab75273ff851812a9fb6fd16a114043f63d76
data/History.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 1.4.1 / 2023-05-07
3
+ ==================
4
+
5
+ * Merge pull request #69 from @fuentesjr / identify-access-restricted-errors
6
+ * Fixing typo in scoping of must_raise in access restricted test
7
+ * Raise a new AccessRestricted error when account is restricted by oer
8
+
2
9
  1.4.0 / 2020-09-11
3
10
  ==================
4
11
 
@@ -17,6 +17,9 @@ class Money
17
17
  # APP_ID not set error
18
18
  class NoAppId < StandardError; end
19
19
 
20
+ # Access restricted (e.g. usage/request limit exceeded for account)
21
+ class AccessRestricted < StandardError; end
22
+
20
23
  # OpenExchangeRatesBank base class
21
24
  class OpenExchangeRatesBank < Money::Bank::VariableExchange
22
25
  VERSION = ::OpenExchangeRatesBank::VERSION
@@ -371,6 +374,10 @@ class Money
371
374
  # @return [Hash] key is country code (ISO 3166-1 alpha-3) value Float
372
375
  def exchange_rates
373
376
  doc = JSON.parse(read_from_cache || read_from_url)
377
+ if doc['error'] && doc['message'] == 'access_restricted'
378
+ raise AccessRestricted
379
+ end
380
+
374
381
  self.rates_timestamp = doc[TIMESTAMP_KEY]
375
382
  @oer_rates = doc[RATES_KEY]
376
383
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Module for version constant
4
4
  module OpenExchangeRatesBank
5
- VERSION = '1.4.0'
5
+ VERSION = '1.4.1'
6
6
  end
@@ -0,0 +1,6 @@
1
+ {
2
+ "error": true,
3
+ "status": 429,
4
+ "message": "access_restricted",
5
+ "description": "Access restricted until 2050-01-01 (reason: too_many_requests). If there has been a mistake, please contact support@openexchangerates.org."
6
+ }
@@ -25,6 +25,9 @@ describe Money::Bank::OpenExchangeRatesBank do
25
25
  let(:oer_historical_path) do
26
26
  data_file('2015-01-01.json')
27
27
  end
28
+ let(:oer_access_restricted_error_path) do
29
+ data_file('access_restricted_error.json')
30
+ end
28
31
 
29
32
  describe 'exchange' do
30
33
  before do
@@ -96,6 +99,13 @@ describe Money::Bank::OpenExchangeRatesBank do
96
99
  subject.update_rates
97
100
  end
98
101
 
102
+ it 'should raise AccessRestricted error when restricted by oer' do
103
+ subject.cache = nil
104
+ filepath = oer_access_restricted_error_path
105
+ subject.stubs(:api_response).returns File.read(filepath)
106
+ _(proc { subject.update_rates }).must_raise Money::Bank::AccessRestricted
107
+ end
108
+
99
109
  it 'should update itself with exchange rates from OpenExchangeRates' do
100
110
  subject.oer_rates.keys.each do |currency|
101
111
  next unless Money::Currency.find(currency)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money-open-exchange-rates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Arnoud
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-11 00:00:00.000000000 Z
11
+ date: 2023-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: money
@@ -143,6 +143,7 @@ files:
143
143
  - lib/money/bank/open_exchange_rates_bank.rb
144
144
  - lib/open_exchange_rates_bank/version.rb
145
145
  - test/data/2015-01-01.json
146
+ - test/data/access_restricted_error.json
146
147
  - test/data/latest.json
147
148
  - test/integration/Gemfile
148
149
  - test/integration/Gemfile.lock
@@ -153,7 +154,7 @@ homepage: http://github.com/spk/money-open-exchange-rates
153
154
  licenses:
154
155
  - MIT
155
156
  metadata: {}
156
- post_install_message:
157
+ post_install_message:
157
158
  rdoc_options: []
158
159
  require_paths:
159
160
  - lib
@@ -168,8 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
169
  - !ruby/object:Gem::Version
169
170
  version: '0'
170
171
  requirements: []
171
- rubygems_version: 3.1.2
172
- signing_key:
172
+ rubygems_version: 3.3.15
173
+ signing_key:
173
174
  specification_version: 4
174
175
  summary: A gem that calculates the exchange rate using published rates from open-exchange-rates.
175
176
  test_files: