Skip to content

Commit

Permalink
feature #6 - add exchange rate internal service
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeniosales committed Oct 16, 2022
1 parent dea9f6c commit 6007af0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/4-framework/services/exchangeRateInternalService.ts
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
}
}
}

0 comments on commit 6007af0

Please sign in to comment.