Skip to content

Commit fcd8ed6

Browse files
getCalender & getEvent commands added
1 parent 3933de6 commit fcd8ed6

File tree

2 files changed

+432
-1
lines changed

2 files changed

+432
-1
lines changed

docs/Google.md

Lines changed: 232 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ The `Google` class is instantiated by calling the `cs.NetKit.Google.new()` funct
1414
## Table of contents
1515

1616
- [cs.NetKit.Google.new()](#csnetkitgooglenew)
17+
- [Google.Calendar.getCalendar()](#googlecalendargetcalendar)
18+
- [Google.Calendar.getCalendars()](#googlecalendargetCalendars)
19+
- [Google.Calendar.getEvent()](#googlecalendargetevent)
20+
- [Google.Calendar.getEvents()](#googlecalendargetevents)
1721
- [Google.mail.append()](#googlemailappend)
1822
- [Google.mail.createLabel()](#googlemailcreatelabel)
1923
- [Google.mail.delete()](#googlemaildelete)
@@ -80,6 +84,234 @@ var $google : cs.NetKit.Google
8084
$oAuth2:=New OAuth2 provider($param)
8185
$google:=cs.NetKit.Google.new($oAuth2;New object("mailType"; "MIME"))
8286
```
87+
88+
## Google.Calendar.getCalendar()
89+
90+
**Google.Calendar.getCalendar**( { *id* : Text } ) : Object
91+
92+
### Parameters
93+
94+
|Parameter|Type||Description|
95+
|---------|--- |:---:|------|
96+
|id|Text|->|ID of the calender to retrieve. |
97+
|calendar|Object|<-| Object containing the details of the specified calendar. For more details, see the [Google Calendar API resource](https://developers.google.com/calendar/api/v3/reference/calendarList#resource).|
98+
99+
> To retrieve calendar IDs call the getCalendars() function. If id is null, empty or missing, returns the primary calendar of the currently logged in user.
100+
101+
### Description
102+
103+
`Google.Calendar.getCalendar()` retrieves a specific calendar from the authenticated user's calendar list; using an `id` to identify the calendar and returns a `calendar` object containing details about the requested calendar.
104+
105+
### Example
106+
107+
```4d
108+
109+
var $google : cs.NetKit.Google
110+
var $oauth2 : cs.NetKit.OAuth2Provider
111+
var $param; $Calendars; $myCalendar : Object
112+
113+
$param:={}
114+
$param.name:="google"
115+
$param.permission:="signedIn"
116+
$param.clientId:="your-client-id" // Replace with your Google identity platform client ID
117+
$param.clientSecret:="xxxxxxxxx"
118+
$param.redirectURI:="http://127.0.0.1:50993/authorize/"
119+
$param.scope:=[]
120+
$param.scope.push("https://mail.google.com/")
121+
$param.scope.push("https://www.googleapis.com/auth/calendar")
122+
123+
$oauth2:=New OAuth2 provider($param)
124+
125+
$google:=cs.NetKit.Google.new($oauth2)
126+
127+
// Retrieve the entire list of calendars
128+
$Calendars:=$google.calendar.getCalendars()
129+
130+
// Retrieve the first calendar in the list using its ID
131+
$myCalendar:=$google.calendar.getCalendar($Calendars.calendars[0].id)
132+
133+
```
134+
135+
136+
## Google.Calendar.getCalendars()
137+
138+
**Google.Calendar.getCalendar**( { *param* : Object } ) : Object
139+
140+
### Parameters
141+
142+
|Parameter|Type||Description|
143+
|---------|--- |:---:|------|
144+
|param|Object|->|Set of options to filter or refine the calendar list request.|
145+
|Result|Object|<-|Object containing the calendar list with the related data.|
146+
147+
### Description
148+
149+
`Google.Calendar.getCalendars()` retrieves a list of calendars that the authenticated user can access. The passed filtering and paging options in `param` are returned in the `result` object.
150+
151+
In *param*, you can pass the following optional properties:
152+
153+
|Property|Type|Description|
154+
|---------|--- |------|
155+
| maxResults | Integer | Maximum number of calendar entries returned per page. Default is 100. Maximum is 250.|
156+
| minAccessRole | String | Minimum access role for the user in the returned calendars. Default is no restriction. Acceptable values:|
157+
| | |- "freeBusyReader": User can read free/busy information. |
158+
| | |- "owner": User can read, modify events, and control access. |
159+
| | |- "reader": User can read non-private events. |
160+
| | |- "writer": User can read and modify events. |
161+
| showDeleted | Boolean | Whether to include deleted calendar list entries in the result. Optional. The default is False.|
162+
| showHidden | Boolean | Whether to show hidden entries. Optional. The default is False.|
163+
164+
### Returned object
165+
166+
The function returns a Collection of details about the user's calendar list in the following properties:
167+
168+
| **Property** | **Type** | **Description** |
169+
|----------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
170+
| `calendars` | Collection | Collection of calendar objects present in the user's calendar list. Each calendar object contains details such as `id`, `summary`, and `accessRole`. |
171+
| `isLastPage` | Boolean | `True` if the last page of results has been reached. |
172+
| `page` | Integer | Current page number of results. Starts at `1`. By default, each page holds 100 results. |
173+
| `next()` | Function | Loads the next page of calendar entries and increments the `page` property by 1. Returns: |
174+
| | | - `True` if the next page is loaded successfully. |
175+
| | | - `False` if no additional pages are available (the collection is not updated). |
176+
| `previous()` | Function | Loads the previous page of calendar entries and decrements the `page` property by 1. Returns: |
177+
| | | - `True` if the previous page is loaded successfully. |
178+
| | | - `False` if no previous pages are available (the collection is not updated). |
179+
| `statusText` | Text | Status message returned by the Google server or the last error message from the 4D error stack. |
180+
| `success` | Boolean | `True` if the operation is successful, `False` otherwise. |
181+
| `errors` | Collection | Collection of 4D error items (if any): |
182+
| | | - `.errcode`: 4D error code number. |
183+
| | | - `.message`: Error description. |
184+
| | | - `.componentSignature`: Signature of the component that returned the error. |
185+
186+
187+
### Example
188+
189+
```4d
190+
191+
var $google : cs.NetKit.Google
192+
var $oauth2 : cs.NetKit.OAuth2Provider
193+
var $param; $Calendars : Object
194+
195+
$param:={}
196+
$param.name:="google"
197+
$param.permission:="signedIn"
198+
$param.clientId:="your-client-id" // Replace with your Google identity platform client ID
199+
$param.clientSecret:="xxxxxxxxx"
200+
$param.redirectURI:="http://127.0.0.1:50993/authorize/"
201+
$param.scope:=[]
202+
$param.scope.push("https://mail.google.com/")
203+
$param.scope.push("https://www.googleapis.com/auth/calendar")
204+
205+
$oauth2:=New OAuth2 provider($param)
206+
207+
$google:=cs.NetKit.Google.new($oauth2)
208+
209+
// Retrieve the entire list of calendars
210+
211+
$Calendars:=$google.calendar.getCalendars()
212+
213+
```
214+
## Google.Calendar.getEvent()
215+
216+
**Google.Calendar.getEvent**( *param* : Object ) : Object
217+
218+
### Parameters
219+
220+
|Parameter|Type||Description|
221+
|---------|--- |:---:|------|
222+
|param|Object|->|Object containing the necessary details to retrieve a specific event|
223+
|Result|Object|<-|Object containing the retrieved event|
224+
225+
### Description
226+
227+
`Google.Calendar.getEvent()` retrieves a specific event from a Google Calendar using its unique `eventId`.
228+
229+
In *param*, you can pass the following properties:
230+
231+
|Property|Type|Description|
232+
|---------|--- |------|
233+
| eventId | String | (Required) The unique identifier of the event to retrieve |
234+
| calendarId | String | Calendar identifier. To retrieve calendar IDs, call calendarList.list(). If not provided, the user's primary (currently logged-in) calendar is used |
235+
| maxAttendees | Integer | Max number of attendees to be returned for the event|
236+
| timeZone | String | Time zone used in the response (formatted as an IANA Time Zone Database name, e.g., "Europe/Zurich"). Defaults to UTC |
237+
238+
### Returned object
239+
240+
The function returns a Google [`event`](https://developers.google.com/calendar/api/v3/reference/events) object.
241+
242+
## Google.Calendar.getEvents()
243+
244+
**Google.Calendar.getEvents**( { *param* : Object } ) : Object
245+
246+
### Parameters
247+
248+
|Parameter|Type||Description|
249+
|---------|--- |:---:|------|
250+
|param|Object|->|Object containing filters and options for retrieving calendar events|
251+
|Result|Object|<-|Object containing the retrieved events|
252+
253+
### Description
254+
255+
`Google.Calendar.getEvents()` retrieves events on the specified calendar. If *param* is not provided, it returns all events from the user's primary calendar.
256+
257+
In *param*, you can pass the following optional properties:
258+
259+
|Property|Type|Description|
260+
|---------|--- |------|
261+
| calendarId | String | Calendar identifier. To retrieve calendar IDs, call `Google.Calendar.getCalendars()`. If not provided, the user's primary calendar is used. |
262+
| eventTypes | String | Specifies the types of events to return. Can be repeated multiple times to retrieve multiple event types. If not set, all event types are returned. Acceptable values: "birthday" (special all-day events with annual recurrence), "default" (regular events), "focusTime" (focus time events), "fromGmail" (events from Gmail), "outOfOffice" (out-of-office events), "workingLocation" (working location events). |
263+
| iCalUID | String | Searches for an event by its iCalendar ID. **Note:** `icalUID` and `id` are not identical. In recurring events, all occurrences have unique `id`s but share the same `icalUID`. |
264+
| maxAttendees | Integer | Limits the number of attendees to be returned per event|
265+
| top | Integer | Mximum number of events per page. Default is `250`, maximum is `2500`. |
266+
| orderBy | String | Specifies how events should be ordered in the response. Default is an **unspecified but stable order**. Acceptable values: "startTime" (ascending, only when `singleEvents=True`), "updated" (ascending order of last modification time). |
267+
| privateExtendedProperty | Collection | Returns events that match these properties specified as propertyName=value |
268+
| search | String | Searches for events using free text in multiple fields, including summary, description, location, attendee names/emails, organizer names/emails, and working location properties. Also matches predefined keywords for out-of-office, focus-time, and working-location events. |
269+
| sharedExtendedProperty | Collection | Returns events that match these properties specified as propertyName=value. The returned events match **all** specified constraints |
270+
| showDeleted | Boolean | Whether to include deleted events (`status="cancelled"`) in the result. Defaults to `False`. Behavior depends on the `singleEvents` setting |
271+
| showHiddenInvitations | Boolean | Whether to include hidden invitations in the result. Defaults to `False` |
272+
| singleEvents | Boolean | Whether to expand recurring events into instances and return only individual events and instances, **excluding** the underlying recurring event. Defaults to `False` |
273+
| startDateTime | Text, Object | Filters events by start time. If set, `endDateTime` must also be provided. **Text:** ISO 8601 UTC timestamp. **Object:** Must contain `date` (date type) and `time` (time type), formatted according to system settings |
274+
| endDateTime | Text, Object | Filters events by end time. If set, `startDateTime` must also be provided. **Text:** ISO 8601 UTC timestamp. **Object:** Must contain `date` (date type) and `time` (time type), formatted according to system settings |
275+
| timeZone | String | Time zone for the response, formatted as an IANA Time Zone Database name (e.g., "Europe/Zurich"). Defaults to UTC |
276+
| updatedMin | Text | Filters events based on last modification time (`ISO 8601 UTC`). When set, deleted events since this time are always included, regardless of `showDeleted` |
277+
278+
### Returned object
279+
280+
The method returns a [**status object**](#status-object-google-class) in addition to the following properties:
281+
282+
| Property | Type | Description |
283+
|---| ---|---|
284+
| isLastPage | Boolean | True if the last page is reached. |
285+
| page | Integer | Page number of the user information. Defaults to 1, with a page size of 100 (configurable via top). |
286+
| next() | Function | Fetches the next page of users, increments page by 1. Returns True if successful, False otherwise. |
287+
| previous() | Function | Fetches the previous page of users, decrements page by 1. Returns True if successful, False otherwise. |
288+
| kind | String | Type of collection ("calendar#events"). |
289+
| etag | String | ETag of the collection. |
290+
| summary | String | Title of the calendar (read-only). |
291+
| calendarId | String | Calendar identifier, same as the calendarId passed in the parameter if present. |
292+
| description | String | Description of the calendar (read-only). |
293+
| updated | Text | Last modification time of the calendar (ISO 8601 UTC). |
294+
| timeZone | String | Time zone of the calendar (formatted as an IANA Time Zone Database name, e.g., "Europe/Zurich"). |
295+
| accessRole | String | User’s access role for the calendar (read-only). Possible values: "none", "freeBusyReader", "reader", "writer", "owner". |
296+
| defaultReminders | Collection | Default reminders for the authenticated user. Applies to events that do not explicitly override them. |
297+
| defaultReminders[].method | String | Method used for the reminder ("email" or "popup"). |
298+
| defaultReminders[].minutes | Integer | Minutes before the event when the reminder triggers. |
299+
| events | Collection | List of events on the calendar. If some events have attachments, an "attachments" attribute is added, containing a collection of attachments. |
300+
301+
### Example
302+
303+
```4d
304+
305+
// Gets all the calendars
306+
var $calendars:=$google.calendar.getCalendars()
307+
// For the rest of the example, we'll use the first calendar in the list
308+
var $myCalendar:=$calendars.calendars[0]
309+
310+
// Gets all the event of the selected calendars
311+
var $events:=$google.calendar.getEvents({calendarId: $myCalendar.id; top: 10})
312+
313+
```
314+
83315
## Google.mail.append()
84316

85317
**Google.mail.append**( *mail* : Text { ; *labelIds* : Collection } ) : Object <br/>
@@ -499,7 +731,6 @@ https://mail.google.com/
499731
https://www.googleapis.com/auth/gmail.modify
500732
```
501733

502-
503734
## Google.mail.update()
504735

505736
**Google.mail.update**( *mailIDs* : Collection ; *options* : Object) : Object

0 commit comments

Comments
 (0)