@vulog/aima-billing
Version:
Invoice management, credits, wallets, and refunds.
19 lines (15 loc) • 635 B
text/typescript
import { Client } from '@vulog/aima-client';
import { z } from 'zod';
export const getInvoicePdf = async (client: Client, invoiceId: string): Promise<ArrayBuffer | null> => {
const result = z.string().trim().min(1).uuid().safeParse(invoiceId);
if (!result.success) {
throw new TypeError('Invalid args', {
cause: result.error.issues,
});
}
const { data } = await client.get<ArrayBuffer>(
`/boapi/proxy/billing/fleets/${client.clientOptions.fleetId}/invoices/${invoiceId}/pdf`,
{ responseType: 'arraybuffer' }
);
return data && data.byteLength > 0 ? data : null;
};