Edits history of script submission #21933 for ' Sign mail merge (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Sign mail merge
     *
     */
    export async function main(
      auth: Zoho,
      id: string,
      _module: string,
      body: {
        sign_mail_merge?: {
          mail_merge_template?: { id?: string; name?: string };
          sign_in_order?: false | true;
          file_name?: string;
          signers?: {
            recipient_name?: string;
            action_type?: "approve" | "sign";
            recipient?: { type?: string; value?: string };
          }[];
        }[];
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/${_module}/${id}/actions/sign_mail_merge`,
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Zoho-oauthtoken " + 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 235 days ago