yt 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ae245f2241c225b65e4d6d45e98f9124afcca9a
4
- data.tar.gz: 5712381f9ea126fe61729b21ed517a1bc9429b55
3
+ metadata.gz: a5e55e68762b528cbc7c42e4fe7e22adf9281696
4
+ data.tar.gz: 90ee508824b125d5c3870033530892cf55d0f333
5
5
  SHA512:
6
- metadata.gz: 69b149b667c9f0684320faa6a45bd62e153cedd1b5d515c2e98f8dfe15b4286a7cda911cb2bc1eee8b5df2ed15ca7b8fad86b525b6f82d1e6a5a13c3a6df9bb4
7
- data.tar.gz: a0701e11530ae0e98a02ef07de7b40be1f1647e557de920de265e21718a886541693f6e14b150d33754495743b2afcbd04fc6796ea960469f5ad4f2eac3e35c0
6
+ metadata.gz: da61fb4dcd83bd430f17be5c41d86fd77c943706ed515644ddefe633753f13d396bcf9c26805c95795881ea8e56fa87377fd41cb4fb9eacbbeaf0f9c46f36c3f
7
+ data.tar.gz: 4e640d95814a39547d4512ee9bdf5f96bc52370c3b0b70d41c8111f11326343464bf6d64087fed7b843406f5f7ef3d1836164a28241506a02b9eeee233c2b0ee
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ For more information about changelogs, check
6
6
  [Keep a Changelog](http://keepachangelog.com) and
7
7
  [Vandamme](http://tech-angels.github.io/vandamme).
8
8
 
9
+ ## 0.28.0 - 2016-10-18
10
+
11
+ **How to upgrade**
12
+
13
+ If your code calls `.earnings` and `.impressions`
14
+ then you must replace that code with `.estimated_revenue` and
15
+ `.ad_impressions` since those metrics will no longer be supported by
16
+ YouTube API as of [November 4, 2016](https://developers.google.com/youtube/analytics/revision_history#august-10-2016).
17
+
18
+ * [breaking change] Change deprecated `earnings` to `estimated_revenue`
19
+ * [breaking change] Change deprecated `impressions` to `ad_impressions`
20
+
9
21
  ## 0.27.0 - 2016-10-07
10
22
 
11
23
  **How to upgrade**
data/lib/yt.rb CHANGED
@@ -18,7 +18,7 @@ require 'yt/models/advertising_options_set'
18
18
  # An object-oriented Ruby client for YouTube.
19
19
  # Helps creating applications that need to interact with YouTube objects.
20
20
  # Inclused methods to access YouTube Data API V3 resources (channels, videos,
21
- # ...), YouTube Analytics API V2 resources (metrics, earnings, ...), and
21
+ # ...), YouTube Analytics API V2 resources (metrics, estimated_revenue, ...), and
22
22
  # objects not available through the API (annotations).
23
23
  module Yt
24
24
  end
@@ -299,11 +299,11 @@ module Yt
299
299
 
300
300
  def define_all_metric_method(metric, type)
301
301
  define_method "all_#{metric}" do
302
- # @note Asking for the "earnings" metric of a day in which a channel
302
+ # @note Asking for the "estimated_revenue" metric of a day in which a channel
303
303
  # made 0 USD returns the wrong "nil". But adding to the request the
304
304
  # "estimatedMinutesWatched" metric returns the correct value 0.
305
305
  metrics = {metric => type}
306
- metrics[:estimated_minutes_watched] = Integer if metric == :earnings
306
+ metrics[:estimated_minutes_watched] = Integer if metric == :estimated_revenue
307
307
  Collections::Reports.of(self).tap{|reports| reports.metrics = metrics}
308
308
  end
309
309
  private "all_#{metric}"
@@ -136,7 +136,7 @@ module Yt
136
136
  elsif dimension.in? [:traffic_source, :country, :state, :playback_location, :device_type, :operating_system, :subscribed_status]
137
137
  hash = hash.transform_values{|h| h.sort_by{|range, v| -v}.to_h}
138
138
  end
139
- (@metrics.one? || @metrics.keys == [:earnings, :estimated_minutes_watched]) ? hash[@metrics.keys.first] : hash
139
+ (@metrics.one? || @metrics.keys == [:estimated_revenue, :estimated_minutes_watched]) ? hash[@metrics.keys.first] : hash
140
140
  end
141
141
  # NOTE: Once in a while, YouTube responds with 400 Error and the message
142
142
  # "Invalid query. Query did not conform to the expectations."; in this
@@ -179,8 +179,8 @@ module Yt
179
179
  params['max-results'] = 50 if @dimension.in? [:playlist, :video]
180
180
  params['max-results'] = 25 if @dimension.in? [:embedded_player_location, :related_video, :search_term, :referrer]
181
181
  if @dimension.in? [:video, :playlist, :embedded_player_location, :related_video, :search_term, :referrer]
182
- if @metrics.keys == [:earnings, :estimated_minutes_watched]
183
- params['sort'] = '-earnings'
182
+ if @metrics.keys == [:estimated_revenue, :estimated_minutes_watched]
183
+ params['sort'] = '-estimatedRevenue'
184
184
  else
185
185
  params['sort'] = "-#{@metrics.keys.join(',').to_s.camelize(:lower)}"
186
186
  end
@@ -181,10 +181,10 @@ module Yt
181
181
  has_report :card_teaser_click_rate, Float
182
182
 
183
183
  # @macro report_by_day_and_country
184
- has_report :earnings, Float
184
+ has_report :estimated_revenue, Float
185
185
 
186
186
  # @macro report_by_day_and_country
187
- has_report :impressions, Integer
187
+ has_report :ad_impressions, Integer
188
188
 
189
189
  # @macro report_by_day_and_country
190
190
  has_report :monetized_playbacks, Integer
@@ -464,10 +464,10 @@ module Yt
464
464
  has_report :card_teaser_click_rate, Float
465
465
 
466
466
  # @macro report_by_day_and_country
467
- has_report :earnings, Float
467
+ has_report :estimated_revenue, Float
468
468
 
469
469
  # @macro report_by_day_and_country
470
- has_report :impressions, Integer
470
+ has_report :ad_impressions, Integer
471
471
 
472
472
  # @macro report_by_day_and_country
473
473
  has_report :monetized_playbacks, Integer
@@ -90,10 +90,10 @@ module Yt
90
90
  has_report :annotation_close_rate, Float
91
91
 
92
92
  # @macro report_by_day_and_country
93
- has_report :earnings, Float
93
+ has_report :estimated_revenue, Float
94
94
 
95
95
  # @macro report_by_day_and_country
96
- has_report :impressions, Integer
96
+ has_report :ad_impressions, Integer
97
97
 
98
98
  # @macro report_by_day_and_country
99
99
  has_report :monetized_playbacks, Integer
data/lib/yt/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yt
2
- VERSION = '0.27.0'
2
+ VERSION = '0.28.0'
3
3
  end
@@ -215,8 +215,8 @@ describe Yt::Channel, :device_app do
215
215
  expect{channel.card_teaser_clicks}.not_to raise_error
216
216
  expect{channel.card_teaser_click_rate}.not_to raise_error
217
217
  expect{channel.viewer_percentage}.not_to raise_error
218
- expect{channel.earnings}.to raise_error Yt::Errors::Unauthorized
219
- expect{channel.impressions}.to raise_error Yt::Errors::Unauthorized
218
+ expect{channel.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
219
+ expect{channel.ad_impressions}.to raise_error Yt::Errors::Unauthorized
220
220
  expect{channel.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
221
221
  expect{channel.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
222
222
  end
@@ -305,8 +305,8 @@ describe Yt::Video, :device_app do
305
305
  expect{video.card_teaser_clicks}.not_to raise_error
306
306
  expect{video.card_teaser_click_rate}.not_to raise_error
307
307
  expect{video.viewer_percentage}.not_to raise_error
308
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
309
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
308
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
309
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
310
310
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
311
311
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
312
312
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -710,8 +710,8 @@ describe Yt::Video, :device_app do
710
710
  expect{video.annotation_click_through_rate}.not_to raise_error
711
711
  expect{video.annotation_close_rate}.not_to raise_error
712
712
  expect{video.viewer_percentage}.not_to raise_error
713
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
714
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
713
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
714
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
715
715
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
716
716
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
717
717
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -1096,8 +1096,8 @@ describe Yt::Video, :device_app do
1096
1096
  expect{video.annotation_click_through_rate}.not_to raise_error
1097
1097
  expect{video.annotation_close_rate}.not_to raise_error
1098
1098
  expect{video.viewer_percentage}.not_to raise_error
1099
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
1100
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
1099
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
1100
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
1101
1101
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
1102
1102
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
1103
1103
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -1501,8 +1501,8 @@ describe Yt::Video, :device_app do
1501
1501
  expect{video.annotation_click_through_rate}.not_to raise_error
1502
1502
  expect{video.annotation_close_rate}.not_to raise_error
1503
1503
  expect{video.viewer_percentage}.not_to raise_error
1504
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
1505
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
1504
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
1505
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
1506
1506
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
1507
1507
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
1508
1508
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -1906,8 +1906,8 @@ describe Yt::Video, :device_app do
1906
1906
  expect{video.annotation_click_through_rate}.not_to raise_error
1907
1907
  expect{video.annotation_close_rate}.not_to raise_error
1908
1908
  expect{video.viewer_percentage}.not_to raise_error
1909
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
1910
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
1909
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
1910
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
1911
1911
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
1912
1912
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
1913
1913
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -2312,8 +2312,8 @@ describe Yt::Video, :device_app do
2312
2312
  expect{video.annotation_click_through_rate}.not_to raise_error
2313
2313
  expect{video.annotation_close_rate}.not_to raise_error
2314
2314
  expect{video.viewer_percentage}.not_to raise_error
2315
- expect{video.earnings}.to raise_error Yt::Errors::Unauthorized
2316
- expect{video.impressions}.to raise_error Yt::Errors::Unauthorized
2315
+ expect{video.estimated_revenue}.to raise_error Yt::Errors::Unauthorized
2316
+ expect{video.ad_impressions}.to raise_error Yt::Errors::Unauthorized
2317
2317
  expect{video.monetized_playbacks}.to raise_error Yt::Errors::Unauthorized
2318
2318
  expect{video.playback_based_cpm}.to raise_error Yt::Errors::Unauthorized
2319
2319
  expect{video.advertising_options_set}.to raise_error Yt::Errors::Forbidden
@@ -22,7 +22,7 @@ describe Yt::Channel, :partner do
22
22
  card_impressions: Integer, card_clicks: Integer,
23
23
  card_click_rate: Float, card_teaser_impressions: Integer,
24
24
  card_teaser_clicks: Integer, card_teaser_click_rate: Float,
25
- earnings: Float, impressions: Integer,
25
+ estimated_revenue: Float, ad_impressions: Integer,
26
26
  monetized_playbacks: Integer, playback_based_cpm: Float}
27
27
  specify 'by day, and are chronologically sorted' do
28
28
  range = {since: 5.days.ago.to_date, until: 3.days.ago.to_date}
@@ -63,11 +63,11 @@ describe Yt::Channel, :partner do
63
63
  :subscribers_gained, :subscribers_lost,
64
64
  :videos_added_to_playlists, :videos_removed_from_playlists,
65
65
  :estimated_minutes_watched, :average_view_duration,
66
- :average_view_percentage, :impressions, :monetized_playbacks,
66
+ :average_view_percentage, :ad_impressions, :monetized_playbacks,
67
67
  :annotation_clicks, :annotation_click_through_rate,
68
68
  :card_impressions, :card_clicks, :card_click_rate,
69
69
  :card_teaser_impressions, :card_teaser_clicks, :card_teaser_click_rate,
70
- :playback_based_cpm, :annotation_close_rate, :earnings].each do |metric|
70
+ :playback_based_cpm, :annotation_close_rate, :estimated_revenue].each do |metric|
71
71
  describe "#{metric} can be retrieved for a range of days" do
72
72
  let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
73
73
  let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
@@ -126,10 +126,10 @@ describe Yt::Channel, :partner do
126
126
  card_click_rate: Float, card_teaser_impressions: Integer,
127
127
  card_teaser_clicks: Integer, card_teaser_click_rate: Float,
128
128
  videos_added_to_playlists: Integer, videos_removed_from_playlists: Integer,
129
- average_view_percentage: Float, impressions: Integer,
129
+ average_view_percentage: Float, ad_impressions: Integer,
130
130
  shares: Integer, playback_based_cpm: Float,
131
131
  monetized_playbacks: Integer, annotation_close_rate: Float,
132
- earnings: Float}.each do |metric, type|
132
+ estimated_revenue: Float}.each do |metric, type|
133
133
  describe "#{metric} can be grouped by range" do
134
134
  let(:metric) { metric }
135
135
 
@@ -151,24 +151,24 @@ describe Yt::Channel, :partner do
151
151
  end
152
152
  end
153
153
 
154
- describe 'earnings can be retrieved for a specific day' do
154
+ describe 'estimated_revenue can be retrieved for a specific day' do
155
155
  # NOTE: This test sounds redundant, but it’s actually a reflection of
156
156
  # another irrational behavior of YouTube API. In short, if you ask for
157
- # the "earnings" metric of a day in which a channel made 0 USD, then
158
- # the API returns "nil". But if you also for the "earnings" metric AND
157
+ # the "estimated_revenue" metric of a day in which a channel made 0 USD, then
158
+ # the API returns "nil". But if you also for the "estimated_revenue" metric AND
159
159
  # the "estimatedMinutesWatched" metric, then the API returns the
160
160
  # correct value of "0", while still returning nil for those days in
161
- # which the earnings have not been estimated yet.
161
+ # which the estimated_revenue have not been estimated yet.
162
162
  context 'in which the channel did not make any money' do
163
- let(:zero_date) { ENV['YT_TEST_PARTNER_CHANNEL_NO_EARNINGS_DATE'] }
164
- let(:earnings) { channel.earnings_on zero_date}
165
- it { expect(earnings).to eq 0 }
163
+ let(:zero_date) { ENV['YT_TEST_PARTNER_CHANNEL_NO_estimated_revenue_DATE'] }
164
+ let(:estimated_revenue) { channel.estimated_revenue_on zero_date}
165
+ it { expect(estimated_revenue).to eq 0 }
166
166
  end
167
167
  end
168
168
 
169
- describe 'earnings can be retrieved for a single country' do
169
+ describe 'estimated_revenue can be retrieved for a single country' do
170
170
  let(:country_code) { 'US' }
171
- let(:earnings) { channel.earnings since: date, by: by, in: location }
171
+ let(:estimated_revenue) { channel.estimated_revenue since: date, by: by, in: location }
172
172
  let(:date) { 4.days.ago }
173
173
 
174
174
  context 'and grouped by day' do
@@ -176,12 +176,12 @@ describe Yt::Channel, :partner do
176
176
 
177
177
  context 'with the :in option set to the country code' do
178
178
  let(:location) { country_code }
179
- it { expect(earnings.keys.min).to eq date.to_date }
179
+ it { expect(estimated_revenue.keys.min).to eq date.to_date }
180
180
  end
181
181
 
182
182
  context 'with the :in option set to {country: country code}' do
183
183
  let(:location) { {country: country_code} }
184
- it { expect(earnings.keys.min).to eq date.to_date }
184
+ it { expect(estimated_revenue.keys.min).to eq date.to_date }
185
185
  end
186
186
  end
187
187
 
@@ -190,34 +190,34 @@ describe Yt::Channel, :partner do
190
190
 
191
191
  context 'with the :in option set to the country code' do
192
192
  let(:location) { country_code }
193
- it { expect(earnings.keys).to eq [country_code] }
193
+ it { expect(estimated_revenue.keys).to eq [country_code] }
194
194
  end
195
195
 
196
196
  context 'with the :in option set to {country: country code}' do
197
197
  let(:location) { {country: country_code} }
198
- it { expect(earnings.keys).to eq [country_code] }
198
+ it { expect(estimated_revenue.keys).to eq [country_code] }
199
199
  end
200
200
  end
201
201
  end
202
202
 
203
- describe 'earnings can be grouped by day' do
203
+ describe 'estimated_revenue can be grouped by day' do
204
204
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
205
205
  let(:keys) { range.values }
206
206
 
207
207
  specify 'with the :by option set to :day' do
208
- earnings = channel.earnings range.merge by: :day
209
- expect(earnings.keys).to eq range.values
208
+ estimated_revenue = channel.estimated_revenue range.merge by: :day
209
+ expect(estimated_revenue.keys).to eq range.values
210
210
  end
211
211
  end
212
212
 
213
- describe 'earnings can be grouped by country' do
213
+ describe 'estimated_revenue can be grouped by country' do
214
214
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
215
215
 
216
216
  specify 'with the :by option set to :country' do
217
- earnings = channel.earnings range.merge by: :country
218
- expect(earnings.keys).to all(be_a String)
219
- expect(earnings.keys.map(&:length).uniq).to eq [2]
220
- expect(earnings.values).to all(be_a Float)
217
+ estimated_revenue = channel.estimated_revenue range.merge by: :country
218
+ expect(estimated_revenue.keys).to all(be_a String)
219
+ expect(estimated_revenue.keys.map(&:length).uniq).to eq [2]
220
+ expect(estimated_revenue.values).to all(be_a Float)
221
221
  end
222
222
  end
223
223
 
@@ -1319,9 +1319,9 @@ describe Yt::Channel, :partner do
1319
1319
  end
1320
1320
  end
1321
1321
 
1322
- describe 'impressions can be retrieved for a single country' do
1322
+ describe 'ad_impressions can be retrieved for a single country' do
1323
1323
  let(:country_code) { 'US' }
1324
- let(:impressions) { channel.impressions since: date, by: by, in: location }
1324
+ let(:ad_impressions) { channel.ad_impressions since: date, by: by, in: location }
1325
1325
  let(:date) { ENV['YT_TEST_PARTNER_PLAYLIST_DATE'] }
1326
1326
 
1327
1327
  context 'and grouped by day' do
@@ -1329,12 +1329,12 @@ describe Yt::Channel, :partner do
1329
1329
 
1330
1330
  context 'with the :in option set to the country code' do
1331
1331
  let(:location) { country_code }
1332
- it { expect(impressions.keys.min).to eq date.to_date }
1332
+ it { expect(ad_impressions.keys.min).to eq date.to_date }
1333
1333
  end
1334
1334
 
1335
1335
  context 'with the :in option set to {country: country code}' do
1336
1336
  let(:location) { {country: country_code} }
1337
- it { expect(impressions.keys.min).to eq date.to_date }
1337
+ it { expect(ad_impressions.keys.min).to eq date.to_date }
1338
1338
  end
1339
1339
  end
1340
1340
 
@@ -1343,34 +1343,34 @@ describe Yt::Channel, :partner do
1343
1343
 
1344
1344
  context 'with the :in option set to the country code' do
1345
1345
  let(:location) { country_code }
1346
- it { expect(impressions.keys).to eq [country_code] }
1346
+ it { expect(ad_impressions.keys).to eq [country_code] }
1347
1347
  end
1348
1348
 
1349
1349
  context 'with the :in option set to {country: country code}' do
1350
1350
  let(:location) { {country: country_code} }
1351
- it { expect(impressions.keys).to eq [country_code] }
1351
+ it { expect(ad_impressions.keys).to eq [country_code] }
1352
1352
  end
1353
1353
  end
1354
1354
  end
1355
1355
 
1356
- describe 'impressions can be grouped by day' do
1356
+ describe 'ad_impressions can be grouped by day' do
1357
1357
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
1358
1358
  let(:keys) { range.values }
1359
1359
 
1360
1360
  specify 'with the :by option set to :day' do
1361
- impressions = channel.impressions range.merge by: :day
1362
- expect(impressions.keys).to eq range.values
1361
+ ad_impressions = channel.ad_impressions range.merge by: :day
1362
+ expect(ad_impressions.keys).to eq range.values
1363
1363
  end
1364
1364
  end
1365
1365
 
1366
- describe 'impressions can be grouped by country' do
1366
+ describe 'ad_impressions can be grouped by country' do
1367
1367
  let(:range) { {since: ENV['YT_TEST_PARTNER_PLAYLIST_DATE']} }
1368
1368
 
1369
1369
  specify 'with the :by option set to :country' do
1370
- impressions = channel.impressions range.merge by: :country
1371
- expect(impressions.keys).to all(be_a String)
1372
- expect(impressions.keys.map(&:length).uniq).to eq [2]
1373
- expect(impressions.values).to all(be_an Integer)
1370
+ ad_impressions = channel.ad_impressions range.merge by: :country
1371
+ expect(ad_impressions.keys).to all(be_a String)
1372
+ expect(ad_impressions.keys.map(&:length).uniq).to eq [2]
1373
+ expect(ad_impressions.values).to all(be_an Integer)
1374
1374
  end
1375
1375
  end
1376
1376
 
@@ -1872,8 +1872,8 @@ describe Yt::Channel, :partner do
1872
1872
  context 'not managed by the authenticated Content Owner' do
1873
1873
  let(:id) { 'UCBR8-60-B28hp2BmDPdntcQ' }
1874
1874
 
1875
- specify 'earnings and impressions cannot be retrieved' do
1876
- expect{channel.earnings}.to raise_error Yt::Errors::Forbidden
1875
+ specify 'estimated_revenue and ad_impressions cannot be retrieved' do
1876
+ expect{channel.estimated_revenue}.to raise_error Yt::Errors::Forbidden
1877
1877
  expect{channel.views}.to raise_error Yt::Errors::Forbidden
1878
1878
  end
1879
1879
 
@@ -1883,4 +1883,4 @@ describe Yt::Channel, :partner do
1883
1883
  end
1884
1884
  end
1885
1885
  end
1886
- end
1886
+ end
@@ -60,7 +60,7 @@ describe Yt::VideoGroup, :partner do
60
60
  average_view_duration: Integer,
61
61
  average_view_percentage: Float, annotation_clicks: Integer,
62
62
  annotation_click_through_rate: Float,
63
- annotation_close_rate: Float, earnings: Float, impressions: Integer,
63
+ annotation_close_rate: Float, estimated_revenue: Float, ad_impressions: Integer,
64
64
  monetized_playbacks: Integer}
65
65
 
66
66
  specify 'by day, and are chronologically sorted' do
@@ -17,11 +17,11 @@ describe Yt::Video, :partner do
17
17
  :subscribers_gained, :subscribers_lost,
18
18
  :videos_added_to_playlists, :videos_removed_from_playlists,
19
19
  :estimated_minutes_watched, :average_view_duration,
20
- :average_view_percentage, :impressions, :monetized_playbacks,
20
+ :average_view_percentage, :ad_impressions, :monetized_playbacks,
21
21
  :annotation_clicks, :annotation_click_through_rate, :playback_based_cpm,
22
22
  :card_impressions, :card_clicks, :card_click_rate,
23
23
  :card_teaser_impressions, :card_teaser_clicks, :card_teaser_click_rate,
24
- :annotation_close_rate, :earnings].each do |metric|
24
+ :annotation_close_rate, :estimated_revenue].each do |metric|
25
25
  describe "#{metric} can be retrieved for a range of days" do
26
26
  let(:date_in) { ENV['YT_TEST_PARTNER_VIDEO_DATE'] }
27
27
  let(:date_out) { Date.parse(ENV['YT_TEST_PARTNER_VIDEO_DATE']) + 5 }
@@ -94,13 +94,13 @@ describe Yt::Video, :partner do
94
94
  shares: Integer, subscribers_gained: Integer, subscribers_lost: Integer,
95
95
  videos_added_to_playlists: Integer, videos_removed_from_playlists: Integer,
96
96
  estimated_minutes_watched: Integer, average_view_duration: Integer,
97
- average_view_percentage: Float, impressions: Integer,
97
+ average_view_percentage: Float, ad_impressions: Integer,
98
98
  monetized_playbacks: Integer, annotation_clicks: Integer,
99
99
  annotation_click_through_rate: Float, annotation_close_rate: Float,
100
100
  card_impressions: Integer, card_clicks: Integer,
101
101
  card_click_rate: Float, card_teaser_impressions: Integer,
102
102
  card_teaser_clicks: Integer, card_teaser_click_rate: Float,
103
- earnings: Float}.each do |metric, type|
103
+ estimated_revenue: Float}.each do |metric, type|
104
104
  describe "#{metric} can be grouped by range" do
105
105
  let(:metric) { metric }
106
106
 
@@ -126,11 +126,11 @@ describe Yt::Video, :partner do
126
126
  :subscribers_gained, :subscribers_lost,
127
127
  :videos_added_to_playlists, :videos_removed_from_playlists,
128
128
  :estimated_minutes_watched, :average_view_duration,
129
- :average_view_percentage, :impressions, :monetized_playbacks,
129
+ :average_view_percentage, :ad_impressions, :monetized_playbacks,
130
130
  :card_impressions, :card_clicks, :card_click_rate,
131
131
  :card_teaser_impressions, :card_teaser_clicks, :card_teaser_click_rate,
132
132
  :annotation_clicks, :annotation_click_through_rate,
133
- :annotation_close_rate, :earnings].each do |metric|
133
+ :annotation_close_rate, :estimated_revenue].each do |metric|
134
134
  describe "#{metric} can be retrieved for a single country" do
135
135
  let(:result) { video.public_send metric, options }
136
136
 
@@ -185,7 +185,7 @@ describe Yt::Video, :partner do
185
185
  card_click_rate: Float, card_teaser_impressions: Integer,
186
186
  card_teaser_clicks: Integer, card_teaser_click_rate: Float,
187
187
  annotation_click_through_rate: Float,
188
- annotation_close_rate: Float, earnings: Float, impressions: Integer,
188
+ annotation_close_rate: Float, estimated_revenue: Float, ad_impressions: Integer,
189
189
  monetized_playbacks: Integer}
190
190
 
191
191
  specify 'by day' do
@@ -222,24 +222,24 @@ describe Yt::Video, :partner do
222
222
  end
223
223
  end
224
224
 
225
- describe 'earnings can be grouped by day' do
225
+ describe 'estimated_revenue can be grouped by day' do
226
226
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
227
227
  let(:keys) { range.values }
228
228
 
229
229
  specify 'with the :by option set to :day' do
230
- earnings = video.earnings range.merge by: :day
231
- expect(earnings.keys).to eq range.values
230
+ estimated_revenue = video.estimated_revenue range.merge by: :day
231
+ expect(estimated_revenue.keys).to eq range.values
232
232
  end
233
233
  end
234
234
 
235
- describe 'earnings can be grouped by country' do
235
+ describe 'estimated_revenue can be grouped by country' do
236
236
  let(:range) { {since: 4.days.ago, until: 3.days.ago} }
237
237
 
238
238
  specify 'with the :by option set to :country' do
239
- earnings = video.earnings range.merge by: :country
240
- expect(earnings.keys).to all(be_a String)
241
- expect(earnings.keys.map(&:length).uniq).to eq [2]
242
- expect(earnings.values).to all(be_a Float)
239
+ estimated_revenue = video.estimated_revenue range.merge by: :country
240
+ expect(estimated_revenue.keys).to all(be_a String)
241
+ expect(estimated_revenue.keys.map(&:length).uniq).to eq [2]
242
+ expect(estimated_revenue.values).to all(be_a Float)
243
243
  end
244
244
  end
245
245
 
@@ -874,24 +874,24 @@ describe Yt::Video, :partner do
874
874
  end
875
875
  end
876
876
 
877
- describe 'impressions can be grouped by day' do
877
+ describe 'ad_impressions can be grouped by day' do
878
878
  let(:range) { {since: 4.days.ago.to_date, until: 3.days.ago.to_date} }
879
879
  let(:keys) { range.values }
880
880
 
881
881
  specify 'with the :by option set to :day' do
882
- impressions = video.impressions range.merge by: :day
883
- expect(impressions.keys).to eq range.values
882
+ ad_impressions = video.ad_impressions range.merge by: :day
883
+ expect(ad_impressions.keys).to eq range.values
884
884
  end
885
885
  end
886
886
 
887
- describe 'impressions can be grouped by country' do
887
+ describe 'ad_impressions can be grouped by country' do
888
888
  let(:range) { {since: ENV['YT_TEST_PARTNER_VIDEO_DATE']} }
889
889
 
890
890
  specify 'with the :by option set to :country' do
891
- impressions = video.impressions range.merge by: :country
892
- expect(impressions.keys).to all(be_a String)
893
- expect(impressions.keys.map(&:length).uniq).to eq [2]
894
- expect(impressions.values).to all(be_an Integer)
891
+ ad_impressions = video.ad_impressions range.merge by: :country
892
+ expect(ad_impressions.keys).to all(be_a String)
893
+ expect(ad_impressions.keys.map(&:length).uniq).to eq [2]
894
+ expect(ad_impressions.values).to all(be_an Integer)
895
895
  end
896
896
  end
897
897
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Claudio Baccigalupo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-10-10 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport