You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
test-assignment-payments/src/exchange-rate/exchange-rate.service.ts

24 lines
671 B

import { HttpService } from '@nestjs/axios';
import { Injectable } from '@nestjs/common';
import { AxiosResponse } from 'axios';
import { map, Observable } from 'rxjs';
import {
ExchangeRateInput,
ExchangeRateResponse,
URL,
} from './exchange-rate.dto';
@Injectable()
export class ExchangeRateService {
constructor(private httpService: HttpService) {}
convertCurrency(input: ExchangeRateInput): Observable<ExchangeRateResponse> {
return this.httpService
.get(URL.exchangeRateConvertUrl.replace('{date}', input.date))
.pipe(
map((axiosResponse: AxiosResponse) => {
return axiosResponse.data?.rates;
}),
);
}
}