class PeopleGroup::Connectors::GoogleSheets

Public Instance Methods

spreadsheet(title) click to toggle source
# File lib/peoplegroup/connectors/google_sheets.rb, line 8
def spreadsheet(title)
  retry_on_error { session.spreadsheet_by_title(title) }
end
worksheet(spreadsheet_title, worksheet_title) click to toggle source
# File lib/peoplegroup/connectors/google_sheets.rb, line 12
def worksheet(spreadsheet_title, worksheet_title)
  worksheets = retry_on_error { spreadsheet(spreadsheet_title).worksheets }
  worksheets.find { |worksheet| worksheet.title == worksheet_title }
end

Private Instance Methods

retry_on_error(&block) click to toggle source
# File lib/peoplegroup/connectors/google_sheets.rb, line 27
def retry_on_error(&block)
  Utils.retry_on_error(errors: [Google::Apis::ServerError], delay: 3, max_attempts: 4, &block)
end
service_account_key() click to toggle source
# File lib/peoplegroup/connectors/google_sheets.rb, line 19
def service_account_key
  StringIO.new(Base64.strict_decode64(ENV['GOOGLE_SERVICE_ACCOUNT_KEY']))
end
session() click to toggle source
# File lib/peoplegroup/connectors/google_sheets.rb, line 23
def session
  @session ||= retry_on_error { GoogleDrive::Session.from_service_account_key(service_account_key) }
end