Skip to content

Commit

Permalink
Merge pull request #2074 from sopel-irc/another-currency-api-bites-th…
Browse files Browse the repository at this point in the history
…e-dust

currency: switch default to exchangerate.host; remove ratesapi.io
  • Loading branch information
dgw authored May 26, 2021
2 parents b6fb3b3 + b02cc85 commit 12f8640
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 70 deletions.
3 changes: 1 addition & 2 deletions sopel/modules/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
FIAT_PROVIDERS = {
'exchangerate.host': 'https://api.exchangerate.host/latest?base=EUR',
'fixer.io': '//data.fixer.io/api/latest?base=EUR&access_key={}',
'ratesapi.io': 'https://api.ratesapi.io/api/latest?base=EUR',
}
CRYPTO_URL = 'https://api.coingecko.com/api/v3/exchange_rates'
EXCHANGE_REGEX = re.compile(r'''
Expand All @@ -44,7 +43,7 @@
class CurrencySection(types.StaticSection):
fiat_provider = types.ChoiceAttribute('fiat_provider',
list(FIAT_PROVIDERS.keys()),
default='ratesapi.io')
default='exchangerate.host')
"""Which data provider to use (some of which require no API key)"""
fixer_io_key = types.ValidatedAttribute('fixer_io_key', default=None)
"""API key for Fixer.io (widest currency support)"""
Expand Down
177 changes: 109 additions & 68 deletions test/vcr/modules/currency/test_example_exchange_cmd_0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ interactions:
response:
body:
string: !!binary |
H4sIALKjkWAAA4yYS2/bRhDHvwoh5JguuHwtmZstRbFrWzEkJU1yW0lrcUtqSSxJy3KQi+89FP0I
Rd/toWgPfaJAm177GdJ8kg7ltJrVMkB9sPWwfpid+c9/ZvW8p3ktqt69571ZPW//KL4SvXu9Q1nP
C6l6d3uNknX7wrQPTy553sDblLh3e/WmbP9zrjdlXfRe3O2JOkWE+3Uq9O7z96dH6PMRcWnSgciN
IE5lLcwoTo0oWEyCMO7AzOapfRanz6sUHaiPAgpDkgR+F0nNDJLiai6cvpma0eGOFEeExV0xiaLC
2Xk4QbnZPvkX4DFGwq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6INqyAJUmSEuaYy3qOYxuoudxIbCBgd8BH+hmmsShN4Ry4w+Z0ges2KMxKzlug5XTYpEBd
oAXHkNGXuEFaVT2DySfAo257yuAZ3hviKEhgp7E7rsyw7Z3CrFFlaS81b66+Q/mmMAV9cGJut13Z
abtTsVBVDdZu6/UL1Cswu2Ciwiy0NVbm+DhgSW1d+Vle1Ost7PKvq87+FsH08gPbSEyDLxXDprqx
ukneiey3zlyNQp8RGtm0SnQEBvscZKnWeA8ZDfF2FHCwdYeNVHLRWRzk7L9JKN7VHzH8EO5Yaao5
7o8RaECU4EhWd4xwc4QMChY7UqwzXLAx3DU8WASRpl7/+Dv2IsYCmIQps1VQG2y748Ys2hyPb2nq
Z7yawrhPSOrYZ+rVbQ2MhVo5FrfBGGUZQHhBFBCa2nO1Efje+mixWXUBmJn1OTzAIf6AiYCEGBPH
5D+XeFI/llpeNhJ06k2K/M9vz4XxzhppatR3uxXZ76y/Mdi6fSTnGif/WMm6fQhO/Oqjf375GK8o
b66+3vKgjnCf5ClsiLEd7WW3lTeDbOfMbFx5COaCTBS1DfOT1qUcvIvuWnGy741KOVUi9/aMWEFT
glDmWY3vv3uITDmssbCxO8Bi3mnv/Fwa7z1vbIq197Dp3Dif7DzApgD2QvFXH8VyWcwUuMiG2iDq
gyKfvZP5CF8sCNwt3MSJqvEWtKtwrn//2v1Sx9/8OL/aqUSHMxJ1AVe6LWrz/m2Sk/Xixb8AAAD/
/wMAWDH8i3QSAAA=
headers:
Access-Control-Allow-Headers:
- Origin, X-Requested-With, Content-Type, Accept, Authorization
Expand All @@ -56,46 +56,43 @@ interactions:
Access-Control-Request-Method:
- '*'
Age:
- '50'
- '9'
Alternate-Protocol:
- 443:npn-spdy/2
CF-Cache-Status:
- HIT
CF-RAY:
- 64a437f34c03c51c-ORD
- 65557e62db73882f-ORD
Cache-Control:
- public, max-age=30
- public, max-age=60
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json; charset=utf-8
Date:
- Tue, 04 May 2021 19:43:32 GMT
- Wed, 26 May 2021 08:04:36 GMT
ETag:
- W/"76f77c338847ebfddec4ea625939149e"
- W/"2eeb08bb94c466379194ab1f4529841d"
Expect-CT:
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Expires:
- Tue, 04 May 2021 19:44:02 GMT
- Wed, 26 May 2021 08:05:36 GMT
Server:
- cloudflare
Set-Cookie:
- __cfduid=d7386bdeb17f68a5d1192139c85ca48f21620157412; expires=Thu, 03-Jun-21
19:43:32 GMT; path=/; domain=.coingecko.com; HttpOnly; SameSite=Lax
Transfer-Encoding:
- chunked
Vary:
- Accept-Encoding, Origin
X-Request-Id:
- be09b5ab-bbc2-4dfa-b5d9-a3f10d2913a3
- fecbeaf4-c15e-4147-afe9-239787fc1a2b
X-Runtime:
- '0.028949'
- '0.015122'
alt-svc:
- h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
cf-request-id:
- 09da814c100000c51cfa9ad000000001
- 0a494d51ca0000882f6685d000000001
status:
code: 200
message: OK
Expand All @@ -111,58 +108,102 @@ interactions:
User-Agent:
- python-requests/2.25.1
method: GET
uri: https://api.ratesapi.io/api/latest?base=EUR
uri: https://api.exchangerate.host/latest?base=EUR
response:
body:
string: !!binary |
H4sIAAAAAAAAAy2RS27CQBBE79JrpzX/3w4wwcTEoDFWAjuicIGQHeLuqTZZtqrqucpzp6/L7UqF
1lOlhn4uv9cblTttlgcqilOIsaGub6lktja6hrZtpaKjzZ4dtO1upGI5q4yj7XsqkZ0NGsoAY0qc
NFKr7hUpVjk19P45UDGOnRLhjIjxnBwi46YVV1DRNnTsliCDFj0q1JnsnRLACWTH2QfYhj0UrVhp
g2s1nMSXtA0NLTeD4LL3CB06LPKRY0LRcf0M6SBfOuwG4cGGQufFvI+ds8JbzI1cEt52lJTDJLDr
jkpgHxPa1f0MyEaqDufniCQfOtbTfzvMezvIYTUbwOqEeVmxcRa4vn6I5C17aNM4I4wySHU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QBDNEb4u1+dX+RSmip46P90LT5iwLDYifX
PcAHgxa57etemb8Q8AHAa9e91fvHiqdArgeXLmEEVMf1MNMm4nFlCevFVaTl8N3V8tb1kijF02yM
ygqwXraXc7xzCL0ZIZaR+Gyy0jOvLUHMeTrOCOsK4sw3JQIPCLh9wLzxsPNrBZ8TP3/+BxbC7cys
CwAA
headers:
Access-Control-Allow-Credentials:
- 'false'
Access-Control-Allow-Headers:
- Origin, X-Requested-With, Content-Type, Accept, Methods
Access-Control-Allow-Methods:
- GET
Access-Control-Allow-Origin:
- '*'
Age:
- '1526'
- '5972'
CF-Cache-Status:
- HIT
CF-RAY:
- 64a437fd6f66d153-BUF
- 65557e6a5c09110e-ORD
Cache-Control:
- max-age=14400
- max-age=31536000
Connection:
- keep-alive
Content-Encoding:
- gzip
Content-Type:
- application/json
- application/json; charset=utf-8
Date:
- Tue, 04 May 2021 19:43:34 GMT
- Wed, 26 May 2021 08:04:38 GMT
ETag:
- W/"bac-xOQMnXJ7P8JGpGDZL8dHgRtLzMI"
Expect-CT:
- max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
NEL:
- '{"report_to":"cf-nel","max_age":604800}'
Report-To:
- '{"max_age":604800,"group":"cf-nel","endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=fEQiZZbvZ5P8Jo22qpEhIIfD7hVZ6rfSGXwNefIkVpJaXgBaQOTyvVGTQmTG74%2ByTuOswPQ%2F37y5rmzGkjIOopFImt%2FMK1%2BNgon5NhEN9ng%3D"}]}'
- '{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v2?s=FzL%2FKnFfJ30tU3IwnPqUc%2F601fwneecHTTO7qlfOu0IL2IcPb1Vc3qVTO%2F0N%2FBgJmNvDef7hHUT2Kbv8HAT3B0VFJtkTFUeuOiXgafgss5YwCE4YH%2Bj7t4migAmj0ylqEoud"}],"group":"cf-nel","max_age":604800}'
Server:
- cloudflare
Set-Cookie:
- __cfduid=df7f898e4be950fc64ece28a8d21e57711620157414; expires=Thu, 03-Jun-21
19:43:34 GMT; path=/; domain=.ratesapi.io; HttpOnly; SameSite=Lax; Secure
Strict-Transport-Security:
- max-age=15552000; includeSubDomains
Transfer-Encoding:
- chunked
access-control-allow-credentials:
- 'true'
access-control-allow-methods:
- GET
access-control-allow-origin:
- '*'
Vary:
- Accept-Encoding
X-Content-Type-Options:
- nosniff
X-DNS-Prefetch-Control:
- 'off'
X-Download-Options:
- noopen
X-Forwarded-For:
- api.exchangerate.host
X-Frame-Options:
- SAMEORIGIN
X-RateLimit-Limit:
- '2000'
X-RateLimit-Remaining:
- '1999'
X-XSS-Protection:
- 1; mode=block
alt-svc:
- h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400
cf-request-id:
- 09da8152670000d153900ee000000001
content-encoding:
- gzip
vary:
- Accept-Encoding
- 0a494d567b0000110e39081000000001
status:
code: 200
message: OK
Expand Down

0 comments on commit 12f8640

Please sign in to comment.