Edits history of script submission #11393 for ' Update commerce integration (pinterest)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Pinterest = {
      token: string;
    };
    /**
     * Update commerce integration
     * Update commerce integration metadata for the given external business ID.
    Note: If you're interested in joining the beta, please reach out to your Pinterest account manager.
     */
    export async function main(
      auth: Pinterest,
      external_business_id: string,
      body: {
        connected_merchant_id?: string;
        connected_advertiser_id?: string;
        connected_lba_id?: string;
        connected_tag_id?: string;
        partner_access_token?: string;
        partner_refresh_token?: string;
        partner_primary_email?: string;
        partner_access_token_expiry?: number;
        partner_refresh_token_expiry?: number;
        scopes?: string;
        additional_id_1?: string;
        partner_metadata?: string;
      },
    ) {
      const url = new URL(
        `https://api.pinterest.com/v5/integrations/commerce/${external_business_id}`,
      );
    
      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