Edits history of script submission #23459 for ' List Marketing Events (hubspot)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List Marketing Events
     * List marketing events (webinars, conferences, ...) created in or synced to the account. Requires crm.objects.marketing_events.read.
     */
    export async function main(
      auth: RT.Hubspot,
      limit: number | undefined,
      after: string | undefined
    ) {
      const url = new URL(`https://api.hubapi.com/marketing/v3/marketing-events/`)
      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