Class: GoogleDrive::Session
- Inherits:
-
Object
- Object
- GoogleDrive::Session
- Defined in:
- lib/model_to_googlesheet/google_drive/session.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#exact_ss(title) ⇒ Object
spreadsheets(title:) returns trashed files too.
- #exact_sss(title) ⇒ Object
- #get_or_create_ss(title) ⇒ Object
Class Method Details
.new_for_gs(client_id: nil, client_secret: nil, refresh_token: nil) ⇒ Object
5 6 7 8 9 10 11 |
# 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 |
Instance Method Details
#exact_ss(title) ⇒ Object
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
21 22 23 |
# File 'lib/model_to_googlesheet/google_drive/session.rb', line 21 def exact_ss title exact_sss(title).first end |
#exact_sss(title) ⇒ Object
24 25 26 27 |
# 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) ⇒ Object
13 14 15 16 |
# 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 |