Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/gslide/concerns/requests.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require "net/http"

module Gslide

# @private
module Concerns
module Requests
def get_request(uri, auth_token: "")
Expand Down
20 changes: 19 additions & 1 deletion lib/gslide/models/spreadsheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ def get_sheets
parsed_body = get
parsed_body[:sheets].collect { |h| Sheet.new(h) }
end

# @param [Hash] options the request body.
# @see https://developers.google.com/workspace/sheets/api/reference/rest/v4/spreadsheets.values/append
def values_append(notation, options = {})
uri = url_escape_uri(GOOGLE_SHEETS + "/#{@id}/values/'#{notation}':append?valueInputOption=USER_ENTERED")
request_body = options.convert_keys { |k| k.to_s.lower_camel_case }.to_json

response_body = post_request(uri, auth_token: @auth.token, body: request_body)
response_body
end

private

def url_escape_uri(uri_string)
parser = URI::Parser.new
URI parser.escape(uri_string)
end
end

class SpreadsheetDraft
Expand All @@ -61,10 +78,11 @@ def create(options = {})
end

class Sheet
attr_reader :id, :charts
attr_reader :id, :title, :charts

def initialize(options = {})
@id = options[:properties][:sheet_id]
@title = options[:properties][:title]
@charts = options[:charts].collect { |h| Chart.new(h) } if options[:charts]
end
end
Expand Down