Edits history of script submission #11250 for ' Edit insertion order through SSIO. (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Edit insertion order through SSIO.
     * Edit insertion order through SSIO for ad_account_id.
    - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via Business Access: Admin, Finance, Campaign.
     */
    export async function main(
      auth: Pinterest,
      ad_account_id: string,
      body: {
        start_date?: string;
        end_date?: string;
        po_number?: string;
        budget_amount?: number;
        billing_contact_firstname?: string;
        billing_contact_lastname?: string;
        billing_contact_email?: string;
        media_contact_firstname?: string;
        media_contact_lastname?: string;
        media_contact_email?: string;
        agency_link?: string;
        user_email?: string;
      } & {
        oracle_line_id?: string;
        salesforce_order_id?: string;
        salesforce_order_line_id?: string;
        ads_manager_order_line_id?: string;
      },
    ) {
      const url = new URL(
        `https://api.pinterest.com/v5/ad_accounts/${ad_account_id}/ssio/insertion_orders`,
      );
    
      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