Attach Calendar
This API endpoint is triggered by the extension interface when a Google calendar is selected to be attached with a Scrims calendar for two way sync.
Endpoint
POST /google/calendars/attach HTTP/1.1
Host: api.atomcal.com/api/v2
Content-Type: application/x-www-form-urlencoded
Triggered by: Extension interface
Authentication: security.verifyAuthToken
Query: req.query.calendar_id, req.query.scrims_calendar_id
It also makes sure that if a Google calendar is already attached with Scrims calendar then it doesn't attach it again.
Example Responses
200 (successful operation)
res.status(200).send({ calendars });
400 (bad response)
Boom.badRequest(errorMessage)
Implementation details
Attach Google calendar
Using the Google calendar id passed by the extension interface as query param pick the locally saved Google calendar and save the passed Scrims calendar id.
Synchronize the calendar events
Finally synchronize Scrims calendar events to this Google calendar and Google calendar events to this Scrims calendar using appropriate endpoints.
`${baseUrl}/api/v2/calendars/${googleCalendar.atomcal_calendar_id}/events`
`https://www.googleapis.com/calendar/v3/calendars/${calendarIdEncoded}/events`
Register notification channels
Register notification channels for Google calendar and Scrims calendar.
Return all Google calendars
Finally read all the google calendars using the member id obtained from the token authenticator service and return all saved Google calendars.
Edge cases
Incase the Google calendar isn't found, or another Scrims calendar is already attached with this Google calendar bad request error will be sent.