Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/main/java/com/se21/Calendar/GoogleCalendar.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.se21.Calendar;

import org.json.simple.JSONObject;
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.Event;

public class GoogleCalendar implements Calendar{

Expand Down Expand Up @@ -28,6 +30,47 @@ public Enums.calApiResponse updateEvents(JSONObject req) {

@Override
public Enums.calApiResponse addEvents() {
/*
Data requirements:
summary : name of the event
location
description
start date and time
end date and time
(The date and time at which you want the event to start in ISO format: YYYY-MM-DDThh:mm:ss+00:00. +00:00 is the timezone offset.
Timezone has been set to new york)
*/

String summary;
String location;
String description;
String startString; //strings to give i/p to DateTime()
String endString;

Event event = new Event()
.setSummary(summary)
.setLocation(location)
.setDescription(description);

DateTime startDateTime = new DateTime(startString);
EventDateTime start = new EventDateTime()
.setDateTime(startDateTime)
.setTimeZone("America/New_York");
event.setStart(start);

DateTime endDateTime = new DateTime();
EventDateTime end = new EventDateTime()
.setDateTime(endDateTime)
.setTimeZone("America/New_York");
event.setStart(end);

//recurrence code

//reminders code

String calendarId="primary";
event = service.events().insert(calendarId, event).execute();
System.out.printf("Event created: %s\n", event.getHtmlLink());

return Enums.calApiResponse.Success;
}
Expand Down