Class: GoogleSpreadsheetFetcher::SheetsServiceBuilder

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

Constant Summary collapse

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

Instance Method Summary collapse

Constructor Details

#initialize(user_id, config: nil, application_name: nil) ⇒ SheetsServiceBuilder

Returns a new instance of SheetsServiceBuilder.

Parameters:



13
14
15
16
17
18
# File 'lib/google_spreadsheet_fetcher/sheets_service_builder.rb', line 13

def initialize(user_id, config: nil, application_name: nil)
  @user_id = user_id
  @config = config || GoogleSpreadsheetFetcher.config
  @application_name = application_name
  @token_store = config.token_store || Google::Auth::Stores::FileTokenStore.new(file: @config.credential_store_file)
end

Instance Method Details

#buildObject



20
21
22
23
24
25
# File 'lib/google_spreadsheet_fetcher/sheets_service_builder.rb', line 20

def build
  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