Class: SlideShare::Slideshows
- Inherits:
-
Object
- Object
- SlideShare::Slideshows
- Defined in:
- lib/slide_share/slideshows.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
Instance Method Summary collapse
-
#create(title, filename, username, password, options = {}) ⇒ Object
Returns id of newly created slideshow if successful or raises an appropriate exception if not.
-
#delete(id, username, password) ⇒ Object
Returns true if successful or raises an appropriate exception if not.
-
#find(id, options = {}) ⇒ Object
Returns hash of attributes for slideshow if successful or raises an appropriate exception if not.
-
#initialize(base) ⇒ Slideshows
constructor
This method should only be called internally from an instance of
SlideShare::Base
. -
#update(id, username, password, options = {}) ⇒ Object
Returns true if successful or raises an appropriate exception if not.
Constructor Details
#initialize(base) ⇒ Slideshows
This method should only be called internally from an instance of SlideShare::Base
.
7 8 9 |
# File 'lib/slide_share/slideshows.rb', line 7 def initialize(base) # :nodoc: self.base = base end |
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
3 4 5 |
# File 'lib/slide_share/slideshows.rb', line 3 def base @base end |
Instance Method Details
#create(title, filename, username, password, options = {}) ⇒ Object
Returns id of newly created slideshow if successful or raises an appropriate exception if not. Takes the following options:
-
:slideshow_description
- Description for the slideshow -
:slideshow_tags
- Tags for the slideshow. Multiple tags should be separated by spaces, using quotes to create individual multiple word tags. -
:make_src_public
- Set totrue/false
to allow users to download the slideshow -
:make_slideshow_private
- Set totrue/false
to change the privacy setting appropriately
The following options will only be used if :make_slideshow_private
is set true
:
-
:generate_secret_url
- Set totrue/false
to generate a secret URL -
:allow_embeds
- Set totrue/false
to allow websites to embed the private slideshow -
:share_with_contacts
- Set totrue/false
to allow your contacts to view the private slideshow
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/slide_share/slideshows.rb', line 30 def create(title, filename, username, password, = {}) force_boolean_params_to_letters! .merge!(:username => username, :password => password, :slideshow_title => title) params = base.send(:add_required_params, ).map do |key, value| Curl::PostField.content(key.to_s, value) end params << Curl::PostField.file("slideshow_srcfile", File.(filename)) curl = Curl::Easy.new("#{SlideShare::Base.base_uri}/upload_slideshow") do |c| c.multipart_form_post = true end curl.http_post(*params) body = ToHashParser.from_xml(curl.body_str) response = base.send(:catch_errors, body) # I'd presume the id returned was an integer response["SlideShowUploaded"]["SlideShowID"].to_i end |
#delete(id, username, password) ⇒ Object
Returns true if successful or raises an appropriate exception if not.
90 91 92 93 94 |
# File 'lib/slide_share/slideshows.rb', line 90 def delete(id, username, password) base.send :post, "/delete_slideshow", :slideshow_id => id, :username => username, :password => password true # This might be too naïve but should have already raised exception if unsuccessful end |
#find(id, options = {}) ⇒ Object
Returns hash of attributes for slideshow if successful or raises an appropriate exception if not. Takes the following options:
-
:username
- SlideShare username of the user making the request -
:password
- SlideShare password of the user making the request -
:detailed
- Set totrue
to return additional, detailed information about the slideshow (see the official API documentation here for more information). Default isfalse
.
58 59 60 61 62 |
# File 'lib/slide_share/slideshows.rb', line 58 def find(id, = {}) detailed = convert_to_number(.delete(:detailed)) [:detailed] = detailed unless detailed.nil? base.send :get, "/get_slideshow", .merge(:slideshow_id => id) end |
#update(id, username, password, options = {}) ⇒ Object
Returns true if successful or raises an appropriate exception if not. Takes the following options:
-
:slideshow_title
- Title for the slideshow -
:slideshow_description
- Description for the slideshow -
:slideshow_tags
- Tags for the slideshow. Multiple tags should be separated by spaces, using quotes to create individual multiple word tags. -
:make_slideshow_private
- Set totrue/false
to change the privacy setting appropriately
The following options will only be used if :make_slideshow_private
is set true
:
-
:generate_secret_url
- Set totrue/false
to generate a secret URL -
:allow_embeds
- Set totrue/false
to allow websites to embed the private slideshow -
:share_with_contacts
- Set totrue/false
to allow your contacts to view the private slideshow
82 83 84 85 86 87 |
# File 'lib/slide_share/slideshows.rb', line 82 def update(id, username, password, = {}) force_boolean_params_to_letters! base.send(:post, "/edit_slideshow", .merge(:slideshow_id => id, :username => username, :password => password)) true # This might be too naïve but should have already raised exception if unsuccessful end |