Class: BOTR::ChannelVideo

Inherits:
Object
  • Object
show all
Defined in:
lib/botr/channels/channel_video.rb

Overview

The BOTR::ChannelVideo class contains calls for requesting channel videos in the dynamic playlist. For manual channels, these calls can also be used to add, change video position or remove video from the playlist.

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Authentication

#signature

Methods included from API

#api_call_class, #api_format, #api_key, #api_nonce, #api_protocol, #api_secret_key, #api_server, #api_timestamp, #api_url, #api_version, #progress_url, #upload_address, #upload_key, #upload_protocol, #upload_token, #upload_url

Methods included from HTTP

#client, #delete_request, #get_request, #post_request, #put_request

Constructor Details

#initialize(params = {}) ⇒ ChannelVideo

Returns a new instance of ChannelVideo.

Raises:

  • (ArgumentError)


120
121
122
123
124
125
126
127
# File 'lib/botr/channels/channel_video.rb', line 120

def initialize(params = {})
	params.each do |key, val|
		param = "@#{key.to_s}"
		next unless methods.include? key.to_sym
		instance_variable_set(param, val)
	end
	raise ArgumentError, "You must specify a video key." if @key.nil?
end

Class Attribute Details

.last_statusObject (readonly)

Returns the value of attribute last_status.



10
11
12
# File 'lib/botr/channels/channel_video.rb', line 10

def last_status
  @last_status
end

Instance Attribute Details

#authorObject (readonly)

Returns the value of attribute author.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def author
  @author
end

#dateObject (readonly)

Returns the value of attribute date.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def date
  @date
end

#descriptionObject (readonly)

Returns the value of attribute description.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def description
  @description
end

#durationObject (readonly)

Returns the value of attribute duration.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def duration
  @duration
end

#keyObject (readonly)

Returns the value of attribute key.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def last_status
  @last_status
end

Returns the value of attribute link.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def link
  @link
end

#md5Object (readonly)

Returns the value of attribute md5.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def md5
  @md5
end

#mediatypeObject (readonly)

Returns the value of attribute mediatype.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def mediatype
  @mediatype
end

#tagsObject (readonly)

Returns the value of attribute tags.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def title
  @title
end

#viewsObject (readonly)

Returns the value of attribute views.



117
118
119
# File 'lib/botr/channels/channel_video.rb', line 117

def views
  @views
end

Class Method Details

.list(channel_key, **options) ⇒ Array

Returns a list of video objects in the channel specified by the channel key.

Parameters:

  • channel_key (String)

    key of the channel for which videos should be listed

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • result_limit (Integer)

    specifies maximum number of videos to return; default is 50 and maximum result limit is 1000.

  • result_offset (Integer)

    specifies how many videos should be skipped at the beginning of the result set

Returns:

  • (Array)

    a list of video objects in the channel specified by the channel key



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/botr/channels/channel_video.rb', line 54

def list(channel_key, **options)
	json = get_request(options.merge(:method => 'list',
									 :channel_key => channel_key))
	res = JSON.parse(json.body)
	
	if json.status == 200
		results = process_list_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return results
end

.show(channel_key, **options) ⇒ BOTR::ChannelVideo Also known as: find

Returns a new object with the properties of the video referenced by the video key or the position.

Parameters:

  • channel_key (String)

    key of the channel to which the video belongs

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • video_key (String)

    key of the video which information to show

  • position (Integer)

    position of the video in the channel for which to show information

Returns:

  • (BOTR::ChannelVideo)

    a new object with the properties of the video referenced by the video key or the position



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/botr/channels/channel_video.rb', line 25

def show(channel_key, **options)
	json = get_request(options.merge(:method => 'show',
					    			 :channel_key => channel_key))
	res = JSON.parse(json.body)

	if json.status == 200
		params = process_show_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return new(params)
end

.update(channel_key, **options) ⇒ BOTR::ChannelVideo

Returns this object with the status of the move operation.

Parameters:

  • channel_key (String)

    key of the channel which should be updated

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • position_from (String)

    position in the channel of the video which should be moved

  • position_to (Integer)

    position in the channel of where the video which should be moved

Returns:



81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/botr/channels/channel_video.rb', line 81

def update(channel_key, **options)
	json = put_request(options.merge(:channel_key => channel_key))
	res = JSON.parse(json.body)

	if json.status == 200
		process_update_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end

Instance Method Details

#create(channel_key, **options) ⇒ BOTR::ChannelVideo

Add a video to the playlist of a manual channel.

Parameters:

  • channel_key (String)

    key of the channel to which the video belongs

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • video_key (String)

    key of the video that should be added to the channel

  • position (Integer)

    indicates where to insert the new video; defaults to insertion at the end

Returns:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/botr/channels/channel_video.rb', line 142

def create(channel_key, **options)
	json = get_request(options.merge(:method => 'create',
									 :channel_key => channel_key,
									 :video_key => @key))
	res = JSON.parse(json.body)

	if json.status == 200
		process_create_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end

#delete(channel_key, **options) ⇒ BOTR::ChannelVideo

Delete a video from the playlist of a manual channel.

Parameters:

  • channel_key (String)

    key of the channel from which video should be deleted

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • video_key (String)

    key of the video; all videos with this key will be deleted from the channel

  • position_to (Integer)

    video position in the channel; only video at this position will be deleted from the channel

Returns:

  • (BOTR::ChannelVideo)

    this object with the status of the delete operation and all other parameters nulled



170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/botr/channels/channel_video.rb', line 170

def delete(channel_key, **options)
	json = delete_request(options.merge(:channel_key => channel_key))
	res = JSON.parse(json.body)

	if json.status == 200
		process_delete_response(res)
	else
		raise "HTTP Error #{json.status}: #{json.body}"
	end

	return self
end