Class: Purtea::SheetApi
- Inherits:
-
Object
- Object
- Purtea::SheetApi
- Defined in:
- lib/purtea/sheet.rb
Overview
Interacts with the Google Sheets API.
Constant Summary collapse
- OOB_URI =
'urn:ietf:wg:oauth:2.0:oob'
- APP_NAME =
'Purtea'
- CREDENTIALS_PATH =
Purtea::Config.resolve_file( 'google_credentials.json', create_dir: true )
- TOKEN_PATH =
Purtea::Config.resolve_file( 'google_token.yaml', create_dir: true )
- SCOPE =
Google::Apis::SheetsV4::AUTH_SPREADSHEETS
- USER_ID =
'default'
Instance Attribute Summary collapse
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#spreadsheet_id ⇒ Object
readonly
Returns the value of attribute spreadsheet_id.
Instance Method Summary collapse
- #append(range, data) ⇒ Object
-
#initialize(spreadsheet_id) ⇒ SheetApi
constructor
A new instance of SheetApi.
Constructor Details
#initialize(spreadsheet_id) ⇒ SheetApi
Returns a new instance of SheetApi.
27 28 29 30 31 32 |
# File 'lib/purtea/sheet.rb', line 27 def initialize(spreadsheet_id) @service = Google::Apis::SheetsV4::SheetsService.new @service..application_name = APP_NAME @service. = @spreadsheet_id = spreadsheet_id end |
Instance Attribute Details
#service ⇒ Object (readonly)
Returns the value of attribute service.
25 26 27 |
# File 'lib/purtea/sheet.rb', line 25 def service @service end |
#spreadsheet_id ⇒ Object (readonly)
Returns the value of attribute spreadsheet_id.
25 26 27 |
# File 'lib/purtea/sheet.rb', line 25 def spreadsheet_id @spreadsheet_id end |
Instance Method Details
#append(range, data) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/purtea/sheet.rb', line 34 def append(range, data) vr = Google::Apis::SheetsV4::ValueRange.new values: data @service.append_spreadsheet_value( @spreadsheet_id, range, vr, insert_data_option: 'INSERT_ROWS', value_input_option: 'RAW' ) end |