//native
type Vercel = {
token: string;
};
/**
* Create Event
* Partner notifies Vercel of any changes made to an Installation or a Resource.
*/
export async function main(
auth: Vercel,
integrationConfigurationId: string,
body: {
event:
| { type: "installation.updated"; billingPlanId?: string }
| { type: "resource.updated"; productId: string; resourceId: string };
},
) {
const url = new URL(
`https://api.vercel.com/v1/installations/${integrationConfigurationId}/events`,
);
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