xrocket-pay-api-sdk
Version:
TypeScript SDK for xRocket Pay API
164 lines (163 loc) • 6.67 kB
TypeScript
import { Version, XRocketPayConfig, CreateInvoiceDto, CreateInvoiceResponse, GetInvoiceResponse, DeleteResponse, PaginationParams, ListInvoicesResponse, AppInfoResponse } from './types';
import { CreateTransferDto, AppTransferResponse, WithdrawalFeesResponse, CreateWithdrawalDto, AppWithdrawalResponse, WithdrawalStatusResponse } from './types/app';
import { CreateChequeDto, SimpleChequeResponse, UpdateChequeDto, PaginatedShortChequeDtoResponse } from './types/multicheque';
import { AvailableCoinsResponse } from './types/currencies';
/**
* XRocket Pay API Client
*/
export declare class XRocketPayClient {
private readonly httpClient;
private readonly config;
constructor(config?: XRocketPayConfig);
/**
* Get API version. Can be used as a healthcheck.
* This endpoint doesn't require authentication.
*
* @returns Promise<Version> The current API version
*/
getVersion(): Promise<Version>;
/**
* Get available currencies
* No authentication required.
*
* @returns Promise<AvailableCoinsResponse> The available currencies data
* @throws {Error} When request fails
*/
getAvailableCurrencies(): Promise<AvailableCoinsResponse>;
/**
* Create a new invoice
* Requires authentication via API key.
*
* @param invoiceData The invoice data to create
* @returns Promise<CreateInvoiceResponse> The created invoice data
* @throws {Error} When API key is not set or request fails
*/
createInvoice(invoiceData: CreateInvoiceDto): Promise<CreateInvoiceResponse>;
/**
* Get a paginated list of invoices
* Requires authentication via API key.
*
* @param params Pagination parameters (limit, offset)
* @returns Promise<ListInvoicesResponse> The paginated list of invoices
* @throws {Error} When API key is not set or request fails
*/
getInvoices(params?: PaginationParams): Promise<ListInvoicesResponse>;
/**
* Get invoice information by ID
* Requires authentication via API key.
*
* @param id The invoice ID to retrieve
* @returns Promise<GetInvoiceResponse> The invoice data with payment statistics
* @throws {Error} When API key is not set or request fails
*/
getInvoice(id: string): Promise<GetInvoiceResponse>;
/**
* Delete invoice by ID
* Requires authentication via API key.
*
* @param id The invoice ID to delete
* @returns Promise<DeleteResponse> The delete operation result
* @throws {Error} When API key is not set or request fails
*/
deleteInvoice(id: string): Promise<DeleteResponse>;
/**
* Update the API key for authenticated requests
*
* @param apiKey The new API key
*/
setApiKey(apiKey: string): void;
/**
* Get the current configuration
*/
getConfig(): Readonly<XRocketPayConfig>;
/**
* Get information about your application
* Requires authentication via API key.
*
* @returns Promise<AppInfoResponse> The application information
* @throws {Error} When API key is not set or request fails
*/
getAppInfo(): Promise<AppInfoResponse>;
/**
* Make a transfer of funds to another user
* Requires authentication via API key.
*
* @param transferData The transfer data to create
* @returns Promise<AppTransferResponse> The created transfer data
* @throws {Error} When API key is not set or request fails
*/
createTransfer(transferData: CreateTransferDto): Promise<AppTransferResponse>;
/**
* Get withdrawal fees for currencies
* Requires authentication via API key.
*
* @param currency Optional currency code to get fees for specific currency
* @returns Promise<WithdrawalFeesResponse> The withdrawal fees data
* @throws {Error} When API key is not set or request fails
*/
getWithdrawalFees(currency?: string): Promise<WithdrawalFeesResponse>;
/**
* Create a new withdrawal
* Requires authentication via API key.
*
* @param withdrawalData The withdrawal data to create
* @returns Promise<AppWithdrawalResponse> The created withdrawal data
* @throws {Error} When API key is not set or request fails
*/
createWithdrawal(withdrawalData: CreateWithdrawalDto): Promise<AppWithdrawalResponse>;
/**
* Get withdrawal status by ID
* Requires authentication via API key.
*
* @param withdrawalId The withdrawal ID to check status for
* @returns Promise<WithdrawalStatusResponse> The withdrawal status data
* @throws {Error} When API key is not set or request fails
*/
getWithdrawalStatus(withdrawalId: string): Promise<WithdrawalStatusResponse>;
/**
* Create a new multicheque
* Requires authentication via API key.
*
* @param chequeData The multicheque data to create
* @returns Promise<SimpleChequeResponse> The created multicheque data
* @throws {Error} When API key is not set or request fails
*/
createMulticheque(chequeData: CreateChequeDto): Promise<SimpleChequeResponse>;
/**
* Get multicheque information by ID
* Requires authentication via API key.
*
* @param id The multicheque ID to retrieve
* @returns Promise<SimpleChequeResponse> The multicheque data
* @throws {Error} When API key is not set or request fails
*/
getMulticheque(id: number): Promise<SimpleChequeResponse>;
/**
* Get a paginated list of multicheques
* Requires authentication via API key.
*
* @param params Pagination parameters (limit, offset)
* @returns Promise<PaginatedShortChequeDtoResponse> The paginated list of multicheques
* @throws {Error} When API key is not set or request fails
*/
getMulticheques(params?: PaginationParams): Promise<PaginatedShortChequeDtoResponse>;
/**
* Update multicheque information
* Requires authentication via API key.
*
* @param id The multicheque ID to update
* @param updateData The multicheque data to update
* @returns Promise<SimpleChequeResponse> The updated multicheque data
* @throws {Error} When API key is not set or request fails
*/
updateMulticheque(id: number, updateData: UpdateChequeDto): Promise<SimpleChequeResponse>;
/**
* Delete multicheque by ID
* Requires authentication via API key.
*
* @param id The multicheque ID to delete
* @returns Promise<DeleteResponse> The delete operation result
* @throws {Error} When API key is not set or request fails
*/
deleteMulticheque(id: number): Promise<DeleteResponse>;
}