Edits history of script submission #23302 for ' Get Event (gcal)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Get Event
     * Get one event by id: title, times, attendees and their RSVPs, recurrence, conference link, etc. For an instance of a recurring event (id `<series>_<start>`), `recurringEventId` points at the series.
     */
    export async function main(
      auth: RT.Gcal,
      event_id: string,
      calendar_id: string = "primary",
      time_zone: string | undefined
    ) {
      const url = new URL(
        `https://www.googleapis.com/calendar/v3/calendars/${encodeURIComponent(calendar_id || "primary")}/events/${event_id}`
      )
      if (time_zone != null && time_zone !== "")
        url.searchParams.append("timeZone", time_zone)
    
      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 6 hours ago