Edits history of script submission #23438 for ' Get Meeting Link Availability (hubspot)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Meeting Link Availability
     * Retrieve the open time slots of a scheduling page, by its slug. `timezone` is an IANA name such as Europe/Paris. Requires scheduler.meetings.meeting-link.read.
     */
    export async function main(
      auth: RT.Hubspot,
      slug: string,
      timezone: string,
      month_offset: number | undefined
    ) {
      const url = new URL(
        `https://api.hubapi.com/scheduler/v3/meetings/meeting-links/book/availability-page/${slug}`
      )
      url.searchParams.append("timezone", timezone)
      if (month_offset != null)
        url.searchParams.append("monthOffset", String(month_offset))
    
      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