omni_exchange 1.1.1 → 1.2.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: 23f8e6cc867244781c587d8ba217e373dabd00c5bf78710b673d8e6f4b330cb0
4
- data.tar.gz: fffb0e30a3bb6f953ff6a38afcf821023f0e9f898c91448c29e2a6697153bf5d
3
+ metadata.gz: 79069dcd87cf3788896dbc2093d114028b94592743a5fea03559cfce974b4d5c
4
+ data.tar.gz: 03a24de2dcfe6dca9ee1c0532e40b8bab6addbc14c9e4863ef644789a0a24adb
5
5
  SHA512:
6
- metadata.gz: a4fe1ff6099ab9d3662f3a4881303e6c3c7d380cfc49c559c09ca39f1a5a918e381fb017c45cb9552e4b7dd35f8c7f52beaa2762898eb84e43e737aa59f7999e
7
- data.tar.gz: 67d7ae42c4ff478a18669cbbed4ac9c99ac81947402e671e8fec1f072d7e3eeacaf46f18b4570e23b675a7dd34c1ff44b34c051c947aa6a2766e50fc3531755e
6
+ metadata.gz: bb380807a18d884f6ebef61b911e9a5301f6704577a15b8b4fc75cc11a4e0337ee1c911ea01c9a8269f919f6df62f86225cc9270bf24c8cad753eed0cefa8e2d
7
+ data.tar.gz: f0909dabbacc96857512b405cc590431ca9df724f622d0e59d589c62e2856e2d6193e992370f4a06d52df2eff7c3f6d1acca1741f5d6c12c9be20c9736b6eef0
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ sandbox.rb
17
17
  omni_exchange-0.1.0.gem
18
18
  omni_exchange-0.2.0.gem
19
19
  omni_exchange-1.1.0.gem
20
+ omni_exchange-1.1.1.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- omni_exchange (1.1.1)
4
+ omni_exchange (1.2.0)
5
5
  faraday (= 0.17.4)
6
6
  money (~> 6.13.1)
7
7
 
@@ -8,4 +8,8 @@ module OmniExchange
8
8
  # A custom error for failure to get data from a provider
9
9
  class HttpError < StandardError
10
10
  end
11
+
12
+ # A custom error for exceeding the monthly request limit for xe.com
13
+ class XeMonthlyLimit < StandardError
14
+ end
11
15
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # rubocop:disable Metrics/AbcSize
3
4
  require 'omni_exchange'
4
5
 
5
6
  module OmniExchange
@@ -36,7 +37,11 @@ module OmniExchange
36
37
  raise e.class, 'xe.com has timed out.'
37
38
  end
38
39
 
39
- JSON.parse(response.body, symbolize_names: true)[:to][0][:mid].to_d
40
+ body = JSON.parse(response.body, symbolize_names: true)
41
+
42
+ raise OmniExchange::XeMonthlyLimit, 'Xe.com monthly limit has been exceeded' if body[:code] == 3
43
+
44
+ body[:to][0][:mid].to_d
40
45
  end
41
46
 
42
47
  # when this file is required at the top of lib/omni_exchange.rb, this method call is run and allows
@@ -44,3 +49,4 @@ module OmniExchange
44
49
  OmniExchange::Provider.register_provider(:xe, self)
45
50
  end
46
51
  end
52
+ # rubocop:enable Metrics/AbcSize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OmniExchange
4
- VERSION = '1.1.1'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/omni_exchange.rb CHANGED
@@ -74,7 +74,7 @@ module OmniExchange
74
74
  exchanged_amount = rate.to_d * amount.to_d
75
75
 
76
76
  return { converted_amount: exchanged_amount, exchange_rate: rate, provider_class: klass }
77
- rescue Faraday::Error, Faraday::ConnectionFailed => e
77
+ rescue Faraday::Error, Faraday::ConnectionFailed, OmniExchange::XeMonthlyLimit => e
78
78
  error_messages << e.inspect
79
79
  end
80
80
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omni_exchange
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yun Chung
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-04 00:00:00.000000000 Z
11
+ date: 2022-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday