Class: Nexo::GoogleCalendarSyncService

Inherits:
GoogleCalendarService show all
Defined in:
app/lib/nexo/api_client/google_calendar_sync_service.rb

Instance Attribute Summary

Attributes inherited from CalendarService

#integration

Instance Method Summary collapse

Methods inherited from GoogleCalendarService

#fields_from_payload, #get_calendar, #get_event, #insert, #insert_calendar, #remove, #remove_calendar, #update, #update_calendar

Methods inherited from CalendarService

#initialize

Constructor Details

This class inherits a constructor from Nexo::CalendarService

Instance Method Details

#full_or_incremental_sync!(folder) ⇒ Object



23
24
25
26
27
28
29
# File 'app/lib/nexo/api_client/google_calendar_sync_service.rb', line 23

def full_or_incremental_sync!(folder)
  if folder.google_next_sync_token.present?
    incremental_sync!(folder)
  else
    full_sync!(folder)
  end
end

#full_sync!(folder) ⇒ Object



3
4
5
6
# File 'app/lib/nexo/api_client/google_calendar_sync_service.rb', line 3

def full_sync!(folder)
  Nexo.logger.info("performing full sync")
  sync!(folder)
end

#incremental_sync!(folder) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/lib/nexo/api_client/google_calendar_sync_service.rb', line 8

def incremental_sync!(folder)
  raise Nexo::Errors::Error, "no sync token" if folder.google_next_sync_token.blank?

  Nexo.logger.info("performing incremental sync")

  sync!(folder, sync_token: folder.google_next_sync_token)
rescue Google::Apis::ClientError => e
  if e.message.match /fullSyncRequired/
    Nexo.logger.warn "Full sync required: #{e}"
    full_sync!(folder)
  else
    raise
  end
end