File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,31 +22,40 @@ bundle install
2222token = " ya29.a0AXeO8..."
2323id = " 113Xmx0YQc..."
2424editor = Gslide ::Editor .new (token)
25- presentation = Gslide ::Presentation .new (id, auth: editor)
26- presentation .get
25+ pres = Gslide ::Presentation .new (id, auth: editor)
26+ pres .get
2727# => parsed json of the Google Slides file
28+ ```
2829
30+ ``` rb
2931editor = Gslide ::Editor .new (token)
3032editor.insert_presentation(title: " Once upon a time" )
31- # => "14HD3asbaVCkJKHQGJB9FJPqPbuqDkMPzsI4HmXFzYQs"
32- id = _
33- presentation = Gslide ::Presentation .new (id, auth: editor)
34- presentation.get
33+ # => <Gslide::Models::Presentation:0x000000013e6d4108
34+ # @id="1itXwmlLbyTRa1QKhrsO16OhJPEJUK6eh2d1nqsQfuqY">
3535
36- presentation.batch_update({
36+ pres = _
37+ pres.batch_update({
3738 requests: [
3839 {
3940 createSlide: {
4041 slideLayoutReference: {
4142 predefinedLayout: " BLANK"
4243 }
4344 }
44- },
45+ }
46+ ]
47+ })
48+
49+ pres.get_slide_ids
50+ # => ["p", "SLIDES_API1463300837_0"]
51+
52+ pres.batch_update({
53+ requests: [
4554 {
4655 createImage: {
4756 url: " https://drive.usercontent.google.com/download?id=1fus5psRLzIJjG3A5GAfbqu22cdEczNZQ&authuser=0" ,
4857 elementProperties: {
49- pageObjectId: " p " ,
58+ pageObjectId: " SLIDES_API1463300837_0 " ,
5059 size: {
5160 height: { magnitude: 200 , unit: " PT" },
5261 width: { magnitude: 300 , unit: " PT" }
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ def initialize(token)
1717 end
1818
1919 # @param [Hash] options the body for the POST request.
20- # @return [String ] presentation id.
20+ # @return [Gslide::Models::Presentation ] presentation id.
2121 # @see https://developers.google.com/slides/api/reference/rest/v1/presentations/create#request-body
2222 def insert_presentation ( options = { } )
2323 uri = URI ( GOOGLE_SLIDES + "" )
@@ -28,7 +28,7 @@ def insert_presentation(options = {})
2828 if response_body [ "error" ]
2929 raise Gslide ::Error . new ( response_body [ "error" ] [ "message" ] )
3030 end
31- response_body [ "presentationId" ]
31+ Presentation . new response_body [ "presentationId" ] , auth : self
3232 end
3333 end
3434 end
Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ module Models
55 class Presentation
66 include Concerns ::Requests
77
8+ attr_reader :id
9+
810 def initialize ( id , auth : nil )
911 @id = id
1012 @auth = auth
@@ -37,6 +39,11 @@ def batch_update(options = {})
3739 end
3840 response_body [ "presentationId" ] == @id
3941 end
42+
43+ def get_slide_ids
44+ parsed_body = get
45+ parsed_body [ "slides" ] . collect { |slide | slide [ "objectId" ] }
46+ end
4047 end
4148 end
4249end
You can’t perform that action at this time.
0 commit comments