Edits history of script submission #16574 for ' Get Email Hooks (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Get Email Hooks
     * Fetches existing email hooks.
    
    An email hook allows you to pass data into Kustomer by sending HTML email. Creating an email hook will return an email address.
    
    Any email received at that address will be parsed to extract json data. For added security, the email data requires inclusion of
    a key.
    
    The key should be included in the script tag within the html body of the email message along with the script type, i.e. ``````
    
     This endpoint will return a maximum of 10 pages with 99 entries.
     */
    export async function main(auth: Kustomer) {
      const url = new URL(`https://api.kustomerapp.com/v1/hooks/email`);
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: "Bearer " + auth.apiKey,
        },
        body: undefined,
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 235 days ago