//native
type Pinterest = {
token: string;
};
/**
* Update ads
* Update multiple existing ads
*/
export async function main(
auth: Pinterest,
ad_account_id: string,
body: {
ad_group_id?: string;
android_deep_link?: string;
carousel_android_deep_links?: string[];
carousel_destination_urls?: string[];
carousel_ios_deep_links?: string[];
click_tracking_url?: string;
creative_type?:
| "REGULAR"
| "VIDEO"
| "SHOPPING"
| "CAROUSEL"
| "MAX_VIDEO"
| "SHOP_THE_PIN"
| "COLLECTION"
| "IDEA"
| "SHOWCASE"
| "QUIZ";
destination_url?: string;
ios_deep_link?: string;
is_pin_deleted?: false | true;
is_removable?: false | true;
name?: string;
status?: "ACTIVE" | "PAUSED" | "ARCHIVED" | "DRAFT" | "DELETED_DRAFT";
tracking_urls?: {
impression?: string[];
click?: string[];
engagement?: string[];
buyable_button?: string[];
audience_verification?: string[];
};
view_tracking_url?: string;
lead_form_id?: string;
grid_click_type?: "CLOSEUP" | "DIRECT_TO_DESTINATION";
customizable_cta_type?:
| "GET_OFFER"
| "LEARN_MORE"
| "ORDER_NOW"
| "SHOP_NOW"
| "SIGN_UP"
| "SUBSCRIBE"
| "BUY_NOW"
| "CONTACT_US"
| "GET_QUOTE"
| "VISIT_SITE"
| "APPLY_NOW"
| "BOOK_NOW"
| "REQUEST_DEMO"
| "REGISTER_NOW"
| "FIND_A_DEALER"
| "ADD_TO_CART"
| "WATCH_NOW"
| "READ_MORE";
quiz_pin_data?: {
questions?: {
question_id?: number;
question_text?: string;
options?: { id?: number; text?: string }[];
}[];
results?: {
organic_pin_id?: string;
android_deep_link?: string;
ios_deep_link?: string;
destination_url?: string;
result_id?: number;
}[];
tie_breaker_type?: "RANDOM" | "CUSTOM";
tie_breaker_custom_result?: {
organic_pin_id?: string;
android_deep_link?: string;
ios_deep_link?: string;
destination_url?: string;
result_id?: number;
};
};
} & { id: string; pin_id?: string }[],
) {
const url = new URL(
`https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ads`,
);
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