-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #6 - add exchange rate internal service
- Loading branch information
1 parent
dea9f6c
commit 6007af0
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ExchangeRate } from '../../1-domain/entities/exchangeRate' | ||
import { IExchangeRateInternalService } from '../../2-business/services/iExchangeRateInternalService' | ||
import { CurrencyEnum } from '../../2-business/enums/currencyEnum' | ||
import axios, { AxiosResponse } from 'axios' | ||
|
||
export class ExchangeRateInternalService implements IExchangeRateInternalService { | ||
private readonly baseUrl = 'https://internal-sbf-exchangerate-dev-lb-431495913.us-east-1.elb.amazonaws.com' | ||
|
||
async get (base: CurrencyEnum): Promise<ExchangeRate> { | ||
const logPrefix = 'get' | ||
|
||
try { | ||
const response: AxiosResponse = await axios.get(`${this.baseUrl}/api/v1/exchangerate`, { | ||
params: { | ||
baseCurrency: base | ||
} | ||
}) | ||
|
||
console.log(`${logPrefix} :: success ::`, { data: response.data }) | ||
return response.data | ||
} catch (error) { | ||
console.error(`${logPrefix} :: error ::`, error) | ||
throw error | ||
} | ||
} | ||
} |