@vulog/aima-billing
Version:
Invoice management, credits, wallets, and refunds.
23 lines (17 loc) • 659 B
text/typescript
import { Client } from '@vulog/aima-client';
import { z } from 'zod';
import { RefundableAmount } from './types';
const schema = z.string().trim().min(1);
export const getRefundableAmount = async (client: Client, invoiceId: string): Promise<RefundableAmount> => {
const result = schema.safeParse(invoiceId);
if (!result.success) {
throw new TypeError('Invalid args', {
cause: result.error.issues,
});
}
return client
.get<RefundableAmount>(
`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/refundableAmount`
)
.then(({ data }) => data);
};