Skip to content

Commit

Permalink
Change exchange rate api to bank of canda api
Browse files Browse the repository at this point in the history
  • Loading branch information
Prabhu-Manchineella_bcgovent committed Sep 22, 2023
1 parent b468e94 commit 7c114f4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions billing-report-utility/summarize_charges.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def get_exchange_rate():
# usd_to_cad_rate= 1
AWS_REGION = "ca-central-1"
ssm_client = boto3.client("ssm", region_name=AWS_REGION)
url = "https://api.exchangerate.host/convert?from=USD&to=CAD"
url = "https://www.bankofcanada.ca/valet/observations/FXUSDCAD?recent=1"

rc_channel = ssm_client.get_parameter(Name='/bcgov/billingutility/rocketchat_alert_webhook', WithDecryption=True)
rc_channel_url = rc_channel['Parameter']['Value']
Expand All @@ -60,7 +60,7 @@ def get_exchange_rate():
retries = Retry(
total=3,
backoff_factor=1,
status_forcelist=[429, 500, 502, 503, 504]
status_forcelist=[429, 500, 502, 503, 504, 404]
)
requests_session.mount("https://", HTTPAdapter(max_retries=retries))

Expand Down Expand Up @@ -118,7 +118,7 @@ def get_exchange_rate():
)
else:
data = response.json()
usd_to_cad_rate = float(data["result"])
usd_to_cad_rate = float(data['observations'][0]['FXUSDCAD']['v'])
# print(usd_to_cad_rate)
return usd_to_cad_rate

Expand Down

0 comments on commit 7c114f4

Please sign in to comment.