brainzz 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 013ac84a0ce1b60ef37f43240595e6065da359c1
4
- data.tar.gz: 7acdc32bb6818441d647a6cbc18acfa3422d9953
3
+ metadata.gz: 3a7df38b3c5dbf4532513c08d8a57155167738f9
4
+ data.tar.gz: 425b4f946d597db63e5e5f85a28810d36e3934d7
5
5
  SHA512:
6
- metadata.gz: 740e8f0583e9a2ad8dd6c1bd9e13b3004e005d6ce34e34e6758d007bda82d3c2084044fa39a4096f667f402e7572a8fd34beffd3f3ce0092af242dd981f0059d
7
- data.tar.gz: df9271f109dd0d24fcd4a9a1ad9ffc8ee719e5c01154379581b751f76eddf2104122d80b8c71dbd5d4793bc178228dae1daaccf5d63092a86bb6d9521beeec08
6
+ metadata.gz: d06108933d0b0d71a5b09484018b999e565ce5ebfe9bfe5944c083183e7d880de8be5c27004b31d2ec9508537a9e163e0a74a7c47d281354631d00e958b35fa5
7
+ data.tar.gz: 1ca881f5099f8930ec5139159abae5ecdc37100a283b8cc0d01748dbb3f526456c83d7a6bfefc6c20ea899d5feb688e2184b113e6e751914eda2bfafdc6a74dc
data/README.md CHANGED
@@ -25,15 +25,41 @@ Check `config/dotenv/test.env` for the required keys.
25
25
  The values in this file are required environment variables
26
26
  when consuming this gem.
27
27
 
28
+ Environment Variables
29
+ ---------------------
30
+ Brainzz requires the use of multiple environment variables:
31
+ - BRAINZZ_GOOGLE_API_KEY
32
+ - BRAINZZ_CLIENT_ID
33
+ - BRAINZZ_CLIENT_SECRET
34
+ - BRAINZZ_REFRESH_TOKEN
35
+ - BRAINZZ_CONTENT_OWNER:
36
+ - the Google account for the CMS that owns the YouTube channel data being sought
37
+
38
+ Place values in `config/dotenv/integration.env`.
39
+
40
+ ### Attaining BRAINZZ_GOOGLE_API_KEY
41
+
28
42
  Follow the instructions [here][atv-wiki-google-api-key]
29
43
  to find the required values.
30
44
 
31
- Place them in `config/dotenv/integration.env`.
45
+ ### Attaining BRAINZZ_REFRESH_TOKEN
46
+ An OAUTH refresh token for the BRAINZZ_CONTENT_OWNER Google account
47
+ uses BRAINZZ_CLIENT_SECRET and BRAINZZ_CLIENT_SECRET
32
48
 
49
+ `BRAINZZ_CLIENT_ID` and `BRAINZZ_CLIENT_SECRET`.
50
+ - Go to the [Google OAuth Playground][google-oauth-playground]
51
+ - Log in with the Google account for BRAINZZ_CONTENT_OWNER
52
+ - Click on the gear (upper-right)
53
+ - Click check box to "Use your own OAuth credentials"
54
+ - Fill in BRAINZZ_CLIENT_ID and BRAINZZ_CLIENT_SECRET
55
+ - In Step 1 (Select & Authorize APIs) scroll down to YouTube Analytics API v1
56
+ - Click the last item "yt-analytics.readonly"
57
+ - Click blue 'Authorize APIs' button
58
+ - Exchange code for tokens
59
+ - Grab value for the Refresh Token and store
33
60
 
34
61
  Interface
35
62
  ---------
36
-
37
63
  All public endpoints are exposed in Brainzz::Core.
38
64
 
39
65
  Every response from the public API is wrapped in a `Response` object
@@ -74,20 +100,13 @@ This endpoint returns a hash with video ids as keys
74
100
  and video objects as the values.
75
101
 
76
102
 
77
- ### views_for
103
+ ### views_by_day_for
78
104
 
79
105
  #### Parameters
80
106
 
81
- * channel id (String)
82
107
  * video id (String)
83
108
  * start date (DateTime)
84
109
  * end date (DateTime)
85
- * refresh token (String)
86
-
87
- Refresh token must be a refresh token for the channel owner
88
- using the same client id and client secret that are set in
89
- `BRAINZZ_CLIENT_ID` and `BRAINZZ_CLIENT_SECRET`.
90
-
91
110
 
92
111
  #### Result
93
112
 
@@ -111,6 +130,35 @@ corresponding to the following YouTube referrals:
111
130
 
112
131
  The constants are defined in `Brainzz::ViewCountEnum`
113
132
 
133
+ ### view_totals_for
134
+
135
+ #### Parameters
136
+ same as views_by_day_for
137
+
138
+ #### Result
139
+ same as views_by_day_for except date values are nil
140
+ views for date range are aggregated per source type
141
+
142
+ ### likes_by_day_for
143
+
144
+ #### Parameters
145
+
146
+ * video id (String)
147
+ * start date (DateTime)
148
+ * end date (DateTime)
149
+
150
+ #### Result
151
+
152
+ An array of `Brainzz::LikeCount` objects ordered by date in ascending order.
153
+
154
+ ### like_totals_for
155
+
156
+ #### Parameters
157
+ same as likes_by_day_for
158
+
159
+ #### Result
160
+ same as likes_by_day_for except date values are nil
161
+ likes for date range are aggregated
114
162
 
115
163
  Factories
116
164
  ---------
@@ -130,3 +178,4 @@ will also build and push this gem to RubyGems.
130
178
 
131
179
 
132
180
  [atv-wiki-google-api-key]: https://www.github.com/awesomenesstv/wiki#google-api-key
181
+ [google-oauth-playground]: https://developers.google.com/oauthplayground/
data/lib/brainzz.rb CHANGED
@@ -10,7 +10,9 @@ require_relative 'brainzz/enums/view_source_enum'
10
10
 
11
11
  require_relative 'brainzz/models/base_model'
12
12
  require_relative 'brainzz/models/video'
13
+ require_relative 'brainzz/models/video_stat'
13
14
  require_relative 'brainzz/models/view_count'
15
+ require_relative 'brainzz/models/like_count'
14
16
  require_relative 'brainzz/models/playlist_item'
15
17
  require_relative 'brainzz/models/playlist_items_wrapper'
16
18
 
@@ -19,19 +21,25 @@ require_relative 'brainzz/services/access_token_service'
19
21
  require_relative 'brainzz/params/base_params'
20
22
  require_relative 'brainzz/params/analytics_params'
21
23
  require_relative 'brainzz/params/video_details_params'
22
- require_relative 'brainzz/params/view_count_params'
24
+ require_relative 'brainzz/params/video_stats_params'
23
25
  require_relative 'brainzz/params/playlist_items_params'
24
26
 
25
27
  require_relative 'brainzz/responses/playlist_items_response'
26
28
  require_relative 'brainzz/responses/video_details_response'
29
+ require_relative 'brainzz/responses/video_stats_response'
27
30
  require_relative 'brainzz/responses/view_count_response'
31
+ require_relative 'brainzz/responses/like_count_response'
28
32
 
29
33
  require_relative 'brainzz/commands/base_command'
30
34
  require_relative 'brainzz/commands/data_command'
31
- require_relative 'brainzz/commands/analytics_command'
32
35
  require_relative 'brainzz/commands/playlist_items_command'
33
36
  require_relative 'brainzz/commands/video_details_command'
34
- require_relative 'brainzz/commands/view_count_command'
37
+ require_relative 'brainzz/commands/analytics_command'
38
+ require_relative 'brainzz/commands/video_stats_command'
39
+ require_relative 'brainzz/commands/view_totals_command'
40
+ require_relative 'brainzz/commands/view_count_by_day_command'
41
+ require_relative 'brainzz/commands/like_totals_command'
42
+ require_relative 'brainzz/commands/like_count_by_day_command'
35
43
 
36
44
  require_relative 'brainzz/core'
37
45
 
@@ -3,16 +3,20 @@ module Brainzz
3
3
  class << self
4
4
  private
5
5
 
6
+ def base_url
7
+ 'https://www.googleapis.com/youtube/analytics/v1'
8
+ end
9
+
10
+ def endpoint
11
+ 'reports'
12
+ end
13
+
6
14
  def headers
7
15
  super.merge({
8
16
  'Authorization' => "Bearer #{access_token}",
9
17
  })
10
18
  end
11
19
 
12
- def base_url
13
- 'https://www.googleapis.com/youtube/analytics/v1'
14
- end
15
-
16
20
  def access_token
17
21
  AccessTokenService.retrieve_token refresh_token
18
22
  end
@@ -20,6 +24,18 @@ module Brainzz
20
24
  def refresh_token
21
25
  ENV['BRAINZZ_REFRESH_TOKEN']
22
26
  end
27
+
28
+ def params(analytics_params)
29
+ super.merge({
30
+ 'ids' => "contentOwner==#{content_owner}",
31
+ 'start-date' => analytics_params.start_date,
32
+ 'end-date' => analytics_params.end_date,
33
+ })
34
+ end
35
+
36
+ def content_owner
37
+ ENV['BRAINZZ_CONTENT_OWNER']
38
+ end
23
39
  end
24
40
  end
25
41
  end
@@ -0,0 +1,14 @@
1
+ module Brainzz
2
+ class LikeCountByDayCommand < LikeTotalsCommand
3
+ class << self
4
+ private
5
+
6
+ def params(video_stats_params)
7
+ super.merge({
8
+ 'dimensions' => 'day',
9
+ 'sort' => 'day',
10
+ })
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,27 @@
1
+ module Brainzz
2
+ class LikeTotalsCommand < VideoStatsCommand
3
+ class << self
4
+ def execute(video_id, start_date, end_date)
5
+ video_stats_params = VideoStatsParams.new ({
6
+ :video_id => video_id,
7
+ :start_date => start_date,
8
+ :end_date => end_date,
9
+ })
10
+
11
+ if video_stats_params.valid?
12
+ LikeCountResponse.new get(video_stats_params)
13
+ else
14
+ LikeCountResponse.new
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def params(video_stats_params)
21
+ super.merge({
22
+ 'metrics' => 'likes',
23
+ })
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,13 @@
1
+ module Brainzz
2
+ class VideoStatsCommand < AnalyticsCommand
3
+ class << self
4
+ private
5
+
6
+ def params(video_stats_params)
7
+ super.merge({
8
+ 'filters' => "video==#{video_stats_params.video_id}",
9
+ })
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Brainzz
2
+ class ViewCountByDayCommand < ViewTotalsCommand
3
+ class << self
4
+ private
5
+
6
+ def params(video_stats_params)
7
+ super.merge({
8
+ 'dimensions' => 'day,insightTrafficSourceType',
9
+ 'sort' => 'day',
10
+ })
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ module Brainzz
2
+ class ViewTotalsCommand < VideoStatsCommand
3
+ class << self
4
+ def execute(video_id, start_date, end_date)
5
+ video_stats_params = VideoStatsParams.new ({
6
+ :video_id => video_id,
7
+ :start_date => start_date,
8
+ :end_date => end_date,
9
+ })
10
+
11
+ if video_stats_params.valid?
12
+ ViewCountResponse.new get(video_stats_params)
13
+ else
14
+ ViewCountResponse.new
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def params(video_stats_params)
21
+ super.merge({
22
+ 'metrics' => 'views',
23
+ 'dimensions' => 'insightTrafficSourceType',
24
+ })
25
+ end
26
+ end
27
+ end
28
+ end
data/lib/brainzz/core.rb CHANGED
@@ -10,8 +10,20 @@ module Brainzz
10
10
  VideoDetailsCommand.execute video_ids
11
11
  end
12
12
 
13
- def views_for(video_id, start_date, end_date)
14
- ViewCountCommand.execute video_id, start_date, end_date
13
+ def views_by_day_for(video_id, start_date, end_date)
14
+ ViewCountByDayCommand.execute video_id, start_date, end_date
15
+ end
16
+
17
+ def view_totals_for(video_id, start_date, end_date)
18
+ ViewTotalsCommand.execute video_id, start_date, end_date
19
+ end
20
+
21
+ def likes_by_day_for(video_id, start_date, end_date)
22
+ LikeCountByDayCommand.execute video_id, start_date, end_date
23
+ end
24
+
25
+ def like_totals_for(video_id, start_date, end_date)
26
+ LikeTotalsCommand.execute video_id, start_date, end_date
15
27
  end
16
28
  end
17
29
  end
@@ -1,5 +1,7 @@
1
1
  module Brainzz
2
2
  module ViewSourceEnum
3
+ extend self
4
+
3
5
  ADVERTISING = 1
4
6
  ANNOTATION = 2
5
7
  EXT_URL = 3
@@ -12,6 +14,10 @@ module Brainzz
12
14
  YT_CHANNEL = 10
13
15
  YT_OTHER_PAGE = 11
14
16
  YT_SEARCH = 12
17
+ EXT_APP = 13
18
+ INFO_CARD = 14
19
+
20
+ UNKNOWN = -1
15
21
 
16
22
  SOURCES = {
17
23
  'advertising' => ADVERTISING,
@@ -26,6 +32,15 @@ module Brainzz
26
32
  'yt_channel' => YT_CHANNEL,
27
33
  'yt_other_page' => YT_OTHER_PAGE,
28
34
  'yt_search' => YT_SEARCH,
35
+ 'ext_app' => EXT_APP,
36
+ 'info_card' => INFO_CARD,
29
37
  }
38
+
39
+ def key_for(value)
40
+ constants.each do |constant|
41
+ return constant.to_s.downcase if const_get(constant) == value
42
+ end
43
+ nil
44
+ end
30
45
  end
31
46
  end
@@ -3,3 +3,4 @@ require_relative 'factories/video'
3
3
  require_relative 'factories/playlist_item'
4
4
  require_relative 'factories/playlist_items_wrapper'
5
5
  require_relative 'factories/view_count'
6
+ require_relative 'factories/like_count'
@@ -0,0 +1,14 @@
1
+ FactoryGirl.define do
2
+ factory :brainzz_like_count, :class => Brainzz::LikeCount do
3
+ likes { rand(1_000_000) + 1 }
4
+ day { DateTime.parse((DateTime.now - rand(100)).strftime('%F')) }
5
+
6
+ factory :brainzz_aggregate_like_count do
7
+ day nil
8
+ end
9
+
10
+ initialize_with do
11
+ Brainzz::LikeCount.new({})
12
+ end
13
+ end
14
+ end
@@ -9,4 +9,8 @@ FactoryGirl.define do
9
9
  sequence(:brainzz_playlist_item_id) { |n| "playlist-item-id-#{n}" }
10
10
 
11
11
  sequence(:brainzz_next_page_token) { |n| "page-token-#{n}" }
12
+
13
+ sequence(:brainzz_view_count_source) do |n|
14
+ n % Brainzz::ViewSourceEnum::SOURCES.count + 1
15
+ end
12
16
  end
@@ -2,13 +2,36 @@ FactoryGirl.define do
2
2
  factory :brainzz_view_count, :class => Brainzz::ViewCount do
3
3
  views { rand(1_000_000) + 1 }
4
4
  day { DateTime.parse((DateTime.now - rand(100)).strftime('%F')) }
5
- source { Brainzz::ViewSourceEnum::SOURCES.values.sample }
5
+ source { generate :brainzz_view_count_source }
6
+
7
+ factory :brainzz_aggregate_view_count do
8
+ day nil
9
+ end
6
10
 
7
11
  Brainzz::ViewSourceEnum::SOURCES.each do |key, value|
8
12
  factory "brainzz_#{key}_view_count".to_sym,
9
13
  :class => Brainzz::ViewCount do
10
14
  source value
11
15
  end
16
+
17
+ factory "brainzz_#{key}_aggregate_view_count".to_sym,
18
+ :class => Brainzz::ViewCount do
19
+ source value
20
+ day nil
21
+ end
22
+ end
23
+
24
+ factory :brainzz_unknown_view_count do
25
+ source nil
26
+ end
27
+
28
+ factory :brainzz_unknown_aggregate_view_count do
29
+ source Brainzz::ViewSourceEnum::UNKNOWN
30
+ day nil
31
+ end
32
+
33
+ initialize_with do
34
+ Brainzz::ViewCount.new({})
12
35
  end
13
36
  end
14
37
  end
@@ -0,0 +1,19 @@
1
+ module Brainzz
2
+ class LikeCount < VideoStat
3
+ attr_accessor :likes
4
+
5
+ def initialize(hash)
6
+ super
7
+
8
+ @hash = hash
9
+
10
+ @likes = normalize_stat(likes_data)
11
+ end
12
+
13
+ private
14
+
15
+ def likes_data
16
+ data && keys['likes'] && data[keys['likes']]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ module Brainzz
2
+ class VideoStat < BaseModel
3
+ attr_accessor :day
4
+
5
+ def initialize(hash)
6
+ @hash = hash
7
+
8
+ @day = transform_date(day_data)
9
+ end
10
+
11
+ private
12
+
13
+ def data
14
+ @hash['data'] || @hash[:data]
15
+ end
16
+
17
+ def keys
18
+ @hash['keys'] || @hash[:keys]
19
+ end
20
+
21
+ def day_data
22
+ data && keys['day'] && data[keys['day']]
23
+ end
24
+
25
+ def normalize_stat(stat)
26
+ stat.to_i if stat
27
+ end
28
+ end
29
+ end
@@ -1,20 +1,29 @@
1
1
  module Brainzz
2
- class ViewCount < BaseModel
3
- attr_accessor :views, :day, :source
2
+ class ViewCount < VideoStat
3
+ attr_accessor :views, :source
4
4
 
5
- def initialize(view_count_row = [])
6
- @views = normalize_views(view_count_row[2])
7
- @day = transform_date(view_count_row[0])
8
- @source = source_value(view_count_row[1])
5
+ def initialize(hash)
6
+ super
7
+
8
+ @hash = hash
9
+
10
+ @views = normalize_stat(views_data)
11
+ @source = source_value(source_data)
9
12
  end
10
13
 
11
14
  private
12
15
 
13
- def normalize_views(views)
14
- return views ? views.to_i : 0
16
+ def views_data
17
+ data && keys['views'] && data[keys['views']]
18
+ end
19
+
20
+ def source_data
21
+ data && keys['insightTrafficSourceType'] &&
22
+ data[keys['insightTrafficSourceType']]
15
23
  end
16
24
 
17
25
  def source_value(source)
26
+ return if source.nil?
18
27
  source = '' unless source.is_a?(String)
19
28
  Brainzz::ViewSourceEnum::SOURCES[source.downcase]
20
29
  end
@@ -1,5 +1,5 @@
1
1
  module Brainzz
2
- class ViewCountParams < AnalyticsParams
2
+ class VideoStatsParams < AnalyticsParams
3
3
  attr_reader :video_id
4
4
 
5
5
  def initialize(params)
@@ -0,0 +1,5 @@
1
+ module Brainzz
2
+ class LikeCountResponse < VideoStatsResponse
3
+ make_with_model LikeCount
4
+ end
5
+ end
@@ -0,0 +1,38 @@
1
+ module Brainzz
2
+ class VideoStatsResponse < Reverb::Response
3
+ class << self
4
+ def model
5
+ @model
6
+ end
7
+
8
+ private
9
+
10
+ def make_with_model(model)
11
+ @model = model
12
+ end
13
+ end
14
+
15
+ private
16
+
17
+ def on_success
18
+ self.data = []
19
+ keys = column_headers
20
+ body['rows'].each do |row|
21
+ self.data << self.class.model.new({
22
+ :data => row,
23
+ :keys => keys,
24
+ })
25
+ end
26
+ end
27
+
28
+ def column_headers
29
+ column_headers = {}
30
+
31
+ body['columnHeaders'].each_with_index do |header, index|
32
+ column_headers[header['name']] = index
33
+ end
34
+
35
+ column_headers
36
+ end
37
+ end
38
+ end
@@ -1,10 +1,5 @@
1
1
  module Brainzz
2
- class ViewCountResponse < Reverb::Response
3
- def on_success
4
- self.data = []
5
- body['rows'].each do |row|
6
- self.data << ViewCount.new(row)
7
- end
8
- end
2
+ class ViewCountResponse < VideoStatsResponse
3
+ make_with_model ViewCount
9
4
  end
10
5
  end
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
8
8
  - Joshua Book
9
+ - Haskel Ash
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2015-03-31 00:00:00.000000000 Z
13
+ date: 2015-04-08 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: faraday
@@ -180,29 +181,38 @@ files:
180
181
  - lib/brainzz/commands/analytics_command.rb
181
182
  - lib/brainzz/commands/base_command.rb
182
183
  - lib/brainzz/commands/data_command.rb
184
+ - lib/brainzz/commands/like_count_by_day_command.rb
185
+ - lib/brainzz/commands/like_totals_command.rb
183
186
  - lib/brainzz/commands/playlist_items_command.rb
184
187
  - lib/brainzz/commands/video_details_command.rb
185
- - lib/brainzz/commands/view_count_command.rb
188
+ - lib/brainzz/commands/video_stats_command.rb
189
+ - lib/brainzz/commands/view_count_by_day_command.rb
190
+ - lib/brainzz/commands/view_totals_command.rb
186
191
  - lib/brainzz/core.rb
187
192
  - lib/brainzz/enums/view_source_enum.rb
188
193
  - lib/brainzz/factories.rb
194
+ - lib/brainzz/factories/like_count.rb
189
195
  - lib/brainzz/factories/playlist_item.rb
190
196
  - lib/brainzz/factories/playlist_items_wrapper.rb
191
197
  - lib/brainzz/factories/sequences.rb
192
198
  - lib/brainzz/factories/video.rb
193
199
  - lib/brainzz/factories/view_count.rb
194
200
  - lib/brainzz/models/base_model.rb
201
+ - lib/brainzz/models/like_count.rb
195
202
  - lib/brainzz/models/playlist_item.rb
196
203
  - lib/brainzz/models/playlist_items_wrapper.rb
197
204
  - lib/brainzz/models/video.rb
205
+ - lib/brainzz/models/video_stat.rb
198
206
  - lib/brainzz/models/view_count.rb
199
207
  - lib/brainzz/params/analytics_params.rb
200
208
  - lib/brainzz/params/base_params.rb
201
209
  - lib/brainzz/params/playlist_items_params.rb
202
210
  - lib/brainzz/params/video_details_params.rb
203
- - lib/brainzz/params/view_count_params.rb
211
+ - lib/brainzz/params/video_stats_params.rb
212
+ - lib/brainzz/responses/like_count_response.rb
204
213
  - lib/brainzz/responses/playlist_items_response.rb
205
214
  - lib/brainzz/responses/video_details_response.rb
215
+ - lib/brainzz/responses/video_stats_response.rb
206
216
  - lib/brainzz/responses/view_count_response.rb
207
217
  - lib/brainzz/services/access_token_service.rb
208
218
  - license/gplv3.md
@@ -1,41 +0,0 @@
1
- module Brainzz
2
- class ViewCountCommand < AnalyticsCommand
3
- class << self
4
- def execute(video_id, start_date, end_date)
5
- view_count_params = ViewCountParams.new({
6
- :video_id => video_id,
7
- :start_date => start_date,
8
- :end_date => end_date
9
- })
10
-
11
- if view_count_params.valid?
12
- ViewCountResponse.new get(view_count_params)
13
- else
14
- ViewCountResponse.new
15
- end
16
- end
17
-
18
- private
19
-
20
- def endpoint
21
- 'reports'
22
- end
23
-
24
- def params(view_count_params)
25
- super.merge({
26
- 'ids' => "contentOwner==#{content_owner}",
27
- 'filters' => "video==#{view_count_params.video_id}",
28
- 'metrics' => 'views',
29
- 'dimensions' => 'day,insightTrafficSourceType',
30
- 'start-date' => view_count_params.start_date,
31
- 'end-date' => view_count_params.end_date,
32
- 'sort' => 'day',
33
- })
34
- end
35
-
36
- def content_owner
37
- ENV['BRAINZZ_CONTENT_OWNER']
38
- end
39
- end
40
- end
41
- end