//native
type Vercel = {
token: string;
};
/**
* Accept project transfer request
* Accept a project transfer request initated by another team. The `code` is generated using the `POST /projects/:idOrName/transfer-request` endpoint.
*/
export async function main(
auth: Vercel,
code: string,
teamId: string | undefined,
slug: string | undefined,
body: {
newProjectName?: string;
paidFeatures?: {
concurrentBuilds?: number;
passwordProtection?: false | true;
previewDeploymentSuffix?: false | true;
};
},
) {
const url = new URL(
`https://api.vercel.com/projects/transfer-request/${code}`,
);
for (const [k, v] of [
["teamId", teamId],
["slug", slug],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
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