Edits history of script submission #14334 for ' Create Box Sign request (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Create Box Sign request
     * Creates a signature request. This involves preparing a document for signing and
    sending the signature request to signers.
     */
    export async function main(
      auth: Box,
      body: {
        is_document_preparation_needed?: false | true;
        redirect_url?: string;
        declined_redirect_url?: string;
        are_text_signatures_enabled?: false | true;
        email_subject?: string;
        email_message?: string;
        are_reminders_enabled?: false | true;
        name?: string;
        prefill_tags?: {
          document_tag_id?: string;
          text_value?: string;
          checkbox_value?: false | true;
          date_value?: string;
        }[];
        days_valid?: number;
        external_id?: string;
        template_id?: string;
        external_system_name?: string;
      } & {
        source_files?: { id: string; etag?: string; type: "file" }[];
        signature_color?: "blue" | "black" | "red";
        signers?: {
          email?: string;
          role?: "signer" | "approver" | "final_copy_reader";
          is_in_person?: false | true;
          order?: number;
          embed_url_external_user_id?: string;
          redirect_url?: string;
          declined_redirect_url?: string;
          login_required?: false | true;
          password?: string;
          signer_group_id?: string;
          suppress_notifications?: false | true;
        }[];
        parent_folder?: { id: string; etag?: string; type: "folder" } & {
          sequence_id?: string & {};
          name?: string;
        } & {};
      },
    ) {
      const url = new URL(`https://api.box.com/2.0/sign_requests`);
    
      const response = await fetch(url, {
        method: "POST",
        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 235 days ago