class Flypbook::GoogleDrive

Public Class Methods

new(client_id, client_secret, refresh_token) click to toggle source
# File lib/flypbook/google_drive.rb, line 5
def initialize(client_id, client_secret, refresh_token)
  credentials = ::Google::Auth::UserRefreshCredentials.new(
    client_id: client_id,
    client_secret: client_secret,
    scope: ::GoogleDrive::Session::DEFAULT_SCOPE,
    redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
    refresh_token: refresh_token
  )
  @session = ::GoogleDrive::Session.new(credentials)
end

Public Instance Methods

upload() click to toggle source
# File lib/flypbook/google_drive.rb, line 16
def upload
  root_collection = @session.root_collection
  flypbook = root_collection.subcollection_by_title('Flypbook') || root_collection.create_subcollection('Flypbook')
  current_run_collection = flypbook.create_subcollection "journey_#{DateTime.now}"
  PhotoStore.screenshots.each do |screenshot|
    current_run_collection.add @session.upload_from_file(screenshot, screenshot, convert: false)
  end
end