Class: GSheets::V4::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/g_sheets/v4/session.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token:, service: Google::Apis::SheetsV4::SheetsService.new) ⇒ Session

Returns a new instance of Session.



4
5
6
7
8
# File 'lib/g_sheets/v4/session.rb', line 4

def initialize(access_token:, service: Google::Apis::SheetsV4::SheetsService.new)
  @access_token = access_token
  @service = service
  @service.authorization = access_token
end

Instance Method Details

#append_row_to_spreadsheet(id:, row:, sheet_name:) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/g_sheets/v4/session.rb', line 14

def append_row_to_spreadsheet(id:, row:, sheet_name:)
  service.append_spreadsheet_value(
    id,
    sheet_name,
    {"values": [row]},
    value_input_option: "RAW"
  )
end

#get_sheets_from_spreadsheet(id) ⇒ Object



10
11
12
# File 'lib/g_sheets/v4/session.rb', line 10

def get_sheets_from_spreadsheet(id)
  service.get_spreadsheet(id).sheets
end

#get_spreadsheet_values(id:, sheet_name:) ⇒ Object



23
24
25
26
27
28
# File 'lib/g_sheets/v4/session.rb', line 23

def get_spreadsheet_values(id:, sheet_name:)
  service.get_spreadsheet_values(
    id,
    sheet_name
  )
end

#serviceObject



30
31
32
# File 'lib/g_sheets/v4/session.rb', line 30

def service
  @service
end