Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Description of change
(write a short description or paste a link to JIRA)
Updated base_url variable which is used in all http requests. The previous one no longer worked.

# Manual QA steps
-
- Use Postman to try the previous HTTP request: https://api.exchangeratesapi.io/2022-03-03?base=USD
- Use Postman to try the current (working) HTTP request: https://api.apilayer.com/exchangerates_data/2022-03-03?base=USD
NOTE: Any historical date larger than Y2K works in the above examples

# Risks
-
- base URL now includes a level 1 path. Not the best practice per se, but as long as every supported endpoint includes that full base URL + level 1 path, the risk is mitigated. That holds true when checking the endpoint documentation located here https://apilayer.com/marketplace/exchangerates_data-api#endpoints

# Rollback steps
- revert this branch
- revert this branch
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/codestream.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/tap-exchangeratesapi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion config.sample.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"base": "AUD",
"start_date": "2017-02-02"
"start_date": "2017-02-02",
"apikey": "VzNBD8lZ5lVkVinRFgM7xM3bf77wAyHn"
}
12 changes: 5 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
#!/usr/bin/env python

from setuptools import setup, find_packages

setup(name='tap-exchangeratesapi',
version='0.1.1',
version='1.0.1',
description='Singer.io tap for extracting currency exchange rate data from the exchangeratesapi.io API',
author='Stitch',
url='http://github.com/singer-io/tap-exchangeratesapi',
url='http://github.com/adswerve/tap-exchangeratesapi',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably worth reverting this change.

classifiers=['Programming Language :: Python :: 3 :: Only'],
py_modules=['tap_exchangeratesapi'],
install_requires=['singer-python==5.3.3',
'backoff==1.3.2',
'requests==2.21.0'],
install_requires=['singer-python==5.13.0',
'backoff==1.8.0',
'requests==2.28.2'],
extras_require={
'dev': [
'ipdb==0.11'
Expand Down
17 changes: 9 additions & 8 deletions tap_exchangeratesapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from datetime import date, datetime, timedelta

base_url = 'https://api.exchangeratesapi.io/'
base_url = 'https://api.apilayer.com/exchangerates_data/'

logger = singer.get_logger()
session = requests.Session()
Expand Down Expand Up @@ -41,23 +41,24 @@ def giveup(error):
max_tries=5,
giveup=giveup,
interval=30)
def request(url, params):
response = requests.get(url=url, params=params)
def request(url, params, headers):
response = requests.get(url=url, params=params,headers=headers)
response.raise_for_status()
return response

def do_sync(base, start_date):
def do_sync(base, start_date, apikey):
state = {'start_date': start_date}
next_date = start_date
prev_schema = {}

try:
while datetime.strptime(next_date, DATE_FORMAT) <= datetime.utcnow():
logger.info('Replicating exchange rate data from %s using base %s',
logger.info('Replicating exchange rate data from %s using base %s with apikey %s',
next_date,
base)
base,
apikey)

response = request(base_url + next_date, {'base': base})
response = request(base_url + next_date, {'base': base}, {'apikey':apikey})
payload = response.json()

# Update schema if new currency/currencies exist
Expand Down Expand Up @@ -112,7 +113,7 @@ def main():
start_date = state.get('start_date') or config.get('start_date') or datetime.utcnow().strftime(DATE_FORMAT)
start_date = singer.utils.strptime_with_tz(start_date).date().strftime(DATE_FORMAT)

do_sync(config.get('base', 'USD'), start_date)
do_sync(config.get('base', 'USD'), start_date, config.get('api_key',''))


if __name__ == '__main__':
Expand Down