Edits history of script submission #14547 for ' Update file request (box)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Box = {
      token: string;
    };
    /**
     * Update file request
     * Updates a file request. This can be used to activate or
    deactivate a file request.
     */
    export async function main(
      auth: Box,
      file_request_id: string,
      if_match: string,
      body: {
        title?: string;
        description?: string;
        status?: "active" | "inactive";
        is_email_required?: false | true;
        is_description_required?: false | true;
        expires_at?: string;
      },
    ) {
      const url = new URL(
        `https://api.box.com/2.0/file_requests/${file_request_id}`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        headers: {
          "if-match": if_match,
          "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