Edits history of script submission #16666 for ' Get default brand (kustomer)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Kustomer = {
      apiKey: string;
    };
    /**
     * Get default brand
     * Retrieves the default brand that was created for your Kustomer organization during registration.
    
    Learn more about the default brand in the [Kustomer Help Center](https://help.kustomer.com/create-and-manage-multiple-brands-ryc8HBZnD#customize).
    
    Any one of the following roles is required for this endpoint:
    
    |Legacy Role|Equivalent Permission Set Role|
    |-----|--------|
    |org.admin.brand.read|org.permission.brand.read|
    |org.user.brand.read|
     */
    export async function main(auth: Kustomer) {
      const url = new URL(`https://api.kustomerapp.com/v1/brands/default`);
    
      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