Class: Gslide::Models::Editor

Inherits:
Object
  • Object
show all
Includes:
Concerns::Requests
Defined in:
lib/gslide/models/editor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::Requests

#get_request, #post_request

Constructor Details

#initialize(token) ⇒ Editor

Returns a new instance of Editor.



11
12
13
14
15
16
17
# File 'lib/gslide/models/editor.rb', line 11

def initialize(token)
  if token.to_s.empty?
    raise ArgumentError.new("Auth Token must be present")
  end

  @token = token
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



9
10
11
# File 'lib/gslide/models/editor.rb', line 9

def token
  @token
end

Instance Method Details

#insert_presentation(options = {}) ⇒ Gslide::Models::Presentation

Returns presentation id.

Parameters:

  • options (Hash) (defaults to: {})

    the body for the POST request.

Returns:

See Also:



22
23
24
25
26
27
28
# File 'lib/gslide/models/editor.rb', line 22

def insert_presentation(options = {})
  uri = URI(GOOGLE_SLIDES + "")

  # "title" is the only allowed field in the request body
  response_body = post_request(uri, auth_token: @token, body: options.to_json)
  Presentation.new response_body["presentationId"], auth: self
end