//native
type Vercel = {
token: string;
};
/**
* Patch an existing experimentation item
* Patch an existing experimentation item
*/
export async function main(
auth: Vercel,
integrationConfigurationId: string,
resourceId: string,
itemId: string,
body: {
slug: string;
origin: string;
name?: string;
category?: "experiment" | "flag";
description?: string;
isArchived?: false | true;
createdAt?: number;
updatedAt?: number;
},
) {
const url = new URL(
`https://api.vercel.com/v1/installations/${integrationConfigurationId}/resources/${resourceId}/experimentation/items/${itemId}`,
);
const response = await fetch(url, {
method: "PATCH",
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