Class: MetachannelsApi
- Inherits:
-
Object
- Object
- MetachannelsApi
- Defined in:
- lib/metachannels-api-client.rb
Constant Summary collapse
- DEFAULT_API_ENDPOINT =
"http://api.metachannels.com/api"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#end_point ⇒ Object
Returns the value of attribute end_point.
Instance Method Summary collapse
-
#create_show(*args) ⇒ Object
Invoke the MetaChannels Shows API to create a show args :youtubetype=>“YoutubePlaylist”, :ytchannelorplaylist=>“abc”, :email=>“[email protected]”, callbackurl=>“24.6.103.116:3001/notify_addshow”.
- #get_video(id, *args) ⇒ Object
-
#get_wurl_package(slug, *args) ⇒ Object
Retrieve a single Wurl Package GET /api/wurl_package.
-
#initialize(apikey = nil, end_point = nil) ⇒ MetachannelsApi
constructor
A new instance of MetachannelsApi.
-
#search(*args) ⇒ Object
Invoke the Metachannels Search API Pass the same parameters as the Search API as a hash.
-
#search_youtube(*args) ⇒ Object
args: username perPage startPage format Example: www.channels.com/api/shows/youtube?username=senatorfeinstein&format=xml&perPage=1&startPage=1.
-
#show(id, *args) ⇒ Object
Invoke the MetaChannels Shows API to retreive a single show id The id of the metachannels show args TBD.
-
#wurl_packages(*args) ⇒ Object
Retreive the set of all Wurl Packages GET /api/wurl_packages.
Constructor Details
#initialize(apikey = nil, end_point = nil) ⇒ MetachannelsApi
Returns a new instance of MetachannelsApi.
10 11 12 13 |
# File 'lib/metachannels-api-client.rb', line 10 def initialize(apikey = nil, end_point = nil) @api_key = apikey @end_point = end_point || DEFAULT_API_ENDPOINT end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/metachannels-api-client.rb', line 7 def api_key @api_key end |
#end_point ⇒ Object
Returns the value of attribute end_point.
8 9 10 |
# File 'lib/metachannels-api-client.rb', line 8 def end_point @end_point end |
Instance Method Details
#create_show(*args) ⇒ Object
Invoke the MetaChannels Shows API to create a show args :youtubetype=>“YoutubePlaylist”, :ytchannelorplaylist=>“abc”, :email=>“[email protected]”, callbackurl=>“24.6.103.116:3001/notify_addshow”
63 64 65 66 67 68 69 70 |
# File 'lib/metachannels-api-client.rb', line 63 def create_show(*args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. parameters[:api_key]=@api_key parameters[:format]="json" #make request json type uri['/shows'].post_form(parameters, {'Channels-Authorization' => @api_key}) end |
#get_video(id, *args) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/metachannels-api-client.rb', line 54 def get_video(id, *args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. parameters[:format]="json" #make request json type uri()["/videos/#{id}"].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |
#get_wurl_package(slug, *args) ⇒ Object
Retrieve a single Wurl Package GET /api/wurl_package
83 84 85 86 87 88 |
# File 'lib/metachannels-api-client.rb', line 83 def get_wurl_package(slug, *args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. uri()["/wurl_packages/#{slug}"].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |
#search(*args) ⇒ Object
Invoke the Metachannels Search API Pass the same parameters as the Search API as a hash. See support.metachannels.com/entries/321559-metachannels-api-beta-0-2 args:
*searchTerms*
*perPage*
*startPage*
*order*
*types*
24 25 26 27 28 29 |
# File 'lib/metachannels-api-client.rb', line 24 def search(*args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. uri()['/search'].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |
#search_youtube(*args) ⇒ Object
args:
*username*
*perPage*
*startPage*
*format*
Example: www.channels.com/api/shows/youtube?username=senatorfeinstein&format=xml&perPage=1&startPage=1
37 38 39 40 41 42 |
# File 'lib/metachannels-api-client.rb', line 37 def search_youtube(*args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. uri()['/shows/youtube'].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |
#show(id, *args) ⇒ Object
Invoke the MetaChannels Shows API to retreive a single show id The id of the metachannels show args TBD
47 48 49 50 51 52 |
# File 'lib/metachannels-api-client.rb', line 47 def show(id, *args) #TODO rename as get_show, alias raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. uri()["/shows/#{id}"].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |
#wurl_packages(*args) ⇒ Object
Retreive the set of all Wurl Packages GET /api/wurl_packages
74 75 76 77 78 79 |
# File 'lib/metachannels-api-client.rb', line 74 def wurl_packages(*args) raise ArgumentError.new('apikey not specified') if @api_key.blank? parameters = args. uri()['/wurl_packages'].get(parameters, {'Channels-Authorization' => @api_key}).deserialise end |