Package com.se21.calbot.services
Class GoogleCalendarService
java.lang.Object
com.se21.calbot.services.GoogleCalendarService
- All Implemented Interfaces:
Calendar
Google Calendar operations are managed through this class.
It implements all functionalities of Calendar interface.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets(package private) Controllerprivate static String(package private) org.apache.http.impl.client.CloseableHttpClientprivate static com.google.api.client.json.JsonFactory(package private) TokensRepository(package private) User -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds event to calendar, currently you can only add unscheduled events i.e.authenticate(String discordId)It serves any authenticate requestorg.json.simple.JSONObjectcreateAddEventBody(org.joda.time.DateTime startDt, org.joda.time.DateTime endDt, String title)Create a new Unscheduled calendar in user's selected calendarDeletes one or some eventorg.json.JSONObjectretrieveEvents(String calId)Retrieves event from calendarvoidsaveAccessToken(String authCode, String discordId)Saves received access token to db and perform some basic functionalities like getting access token and refresh token further.voidThis is temporary function, until spring session variables are not maintainedupdateEvents(org.json.simple.JSONObject req)Updates existing events to calendar
-
Field Details
-
tokensRepository
-
controller
-
user
User user -
CREDENTIALS_FILE_PATH
- See Also:
- Constant Field Values
-
JSON_FACTORY
private static final com.google.api.client.json.JsonFactory JSON_FACTORY -
SCOPES
-
httpClient
org.apache.http.impl.client.CloseableHttpClient httpClient -
clientSecrets
private com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets clientSecrets
-
-
Constructor Details
-
GoogleCalendarService
public GoogleCalendarService()
-
-
Method Details
-
setUserVariable
public void setUserVariable()Description copied from interface:CalendarThis is temporary function, until spring session variables are not maintained- Specified by:
setUserVariablein interfaceCalendar
-
authenticate
Description copied from interface:CalendarIt serves any authenticate request- Specified by:
authenticatein interfaceCalendar- Parameters:
discordId- User unique identifier- Returns:
- URL for authentication
-
saveAccessToken
Description copied from interface:CalendarSaves received access token to db and perform some basic functionalities like getting access token and refresh token further.- Specified by:
saveAccessTokenin interfaceCalendar- Parameters:
authCode- auth codediscordId- user Id
-
retrieveEvents
Description copied from interface:CalendarRetrieves event from calendar- Specified by:
retrieveEventsin interfaceCalendar- Parameters:
calId- calendar id(One google calendar can have multiple calendars at same time)- Returns:
- JSON objects of calendar returned events
- Throws:
Exception
-
updateEvents
Description copied from interface:CalendarUpdates existing events to calendar- Specified by:
updateEventsin interfaceCalendar- Parameters:
req- type is JSON object, exact parameters not yet decided, but can be changed based on different type of calendars- Returns:
- response from calendar
-
createAddEventBody
public org.json.simple.JSONObject createAddEventBody(org.joda.time.DateTime startDt, org.joda.time.DateTime endDt, String title) -
addEvents
Description copied from interface:CalendarAdds event to calendar, currently you can only add unscheduled events i.e. when there is no start date but only deadline and number of hours need to be dedicated -
deleteEvents
Description copied from interface:CalendarDeletes one or some event- Specified by:
deleteEventsin interfaceCalendar- Returns:
- Calendar response
-
createNewUnscheduledCalendar
Description copied from interface:CalendarCreate a new Unscheduled calendar in user's selected calendar- Specified by:
createNewUnscheduledCalendarin interfaceCalendar- Returns:
- Calendar response
-