UNPKG

nowpayments-api-typescript

Version:
55 lines (48 loc) 1.07 kB
import ApiConnection from './../utils/api-connection'; import { IGetListPayments, IError } from './../interfaces'; interface Invoice { payment_id: number; payment_status: string; pay_address: string; price_amount: number; price_currency: string; pay_amount: number; actually_paid: number; pay_currency: string; order_id: string; order_description: string; purchase_id: number; outcome_amount: number; outcome_currency: string; } export interface GetListPaymentsResponse { data: Invoice[]; limit: number; page: number; pagesCount: number; total: number; } export interface GetListPayments extends IGetListPayments { apiKey: string; } const getListPayments = async ({ apiKey, limit, page, sortBy, orderBy, dateFrom, dateTo, }: GetListPayments): Promise<GetListPaymentsResponse | IError> => { const api = new ApiConnection({ apiKey }); const { data } = await api.get('/payment', { limit, page, sortBy, orderBy, dateFrom, dateTo, }); return data; }; export default getListPayments;