//native
type Pinterest = {
token: string;
};
/**
* Update product group promotions
* Update multiple existing Product Group Promotions (by product_group_id)
*/
export async function main(
auth: Pinterest,
ad_account_id: string,
body: {
ad_group_id: string;
product_group_promotion: {
id?: string;
ad_group_id?: string;
bid_in_micro_currency?: number;
included?: false | true;
definition?: string;
relative_definition?: string;
parent_id?: string;
slideshow_collections_title?: string;
slideshow_collections_description?: string;
is_mdl?: false | true;
status?: "ACTIVE" | "PAUSED" | "ARCHIVED" | "DRAFT" | "DELETED_DRAFT";
tracking_url?: string;
catalog_product_group_id?: string;
catalog_product_group_name?: string;
collections_hero_pin_id?: string;
collections_hero_destination_url?: string;
grid_click_type?: "CLOSEUP" | "DIRECT_TO_DESTINATION";
}[];
},
) {
const url = new URL(
`https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/product_group_promotions`,
);
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.json();
}
Submitted by hugo697 536 days ago