Google Calendar
With the Google Calendar adapter you can create or edit events in the Google Calendar from within IYOPRO.
To be able to interact with Google Calendar, you need authorization. The following link shows possibilities on how to
get this authorization:
https://developers.google.com/identity/protocols/oauth2/service-account
Check and adjust the service account and the json file entry in the GoogleCalendar.config.
You should have received a json file after creating the service account. We recommend storing the json file in the
folder with the Google Calendar dlls. You can look up the path to your adapter directory in the Backend.config.
Adapter
public class Adapter : IDisposable
Properties
string DefaultTimezone
-
The default time zone for all Google Calendar events attached to your account (time zone set for your Google account)
Methods
Adapter()
-
The constructor
Event[] GetEvents(string calendarId, DateTime? from = null, DateTime? to = null)
-
Gets an array with the events of the calendar that belongs to the calendar ID. The period can be limited with "from" and "to"
Color[] GetEventColors()
-
Gets the colors defined in the Google Calendar as an array
Event.SourceData CreateEventSourceData(string title = null, string url = null)
-
Create source data for the event
Event GetEvent(string calendarId, string eventId)
-
Get the event that has the specified event ID and is in the calendar that the specified calendar ID belongs to
Event InsertEvent(string calendarId, string summary, string description, DateTime start, DateTime end, bool fullDay = false, string timezone = null, string colorId = null)
-
Add an event to a specific calendar using the calendar id. You can add a summary (title of the event) and a description. Enter the time period of the event and whether it is an all-day event or not. You can change the time zone of the event and its color using the color ID
Event CreateEvent(string summary, string description, DateTime start, DateTime end, bool fullDay = false, string timezone = null, string colorId = null)
-
Create an event with specific properties
Event InsertEvent(string calendarId, Event ev)
-
Add an event to a specific calendar using the calendar id.
void DeleteEvent(string calendarId, string eventId)
-
Delete the event with the specified event ID from the calendar. If the event is recurring, use RecurringEventId to delete the following events as well
Event UpdateEvent(string calendarId, Event ev)
-
Update an event of the calendar that the specified calendar ID belongs to
EventDateTime ToEventDateTime(DateTime dateTime, bool fullDay = false, string timezone = null)
-
Change a C# DateTime value to an EventDateTime value with the additional information about the time zone and whether it is an all-day event
DateTime? ToDateTime(EventDateTime eventDateTime)
-
Change an EventDateTime value to a C# DateTime value
void Dispose()
-
Releases the resources used
You can also use the event resources of the Calendar API.
Example
This example inserts an event into a Google Calendar and prints the id of that event
import clr
clr.AddReferenceToFileAndPath(Session.GetAdapterPath("GOOGLECALENDAR"))
from IYOPRO.GoogleCalendar import Adapter
from System import DateTime
calendarId = "<Google Calendar id>"
with Adapter() as gc:
event = gc.InsertEvent(calendarId, "IYOPRO Google Calendar adapter test", "Generated in script task", DateTime.Now.AddHours(24), DateTime.Now.AddHours(25))
print event.Id