Edits history of script submission #23830 for ' List Locales (zendesk)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Locales
     * List the locales enabled on the account (e.g. `en-us`, `fr`), for the Help Center and dynamic content `locale` parameters.
     */
    export async function main(auth: RT.Zendesk) {
      const response = await fetch(
        `https://${auth.subdomain}.zendesk.com/api/v2/locales`,
        {
          headers: {
            Authorization: auth.token
              ? `Bearer ${auth.token}`
              : `Basic ${btoa(`${auth.username}:${auth.password}`)}`,
            Accept: "application/json",
          },
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 days ago