Class: Rabbit::Task::SlideShare

Inherits:
Object
  • Object
show all
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

GetText::DOMAIN

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from GetText

included

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

#descriptionObject

Returns the value of attribute description.



36
37
38
# File 'lib/rabbit/slideshare.rb', line 36

def description
  @description
end

#pdf_pathObject

Returns the value of attribute pdf_path.



36
37
38
# File 'lib/rabbit/slideshare.rb', line 36

def pdf_path
  @pdf_path
end

#tagsObject

Returns the value of attribute tags.



36
37
38
# File 'lib/rabbit/slideshare.rb', line 36

def tags
  @tags
end

#titleObject

Returns the value of attribute title.



36
37
38
# File 'lib/rabbit/slideshare.rb', line 36

def title
  @title
end

#userObject

Returns the value of attribute user.



36
37
38
# File 'lib/rabbit/slideshare.rb', line 36

def user
  @user
end

Instance Method Details

#uploadObject



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