Class: GoogleSpreadsheetFetcher::SheetsServiceBuilder
- Inherits:
-
Object
- Object
- GoogleSpreadsheetFetcher::SheetsServiceBuilder
- Defined in:
- lib/google_spreadsheet_fetcher/sheets_service_builder.rb
Instance Method Summary collapse
- #build(authorizer: nil) ⇒ Object
-
#initialize(user_id, config: nil, application_name: nil) ⇒ SheetsServiceBuilder
constructor
A new instance of SheetsServiceBuilder.
Constructor Details
#initialize(user_id, config: nil, application_name: nil) ⇒ SheetsServiceBuilder
Returns a new instance of SheetsServiceBuilder.
6 7 8 9 10 |
# File 'lib/google_spreadsheet_fetcher/sheets_service_builder.rb', line 6 def initialize(user_id, config: nil, application_name: nil) @user_id = user_id @config = config || GoogleSpreadsheetFetcher.config @application_name = application_name end |
Instance Method Details
#build(authorizer: nil) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/google_spreadsheet_fetcher/sheets_service_builder.rb', line 12 def build(authorizer: nil) = || config. || ::GoogleSpreadsheetFetcher::Authorizer::Oauth2::Authorizer.new raise 'Authorizer is not configured' if .blank? ::Google::Apis::SheetsV4::SheetsService.new.tap do |service| service. = .fetch_credentials!(user_id: user_id) service..application_name = application_name if application_name.present? end end |