class GoogleDrive::Session

Public Class Methods

new_for_gs(client_id: nil, client_secret: nil, refresh_token: nil) click to toggle source
# File lib/model_to_googlesheet/google_drive/session.rb, line 5
def self.new_for_gs client_id: nil, client_secret: nil, refresh_token: nil
        auth = GoogleDrive::AuthenticationHelper.set_auth client_id, client_secret

        auth.refresh_token = refresh_token
        auth.fetch_access_token!
        @session = login_with_oauth(auth.access_token) 
end

Public Instance Methods

exact_ss(title) click to toggle source

spreadsheets(title:) returns trashed files too. gs doesn’t allow to create worksheets with the same title in one spreadsheet and it doesn’t trash ws-s

# File lib/model_to_googlesheet/google_drive/session.rb, line 21
def exact_ss title
        exact_sss(title).first
end
exact_sss(title) click to toggle source
# File lib/model_to_googlesheet/google_drive/session.rb, line 24
def exact_sss title
        spreadsheets(title: title, :'title-exact' => true).select { |ss| !ss.labels.trashed }
        # (:'title-exact' => true this stupid form is for ruby 2.1)
end
get_or_create_ss(title) click to toggle source
# File lib/model_to_googlesheet/google_drive/session.rb, line 13
def get_or_create_ss title
        ss = exact_ss title
        ss ||= create_spreadsheet(title)
end