Class GoogleCalendarService

java.lang.Object
com.se21.calbot.services.GoogleCalendarService
All Implemented Interfaces:
Calendar

@Service public class GoogleCalendarService extends Object implements Calendar
Google Calendar operations are managed through this class. It implements all functionalities of Calendar interface.
  • Field Details

    • tokensRepository

      @Autowired TokensRepository tokensRepository
    • controller

      @Autowired Controller controller
    • user

      User user
    • CREDENTIALS_FILE_PATH

      private static final String CREDENTIALS_FILE_PATH
      See Also:
      Constant Field Values
    • JSON_FACTORY

      private static final com.google.api.client.json.JsonFactory JSON_FACTORY
    • SCOPES

      private static final List<String> 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 interface Calendar
    • authenticate

      public String authenticate(String discordId)
      Description copied from interface: Calendar
      It serves any authenticate request
      Specified by:
      authenticate in interface Calendar
      Parameters:
      discordId - User unique identifier
      Returns:
      URL for authentication
    • saveAccessToken

      public void saveAccessToken(String authCode, String discordId)
      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 interface Calendar
      Parameters:
      authCode - auth code
      discordId - user Id
    • retrieveEvents

      public org.json.JSONObject retrieveEvents(String calId) throws Exception
      Description copied from interface: Calendar
      Retrieves event from calendar
      Specified by:
      retrieveEvents in interface Calendar
      Parameters:
      calId - calendar id(One google calendar can have multiple calendars at same time)
      Returns:
      JSON objects of calendar returned events
      Throws:
      Exception
    • updateEvents

      public Enums.calApiResponse updateEvents(org.json.simple.JSONObject req)
      Description copied from interface: Calendar
      Updates existing events to calendar
      Specified by:
      updateEvents in interface Calendar
      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

      public Enums.calApiResponse addEvents(String title, String hours, String deadline)
      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
      Specified by:
      addEvents in interface Calendar
      Parameters:
      title - Event title
      hours - Number of hours to be dedicated
      deadline - deadline for this activity
      Returns:
      Calendar response
    • deleteEvents

      public Enums.calApiResponse deleteEvents()
      Description copied from interface: Calendar
      Deletes one or some event
      Specified by:
      deleteEvents in interface Calendar
      Returns:
      Calendar response
    • createNewUnscheduledCalendar

      public Enums.calApiResponse createNewUnscheduledCalendar()
      Description copied from interface: Calendar
      Create a new Unscheduled calendar in user's selected calendar
      Specified by:
      createNewUnscheduledCalendar in interface Calendar
      Returns:
      Calendar response