Edits history of script submission #16671 for ' Get forward attachment (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Get forward attachment
     * Retrieves a forward attachment.
    
    ### Pre-signed URL
    
    When you request the resource, the response will include a **related** URL in the **links** section. You can use this URL to download the attachment file.  This URL is a Pre-Signed URL from S3 and provides access for a limited duration to download a file.
     */
    export async function main(auth: Kustomer, id: string, attachmentId: string) {
      const url = new URL(
        `https://api.kustomerapp.com/v1/forwards/${id}/attachments/${attachmentId}`,
      );
    
      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