Mercurial > code > home > repos > gcalendarwatch
annotate calsync/gcalclient/event_requests.go @ 70:06f3aa9d461c
page size
author | drewp@bigasterisk.com |
---|---|
date | Fri, 06 Sep 2024 17:30:27 -0700 |
parents | 8aee4f5c4bdd |
children |
rev | line source |
---|---|
53 | 1 package gcalclient |
2 | |
3 import ( | |
4 "time" | |
5 | |
6 "google.golang.org/api/calendar/v3" | |
7 ) | |
8 | |
70 | 9 const pageSize = 200 |
61
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
10 const notificationsUrl1 = "https://bigasterisk.com" |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
11 const notificationsUrl2 = "/gcalendarwatch/notifications" |
53 | 12 |
57 | 13 func rangedEventsCall(srv *calendar.Service, calGoogleId string, initialFillStart, initialFillEnd time.Time, pageToken string) *calendar.EventsListCall { |
53 | 14 return srv.Events.List(calGoogleId). |
15 ShowDeleted(false). | |
16 SingleEvents(true). | |
17 TimeMin(initialFillStart.Format(time.RFC3339)). | |
18 TimeMax(initialFillEnd.Format(time.RFC3339)). | |
19 MaxResults(pageSize). | |
20 PageToken(pageToken) | |
21 } | |
22 | |
57 | 23 func syncEventsCall(srv *calendar.Service, calGoogleId string, syncToken, pageToken string) *calendar.EventsListCall { |
53 | 24 return srv.Events.List(calGoogleId). |
25 ShowDeleted(true). | |
26 SingleEvents(true). | |
57 | 27 MaxResults(pageSize). |
28 PageToken(pageToken). | |
29 SyncToken(syncToken) | |
53 | 30 } |
61
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
31 |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
32 func watchEventsCall(srv *calendar.Service, calGoogleId string, expire time.Duration, watchId string) *calendar.EventsWatchCall { |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
33 |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
34 return srv.Events.Watch(calGoogleId, &calendar.Channel{ |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
35 Address: notificationsUrl1 + notificationsUrl2, |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
36 Expiration: (time.Now().Add(expire)).UnixMilli(), |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
37 Id: watchId, |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
38 Type: "web_hook", |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
39 }) |
8aee4f5c4bdd
receive notifications and route them to calendar sync functions
drewp@bigasterisk.com
parents:
57
diff
changeset
|
40 } |