Class: MetachannelsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/metachannels-api-client.rb

Constant Summary collapse

DEFAULT_API_ENDPOINT =
"http://api.metachannels.com/api"

Instance Attribute Summary collapse

Instance Method Summary collapse

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_keyObject

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_pointObject

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

Raises:

  • (ArgumentError)


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.extract_options!
  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

Raises:

  • (ArgumentError)


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.extract_options!
  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

Raises:

  • (ArgumentError)


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.extract_options!

  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*

Raises:

  • (ArgumentError)


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.extract_options!

  uri()['/search'].get(parameters, {'Channels-Authorization' => @api_key}).deserialise
end

#search_youtube(*args) ⇒ Object

Raises:

  • (ArgumentError)


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.extract_options!

  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

Raises:

  • (ArgumentError)


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.extract_options!

  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

Raises:

  • (ArgumentError)


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.extract_options!

  uri()['/wurl_packages'].get(parameters, {'Channels-Authorization' => @api_key}).deserialise
end