//native
type Vercel = {
token: string;
};
/**
* Submit Prepayment Balances
* Sends the prepayment balances. The partner should do this at least once a day and ideally once per hour. Use the `credentials.access_token` we provided in the [Upsert Installation](#upsert-installation) body to authorize this request.
*/
export async function main(
auth: Vercel,
integrationConfigurationId: string,
body: {
timestamp: string;
balances: {
resourceId?: string;
credit?: string;
nameLabel?: string;
currencyValueInCents: number;
}[];
},
) {
const url = new URL(
`https://api.vercel.com/v1/installations/${integrationConfigurationId}/billing/balance`,
);
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.text();
}
Submitted by hugo697 428 days ago