Class: BOTR::VideoView

Inherits:
Object
  • Object
show all
Defined in:
lib/botr/videos/video_view.rb

Overview

The BOTR::VideoView class contains calls for requesting video views statistics.

A video view is counted every time:

The video starts playing in one of your players. The video starts downloading from our content server. When a user scrubs through the video in a player or restarts the video, no additional view is counted.

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 = {}) ⇒ VideoView

Returns a new instance of VideoView.


140
141
142
143
144
145
146
# File 'lib/botr/videos/video_view.rb', line 140

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		
end

Class Attribute Details

.last_statusObject (readonly)

Returns the value of attribute last_status


16
17
18
# File 'lib/botr/videos/video_view.rb', line 16

def last_status
  @last_status
end

Instance Attribute Details

#dateObject (readonly)

Returns the value of attribute date


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def date
  @date
end

#daysObject (readonly)

Returns the value of attribute days


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def days
  @days
end

#downloadsObject (readonly)

Returns the value of attribute downloads


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def downloads
  @downloads
end

#keyObject (readonly)

Returns the value of attribute key


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def key
  @key
end

#last_statusObject (readonly)

Returns the value of attribute last_status


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def last_status
  @last_status
end

#monthsObject (readonly)

Returns the value of attribute months


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def months
  @months
end

#numberObject (readonly)

Returns the value of attribute number


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def number
  @number
end

#pageviewsObject (readonly)

Returns the value of attribute pageviews


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def pageviews
  @pageviews
end

#statusObject (readonly)

Returns the value of attribute status


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def status
  @status
end

#streamsObject (readonly)

Returns the value of attribute streams


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def streams
  @streams
end

#timestampObject (readonly)

Returns the value of attribute timestamp


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def timestamp
  @timestamp
end

#titleObject (readonly)

Returns the value of attribute title


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def title
  @title
end

#totalObject (readonly)

Returns the value of attribute total


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def total
  @total
end

#viewedObject (readonly)

Returns the value of attribute viewed


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def viewed
  @viewed
end

#viewsObject (readonly)

Returns the value of attribute views


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def views
  @views
end

#yearObject (readonly)

Returns the value of attribute year


136
137
138
# File 'lib/botr/videos/video_view.rb', line 136

def year
  @year
end

Class Method Details

.allObject


99
100
101
# File 'lib/botr/videos/video_view.rb', line 99

def all
	list({})
end

.list(**options) ⇒ Array

Returns a list of objects with the statistics of the all videos matching the search criteria.

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • aggregate (String)

    specifies if returned video views statistics should be aggregate: true or false

  • group_days (String)

    specifies if returned video views statistics should be grouped by year and month

  • include_empty_days (String)

    specifies if video views statistics should include days for which there is no statistics available: true or false

  • statuses_filter (String)

    list only videos with the specified statuses: "active", "deleted"

Returns:

  • (Array)

    a list of objects with the statistics of the all videos matching the search criteria


86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/botr/videos/video_view.rb', line 86

def list(**options)
	json = get_request(options.merge(:method => 'list'))
	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(video_key, **options) ⇒ BOTR::VideoView Also known as: find

Returns a new object with the statistics for the video referenced by the video_key.

Parameters:

  • video_key (String)

    key of the video for which to show views statistics

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • start_date (Integer)

    Unix timestamp of date from which videos views statistics should be start

  • end_date (Integer)

    Unix timestamp of date on which videos views statistics should be end

  • aggregate (String)

    specifies if returned video views statistics should be aggregate: true or false

  • group_days (String)

    specifies if returned video views statistics should be grouped by year and month

  • include_empty_days (String)

    specifies if video views statistics should include days for which there is no statistics available: true or false

Returns:

  • (BOTR::VideoView)

    a new object with the statistics for the video referenced by the video_key


38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/botr/videos/video_view.rb', line 38

def show(video_key, **options)
	json = get_request(options.merge(:method => 'show',
					    			 :video_key => video_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