type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Update Variant
* Updates the specified variant. You don't need to include all the properties. If you just want to update content, for example, then include just that.
You can't switch the active state of the default variant of an item. Similarly, you can't switch the default to false if the variant is the default. You must make another variant default instead.
#### Allowed For
* Admins, Agents
*/
export async function main(
auth: Zendesk,
dynamic_content_item_id: string,
dynammic_content_variant_id: string
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items/${dynamic_content_item_id}/variants/${dynammic_content_variant_id}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 377 days ago
type Zendesk = {
username: string;
password: string;
subdomain: string;
};
/**
* Update Variant
* Updates the specified variant. You don't need to include all the properties. If you just want to update content, for example, then include just that.
You can't switch the active state of the default variant of an item. Similarly, you can't switch the default to false if the variant is the default. You must make another variant default instead.
#### Allowed For
* Admins, Agents
*/
export async function main(
auth: Zendesk,
dynamic_content_item_id: string,
dynammic_content_variant_id: string
) {
const url = new URL(
`https://${auth.subdomain}.zendesk.com/api/v2/dynamic_content/items/${dynamic_content_item_id}/variants/${dynammic_content_variant_id}`
);
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 923 days ago