Edits history of script submission #15937 for ' Update notification email (formstack)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Formstack = {
      token: string;
    };
    /**
     * /notification/:id
     * Update the specified notification email
     */
    export async function main(
      auth: Formstack,
      id: string,
      body: {
        name?: string;
        from_type: string;
        from_value: string;
        recipients: string;
        subject: string;
        type: string;
        hide_empty?: false | true;
        show_section?: false | true;
        message?: string;
        attach_limit?: number;
        format?: string;
        logic?: {};
      },
    ) {
      const url = new URL(
        `https://www.formstack.com/api/v2/notification/${id}.json`,
      );
    
      const response = await fetch(url, {
        method: "PUT",
        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