Class: SlideshareApi::Client
- Inherits:
-
Object
- Object
- SlideshareApi::Client
- Defined in:
- lib/slideshare_api/client.rb
Constant Summary collapse
- SLIDESHARE_API_URL =
'https://www.slideshare.net/api/2'
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#shared_secret ⇒ Object
Returns the value of attribute shared_secret.
Instance Method Summary collapse
-
#initialize(api_key, shared_secret) ⇒ Client
constructor
A new instance of Client.
- #search(query, options = {}) ⇒ Object
- #slideshow(options = {}) ⇒ Object
- #slideshows(options = {}) ⇒ Object
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_key ⇒ Object
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/slideshare_api/client.rb', line 10 def api_key @api_key end |
#connection ⇒ Object
Returns the value of attribute connection.
10 11 12 |
# File 'lib/slideshare_api/client.rb', line 10 def connection @connection end |
#shared_secret ⇒ Object
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
#search(query, options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/slideshare_api/client.rb', line 45 def search(query, = {}) params = {} params.merge!(q: query) params.merge!(detailed: [:detailed] ? 1 : 0) if .has_key?(:detailed) params.merge!(page: [:page]) if [:page] params.merge!(items_per_page: [:per_page]) if [:per_page] params.merge!(lang: [:language]) if [:language] params.merge!(sort: [:ordered_by]) if [:ordered_by] params.merge!(upload_date: [:upload_date]) if [:upload_date] params.merge!(download: [:downloadable] ? 1 : 0) if .has_key?(:downloadable) params.merge!(fileformat: [:format]) if [:format] params.merge!(file_type: [:type]) if [:type] get('search_slideshows', params).search('Slideshow').map { |s| SlideshareApi::Model::Slideshow.new(s) } end |
#slideshow(options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/slideshare_api/client.rb', line 18 def ( = {}) params = {} params.merge!(slideshow_url: cleaned_url([:slideshow_url])) if [:slideshow_url] params.merge!(slideshow_id: [:slideshow_id]) if [:slideshow_id] params.merge!(detailed: [:detailed] ? 0 : 1) if .has_key?(: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 ( = {}) params = {} if [:tag] params.merge!(tag: [:tag]) path = 'get_slideshows_by_tag' elsif [:group] params.merge!(group_name: [:group]) path = 'get_slideshows_by_group' elsif [:user] params.merge!(username_for: [:user]) path = 'get_slideshows_by_user' else raise SlideshareApi::Error, 'Required Parameter Missing' end params.merge!(detailed: [:detailed] ? 1 : 0) if .has_key?(:detailed) get(path, params).search('Slideshow').map { |s| SlideshareApi::Model::Slideshow.new(s) } end |