Edits history of script submission #23452 for ' List Channels (hubspot)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Channels
     * List the conversation channels (email, chat, forms, ...) of the account. Requires conversations.read.
     */
    export async function main(
      auth: RT.Hubspot,
      limit: number | undefined,
      after: string | undefined
    ) {
      const url = new URL(
        `https://api.hubapi.com/conversations/v3/conversations/channels`
      )
      if (limit != null) url.searchParams.append("limit", String(limit))
      if (after != null && after !== "") url.searchParams.append("after", after)
    
      const response = await fetch(url, {
        headers: {
          Authorization: `Bearer ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 hours ago