Edits history of script submission #21085 for ' Add appointments rescheduled history (zoho)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Zoho = {
      token: string;
    };
    /**
     * Add appointments rescheduled history
     *
     */
    export async function main(
      auth: Zoho,
      body: {
        data: {
          $currency_symbol: string;
          Rescheduled_To: string;
          $review_process: false | true;
          Reschedule_Reason: string;
          $sharing_permission: string;
          Name: string;
          Modified_By: { name: string; id: string; email: string };
          $review: false | true;
          Rescheduled_By: { name: string; id: string; email: string };
          $state: string;
          $canvas_id: string;
          $process_flow: false | true;
          id: string;
          Rescheduled_Time: string;
          $zia_visions: false | true;
          $approved: false | true;
          Modified_Time: string;
          $approval: {
            delegate: false | true;
            approve: false | true;
            reject: false | true;
            resubmit: false | true;
          };
          Created_Time: string;
          Rescheduled_From: string;
          Appointment_Name: { name: string; id: string };
          $editable: false | true;
          $orchestration: false | true;
          $in_merge: false | true;
          Created_By: { name: string; id: string; email: string };
          $approval_state: string;
          Reschedule_Note: string;
        }[];
      },
    ) {
      const url = new URL(
        `https://zohoapis.com/crm/v8/Appointments_Rescheduled_History__s`,
      );
    
      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