Class: YTAnalytics::Client

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/yt_analytics/client.rb

Direct Known Subclasses

OAuth2Client

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(*params) ⇒ Client

Previously this was a logger instance but we now do it globally



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/yt_analytics/client.rb', line 6

def initialize *params
  if params.first.is_a?(Hash)
    hash_options = params.first
    @user = hash_options[:username]
    @pass = hash_options[:password]
    @dev_key = hash_options[:dev_key]
    @client_id = hash_options[:client_id] || "yt_analytics"
    @legacy_debug_flag = hash_options[:debug]
  elsif params.first
    puts "* warning: the method YTAnalytics::Client.new(user, passwd, dev_key) is deprecated, use YTAnalytics::Client.new(:username => 'user', :password => 'passwd', :dev_key => 'dev_key')"
    @user = params.shift
    @pass = params.shift
    @dev_key = params.shift
    @client_id = params.shift || "youtube_it"
    @legacy_debug_flag = params.shift
  end
end

Instance Method Details

#analytics(options = {}) ⇒ Object



32
33
34
# File 'lib/yt_analytics/client.rb', line 32

def analytics(options = {})
  client.get_analytics(options)
end

#current_userObject



28
29
30
# File 'lib/yt_analytics/client.rb', line 28

def current_user
  client.get_current_user
end

#day_totals(options = {}) ⇒ Object



44
45
46
# File 'lib/yt_analytics/client.rb', line 44

def day_totals(options = {})
  client.temporal_totals('day',self.user_id, options)
end

#day_watch_time(options = {}) ⇒ Object

WATCH TIME METRICS



58
59
60
# File 'lib/yt_analytics/client.rb', line 58

def day_watch_time(options = {})
  client.watch_time_metrics('day', self.user_id, options)
end

#demographic_percentages(options = {}) ⇒ Object

DEMOGRAPHICS METRICS



53
54
55
# File 'lib/yt_analytics/client.rb', line 53

def demographic_percentages(options = {})
  client.demographic_percentages(self.user_id, options)
end

#enable_http_debuggingObject



24
25
26
# File 'lib/yt_analytics/client.rb', line 24

def enable_http_debugging
  client.enable_http_debugging
end

#month_totals(options = {}) ⇒ Object



48
49
50
# File 'lib/yt_analytics/client.rb', line 48

def month_totals(options = {})
  client.temporal_totals('month',self.user_id, options)
end

#seven_day_totals(options = {}) ⇒ Object



36
37
38
# File 'lib/yt_analytics/client.rb', line 36

def seven_day_totals(options = {})
  client.temporal_totals('7DayTotals',self.user_id, options)
end

#thirty_day_totals(options = {}) ⇒ Object



40
41
42
# File 'lib/yt_analytics/client.rb', line 40

def thirty_day_totals(options = {})
  client.temporal_totals('30DayTotals',self.user_id, options)
end