diff --git a/.env-sample b/.env-sample index 995fca4..083c815 100644 --- a/.env-sample +++ b/.env-sample @@ -1 +1 @@ -NODE_ENV=production \ No newline at end of file +NODE_ENV=development \ No newline at end of file diff --git a/.gitignore b/.gitignore index 43593e3..77d0c2f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/* .idea .env -.DS_Store \ No newline at end of file +.DS_Store +dist \ No newline at end of file diff --git a/src/actions/get-available-currencies/index.d.ts b/src/actions/get-available-currencies/index.d.ts new file mode 100644 index 0000000..a32cd13 --- /dev/null +++ b/src/actions/get-available-currencies/index.d.ts @@ -0,0 +1,8 @@ +import { Error } from '../../types'; +export interface GetAvailableCurrenciesReturn { + currencies: [string]; +} +declare const getAvailableCurrencies: ({ apiKey }: { + apiKey: string; +}) => Promise; +export default getAvailableCurrencies; diff --git a/src/actions/get-available-currencies/index.ts b/src/actions/get-available-currencies/index.ts new file mode 100644 index 0000000..1097a59 --- /dev/null +++ b/src/actions/get-available-currencies/index.ts @@ -0,0 +1,15 @@ +import ConnectApi from '../../utils/connect-api' +import { Error } from '../../types' + +export interface GetAvailableCurrenciesReturn { + currencies: [string] +} + +const getAvailableCurrencies = async ({ apiKey }: { apiKey: string }): Promise => { + const API = new ConnectApi({ apiKey }) + + const { data } = await API.get('/merchant/coins') + return data +} + +export default getAvailableCurrencies diff --git a/src/actions/get-full-currencies/index.d.ts b/src/actions/get-full-currencies/index.d.ts new file mode 100644 index 0000000..9ac1f40 --- /dev/null +++ b/src/actions/get-full-currencies/index.d.ts @@ -0,0 +1,26 @@ +import { Error } from '../../types'; +export interface GetFullCurrenciesReturn { + currencies: [Partial] + } + + export interface FullCurrency { + id: number + code: string + name: string + enable: boolean + wallet_regex: string + priority: number + extra_id_exists: boolean + extra_id_regex: string | null + logo_url: string + track: boolean + cg_id: string + is_maxlimit: boolean + network: string + smart_contract: string | null + network_precision: number | null + } +declare const getCurrencies: ({ apiKey }: { + apiKey: string; +}) => Promise; +export default getCurrencies; \ No newline at end of file diff --git a/src/actions/get-full-currencies/index.ts b/src/actions/get-full-currencies/index.ts new file mode 100644 index 0000000..0093acc --- /dev/null +++ b/src/actions/get-full-currencies/index.ts @@ -0,0 +1,33 @@ +import ConnectApi from '../../utils/connect-api' +import { Error } from '../../types' + +export interface GetFullCurrenciesReturn { + currencies: [Partial] +} + +export interface FullCurrency { + id: number + code: string + name: string + enable: boolean + wallet_regex: string + priority: number + extra_id_exists: boolean + extra_id_regex: string | null + logo_url: string + track: boolean + cg_id: string + is_maxlimit: boolean + network: string + smart_contract: string | null + network_precision: number | null +} + +const getFullCurrencies = async ({ apiKey }: { apiKey: string }): Promise => { + const API = new ConnectApi({ apiKey }) + + const { data } = await API.get('/full-currencies') + return data +} + +export default getFullCurrencies diff --git a/src/actions/index.d.ts b/src/actions/index.d.ts index f1dabaf..15147df 100644 --- a/src/actions/index.d.ts +++ b/src/actions/index.d.ts @@ -3,6 +3,12 @@ declare const _default: { getCurrencies: ({ apiKey }: { apiKey: string; }) => Promise; + getFullCurrencies: ({ apiKey }: { + apiKey: string; + }) => Promise; + getAvailableCurrencies: ({ apiKey }: { + apiKey: string; + }) => Promise; getEstimatePrice: ({ apiKey, amount, currency_from, currency_to }: import("./get-estimate-price").GetEstimatePrice) => Promise; createPayment: ({ apiKey, price_amount, price_currency, pay_amount, pay_currency, ipn_callback_url, order_id, order_description, purchase_id, payout_address, payout_currency, payout_extra_id, fixed_rate }: import("./create-payment").CreatePayment) => Promise; getPaymentStatus: ({ apiKey, payment_id }: import("./get-payment-status").GetPaymentStatus) => Promise; diff --git a/src/actions/index.ts b/src/actions/index.ts index c4f4a04..d0446df 100644 --- a/src/actions/index.ts +++ b/src/actions/index.ts @@ -1,5 +1,7 @@ import status from './status' import getCurrencies from './get-currencies' +import getFullCurrencies from './get-full-currencies' +import getAvailableCurrencies from './get-available-currencies' import getEstimatePrice from './get-estimate-price' import createPayment from './create-payment' import getPaymentStatus from './get-payment-status' @@ -10,6 +12,8 @@ import createInvoice from './create-invoice' export default { status, getCurrencies, + getFullCurrencies, + getAvailableCurrencies, getEstimatePrice, createPayment, getPaymentStatus, diff --git a/src/index.d.ts b/src/index.d.ts index 110b8a8..fb689bc 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -6,6 +6,8 @@ declare class NOWPaymentsApi { }); status(): Promise; getCurrencies(): Promise; + getFullCurrencies(): Promise; + getAvailableCurrencies(): Promise; getEstimatePrice({ amount, currency_from, currency_to }: IGetEstimatePrice): Promise; createPayment({ price_amount, price_currency, pay_amount, pay_currency, ipn_callback_url, order_id, order_description, purchase_id, payout_address, payout_currency, payout_extra_id, fixed_rate }: ICreatePayment): Promise; getPaymentStatus({ payment_id }: IGetPaymentStatus): Promise; diff --git a/src/index.ts b/src/index.ts index d17f501..033cf75 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,14 @@ class NOWPaymentsApi { return await NP.getCurrencies({ apiKey: this.apiKey }) } + async getAllCurrencies() { + return await NP.getFullCurrencies({ apiKey: this.apiKey }) + } + + async getAvailableCurrencies() { + return await NP.getAvailableCurrencies({ apiKey: this.apiKey }) + } + async getEstimatePrice({ amount, currency_from, currency_to }: IGetEstimatePrice) { return await NP.getEstimatePrice({ apiKey: this.apiKey, amount, currency_from, currency_to }) }