UNPKG

nowpayments-api-typescript

Version:
32 lines (26 loc) 702 B
import ApiConnection from './../utils/api-connection'; import { IGetEstimatePrice, IError } from './../interfaces'; export interface GetEstimatePriceResponse { currency_from: string; amount_from: number; currency_to: string; estimated_amount: number; } export interface GetEstimatePrice extends IGetEstimatePrice { apiKey: string; } const getEstimatePrice = async ({ apiKey, amount, currency_from, currency_to, }: GetEstimatePrice): Promise<GetEstimatePriceResponse | IError> => { const api = new ApiConnection({ apiKey }); const { data } = await api.get('/estimate', { amount, currency_from, currency_to, }); return data; }; export default getEstimatePrice;