Class: SlideshareApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/slideshare_api/client.rb

Constant Summary collapse

SLIDESHARE_API_URL =
'https://www.slideshare.net/api/2'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key, shared_secret) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
# File 'lib/slideshare_api/client.rb', line 12

def initialize(api_key, shared_secret)
  @api_key = api_key
  @shared_secret = shared_secret
  build_connection
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



10
11
12
# File 'lib/slideshare_api/client.rb', line 10

def api_key
  @api_key
end

#connectionObject

Returns the value of attribute connection.



10
11
12
# File 'lib/slideshare_api/client.rb', line 10

def connection
  @connection
end

#shared_secretObject

Returns the value of attribute shared_secret.



10
11
12
# File 'lib/slideshare_api/client.rb', line 10

def shared_secret
  @shared_secret
end

Instance Method Details

#slideshow(options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/slideshare_api/client.rb', line 18

def slideshow(options = {})
  params = {}
  params.merge!(slideshow_url: cleaned_url(options[:slideshow_url])) if options[:slideshow_url]
  params.merge!(slideshow_id: options[:slideshow_id]) if options[:slideshow_id]
  params.merge!(detailed: 1) if options[:detailed]
  SlideshareApi::Model::Slideshow.new get('get_slideshow', params)
end

#slideshows(options = {}) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/slideshare_api/client.rb', line 26

def slideshows(options = {})
  params = {}
  if options[:tag]
    params.merge!(tag: options[:tag])
    path = 'get_slideshows_by_tag'
  elsif options[:group]
    params.merge!(group_name: options[:group])
    path = 'get_slideshows_by_group'
  elsif options[:user]
    params.merge!(username_for: options[:user])
    path = 'get_slideshows_by_user'
  else
    raise SlideshareApi::Error, 'Required Parameter Missing'
  end

  params.merge!(detailed: 1) if options[:detailed]
  get(path, params).search('Slideshow').map { |s| SlideshareApi::Model::Slideshow.new(s) }
end