//native
type Vercel = {
token: string;
};
/**
* Submit Invoice
* This endpoint allows the partner to submit an invoice to Vercel.
*/
export async function main(
auth: Vercel,
integrationConfigurationId: string,
body: {
externalId?: string;
invoiceDate: string;
memo?: string;
period: { start: string; end: string };
items: {
resourceId?: string;
billingPlanId: string;
start?: string;
end?: string;
name: string;
details?: string;
price: string;
quantity: number;
units: string;
total: string;
}[];
discounts?: {
resourceId?: string;
billingPlanId: string;
start?: string;
end?: string;
name: string;
details?: string;
amount: string;
}[];
test?: { validate?: false | true; result?: "paid" | "notpaid" };
},
) {
const url = new URL(
`https://api.vercel.com/v1/installations/${integrationConfigurationId}/billing/invoices`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago