//native
type Vercel = {
token: string;
};
/**
* Get configurations for the authenticated user or team
* Allows to retrieve all configurations for an authenticated integration. When the `project` view is used, configurations generated for the authorization flow will be filtered out of the results.
*/
export async function main(
auth: Vercel,
view: "account" | "project" | undefined,
installationType: "marketplace" | "external" | undefined,
integrationIdOrSlug: string | undefined,
teamId: string | undefined,
slug: string | undefined,
) {
const url = new URL(`https://api.vercel.com/v1/integrations/configurations`);
for (const [k, v] of [
["view", view],
["installationType", installationType],
["integrationIdOrSlug", integrationIdOrSlug],
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago