Class: Rabbit::Task::SlideShare
- Inherits:
-
Object
- Object
- Rabbit::Task::SlideShare
- Includes:
- GetText
- Defined in:
- lib/rabbit/slideshare.rb
Constant Summary collapse
- BASE_URL =
"https://www.slideshare.net"
- API_PATH_PREFIX =
"/api/2"
- API_KEY =
"NB1B0IzS"
- SHARED_SECRET =
"iuTFlPzU"
Constants included from GetText
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#pdf_path ⇒ Object
Returns the value of attribute pdf_path.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#title ⇒ Object
Returns the value of attribute title.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(logger) ⇒ SlideShare
constructor
A new instance of SlideShare.
- #upload ⇒ Object
Methods included from GetText
Constructor Details
#initialize(logger) ⇒ SlideShare
Returns a new instance of SlideShare.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/rabbit/slideshare.rb', line 37 def initialize(logger) @logger = logger @user = nil @pdf_path = nil @title = nil @description = nil @tags = [] @connection = Faraday.new(:url => BASE_URL) do |builder| builder.request :multipart builder.request :url_encoded builder.response :logger, @logger builder.adapter :net_http end end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
36 37 38 |
# File 'lib/rabbit/slideshare.rb', line 36 def description @description end |
#pdf_path ⇒ Object
Returns the value of attribute pdf_path.
36 37 38 |
# File 'lib/rabbit/slideshare.rb', line 36 def pdf_path @pdf_path end |
#tags ⇒ Object
Returns the value of attribute tags.
36 37 38 |
# File 'lib/rabbit/slideshare.rb', line 36 def @tags end |
#title ⇒ Object
Returns the value of attribute title.
36 37 38 |
# File 'lib/rabbit/slideshare.rb', line 36 def title @title end |
#user ⇒ Object
Returns the value of attribute user.
36 37 38 |
# File 'lib/rabbit/slideshare.rb', line 36 def user @user end |
Instance Method Details
#upload ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rabbit/slideshare.rb', line 52 def upload payload = { :username => @user, :password => password, :slideshow_title => @title, :slideshow_srcfile => Faraday::UploadIO.new(@pdf_path, "application/pdf"), :slideshow_description => @description, :tags => @tags.join(","), } payload = common_payload.merge(payload) payload.keys.each do |key| payload.delete(key) if payload[key].nil? end parse_response(@connection.post("#{API_PATH_PREFIX}/upload_slideshow", payload)) end |