Class: GoogleSpreadsheetFetcher::Fetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/google_spreadsheet_fetcher/fetcher.rb

Constant Summary collapse

OOB_URI =
'urn:ietf:wg:oauth:2.0:oob'

Instance Method Summary collapse

Constructor Details

#initialize(spreadsheet_id, user_id, config: nil, application_name: nil) ⇒ Fetcher

Returns a new instance of Fetcher.

Parameters:



14
15
16
17
18
19
# File 'lib/google_spreadsheet_fetcher/fetcher.rb', line 14

def initialize(spreadsheet_id, user_id, config: nil, application_name: nil)
  @spreadsheet_id = spreadsheet_id
  @user_id = user_id
  @config = config || GoogleSpreadsheetFetcher.config
  @application_name = application_name
end

Instance Method Details

#fetch_all_rows_by!(index: nil, sheet_id: nil, title: nil, skip: 0, structured: false) ⇒ Object



21
22
23
24
# File 'lib/google_spreadsheet_fetcher/fetcher.rb', line 21

def fetch_all_rows_by!(index: nil, sheet_id: nil, title: nil, skip: 0, structured: false)
  sheet = fetch_sheet_by!(index: index, sheet_id: sheet_id, title: title)
  fetch_all_rows(sheet, skip: skip, structured: structured)
end

#serviceObject



26
27
28
29
30
31
# File 'lib/google_spreadsheet_fetcher/fetcher.rb', line 26

def service
  @service ||= Google::Apis::SheetsV4::SheetsService.new.tap do |service|
    service.authorization = fetch_credentials
    service.client_options.application_name = @application_name if @application_name.present?
  end
end