UNPKG

nodejs-cryptomus

Version:

A comprehensive Node.js client for the Cryptomus API

61 lines (60 loc) 1.78 kB
import { filterUndefined, ensureString } from '../utils/helpers'; /** * Payout service for managing payouts */ export class PayoutService { /** * Create a new payout service * * @param client - Cryptomus API client */ constructor(client) { this.client = client; } /** * Create a new payout * * @param params - Payout creation parameters * @returns Created payout information */ async createPayout(params) { const payload = { ...params, amount: ensureString(params.amount) }; const response = await this.client.requestPayout('POST', '/payout', payload); return response.result; } /** * Get payout information by UUID or order ID * * @param params - Parameters containing UUID or order ID * @returns Payout information */ async getPayoutInfo(params) { if (!params.uuid && !params.order_id) { throw new Error('Either uuid or order_id must be provided'); } const response = await this.client.requestPayout('POST', '/payout/info', filterUndefined(params)); return response.result; } /** * Get payout history * * @param params - History request parameters * @returns List of payouts */ async getPayoutHistory(params = {}) { const response = await this.client.requestPayout('POST', '/payout/list', filterUndefined(params)); return response.result; } /** * Get list of available payout services * * @returns List of available payout services */ async getServices() { const response = await this.client.requestPayout('GET', '/payout/services'); return response.result; } }