Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env-sample
Original file line number Diff line number Diff line change
@@ -1 +1 @@
NODE_ENV=production
NODE_ENV=development
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/*
.idea
.env
.DS_Store
.DS_Store
dist
8 changes: 8 additions & 0 deletions src/actions/get-available-currencies/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Error } from '../../types';
export interface GetAvailableCurrenciesReturn {
currencies: [string];
}
declare const getAvailableCurrencies: ({ apiKey }: {
apiKey: string;
}) => Promise<GetAvailableCurrenciesReturn | Error>;
export default getAvailableCurrencies;
15 changes: 15 additions & 0 deletions src/actions/get-available-currencies/index.ts
Original file line number Diff line number Diff line change
@@ -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<GetAvailableCurrenciesReturn | Error> => {
const API = new ConnectApi({ apiKey })

const { data } = await API.get('/merchant/coins')
return data
}

export default getAvailableCurrencies
26 changes: 26 additions & 0 deletions src/actions/get-full-currencies/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Error } from '../../types';
export interface GetFullCurrenciesReturn {
currencies: [Partial<FullCurrency>]
}

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<GetFullCurrenciesReturn | Error>;
export default getCurrencies;
33 changes: 33 additions & 0 deletions src/actions/get-full-currencies/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import ConnectApi from '../../utils/connect-api'
import { Error } from '../../types'

export interface GetFullCurrenciesReturn {
currencies: [Partial<FullCurrency>]
}

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<GetFullCurrenciesReturn | Error> => {
const API = new ConnectApi({ apiKey })

const { data } = await API.get('/full-currencies')
return data
}

export default getFullCurrencies
6 changes: 6 additions & 0 deletions src/actions/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ declare const _default: {
getCurrencies: ({ apiKey }: {
apiKey: string;
}) => Promise<import("../types").Error | import("./get-currencies").GetCurrenciesReturn>;
getFullCurrencies: ({ apiKey }: {
apiKey: string;
}) => Promise<import("../types").Error | import("./get-full-currencies").GetFullCurrenciesReturn>;
getAvailableCurrencies: ({ apiKey }: {
apiKey: string;
}) => Promise<import("../types").Error | import("./get-available-currencies").GetAvailableCurrenciesReturn>;
getEstimatePrice: ({ apiKey, amount, currency_from, currency_to }: import("./get-estimate-price").GetEstimatePrice) => Promise<import("../types").Error | import("./get-estimate-price").GetEstimatePriceReturn>;
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<import("../types").Error | import("./create-payment").CreatePaymentReturn>;
getPaymentStatus: ({ apiKey, payment_id }: import("./get-payment-status").GetPaymentStatus) => Promise<import("../types").Error | import("./get-payment-status").GetPaymentStatusReturn>;
Expand Down
4 changes: 4 additions & 0 deletions src/actions/index.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -10,6 +12,8 @@ import createInvoice from './create-invoice'
export default {
status,
getCurrencies,
getFullCurrencies,
getAvailableCurrencies,
getEstimatePrice,
createPayment,
getPaymentStatus,
Expand Down
2 changes: 2 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ declare class NOWPaymentsApi {
});
status(): Promise<import("./actions/status").StatusReturn | import("./types").Error>;
getCurrencies(): Promise<import("./types").Error | import("./actions/get-currencies").GetCurrenciesReturn>;
getFullCurrencies(): Promise<import("./types").Error | import("./actions/get-full-currencies").GetFullCurrenciesReturn>;
getAvailableCurrencies(): Promise<import("./types").Error | import("./actions/get-available-currencies").GetAvailableCurrenciesReturn>;
getEstimatePrice({ amount, currency_from, currency_to }: IGetEstimatePrice): Promise<import("./types").Error | import("./actions/get-estimate-price").GetEstimatePriceReturn>;
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<import("./types").Error | import("./actions/create-payment").CreatePaymentReturn>;
getPaymentStatus({ payment_id }: IGetPaymentStatus): Promise<import("./types").Error | import("./actions/get-payment-status").GetPaymentStatusReturn>;
Expand Down
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand Down