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) Controller
private static String
(package private) org.apache.http.impl.client.CloseableHttpClient
private 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.JSONObject
createAddEventBody(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.JSONObject
retrieveEvents(String calId)
Retrieves event from calendarvoid
saveAccessToken(String authCode, String discordId)
Saves received access token to db and perform some basic functionalities like getting access token and refresh token further.void
This 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:Calendar
This is temporary function, until spring session variables are not maintained- Specified by:
setUserVariable
in interfaceCalendar
-
authenticate
Description copied from interface:Calendar
It serves any authenticate request- Specified by:
authenticate
in interfaceCalendar
- Parameters:
discordId
- User unique identifier- Returns:
- URL for authentication
-
saveAccessToken
Description copied from interface:Calendar
Saves received access token to db and perform some basic functionalities like getting access token and refresh token further.- Specified by:
saveAccessToken
in interfaceCalendar
- Parameters:
authCode
- auth codediscordId
- user Id
-
retrieveEvents
Description copied from interface:Calendar
Retrieves event from calendar- Specified by:
retrieveEvents
in 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:Calendar
Updates existing events to calendar- Specified by:
updateEvents
in 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:Calendar
Adds 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:Calendar
Deletes one or some event- Specified by:
deleteEvents
in interfaceCalendar
- Returns:
- Calendar response
-
createNewUnscheduledCalendar
Description copied from interface:Calendar
Create a new Unscheduled calendar in user's selected calendar- Specified by:
createNewUnscheduledCalendar
in interfaceCalendar
- Returns:
- Calendar response
-