brainzz 0.0.13 → 0.0.14

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: 2a671d124176c1959b3197fd55e6637c610a5ae7
4
- data.tar.gz: 1b9ab27231a0fb1983816d84a5774243d303a7fe
3
+ metadata.gz: 5c3b7c8a7a3823fe06e1f4b09a528d6f9772f6f7
4
+ data.tar.gz: 9f415ab84b1f27e291c414a7832a3b72ecc751e4
5
5
  SHA512:
6
- metadata.gz: 26065917c46b2207eb9d79ed1a5af5338aca388aaca4283946222ca601ef220c19b2e0ac96760ad070b3dceb48e0478ce51db5f820f6d58a65b03574155e1199
7
- data.tar.gz: 3ebbc06bedd1e8689c3fce27ca2417c89bfbf04b702ee0173069047f52f0eec613fa52ed9758f554be7dc04dfa99e12054e438bd6c62eb8a01aaf25759d6dde1
6
+ metadata.gz: 5ee2a8f8a1b3fe7d5f2e18b3bd5e6e50bcdb67a2daef4d37d361f0d5f4e304f01d601cd71c4d18cd1c92cdcbab99c9e4111a9eb60d631887d851f2c5940f4456
7
+ data.tar.gz: 46fbc04ae7d163b4c03388aff58d006fd47bcb44fddd35b9eb2298081d30dfdd63309c8b25db8d1457b2b6d17c1d3c249a5ef673de4db9aeaa4396f5b41da523
data/README.md CHANGED
@@ -72,6 +72,31 @@ Every response from the public API is wrapped in a `Response` object
72
72
  that will always have the same interface regardless of request.
73
73
  The `Response#data` attribute will be an object specific to the data requested.
74
74
 
75
+ ### channel_details_for
76
+
77
+ Accepts an array of channel ids.
78
+ The maximum length of the array is determined by YouTube.
79
+
80
+ This endpoint returns a hash with channel ids as keys
81
+ and channel objects as the values.
82
+
83
+ #### Channel Attributes Accessible
84
+
85
+ * id
86
+ * title
87
+ * published_at
88
+ * description
89
+ * uploads_playlist
90
+ * likes_playlist
91
+ * google_plus_id
92
+ * view_count
93
+ * comment_count
94
+ * subscriber_count
95
+ * video_count
96
+
97
+ #### Parameters
98
+
99
+ * channel ids (Array[String])
75
100
 
76
101
  ### playlist_items_for
77
102
 
@@ -10,6 +10,7 @@ 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/channel'
13
14
  require_relative 'brainzz/models/stat'
14
15
  require_relative 'brainzz/models/video_stat'
15
16
  require_relative 'brainzz/models/channel_stat'
@@ -37,12 +38,15 @@ require_relative 'brainzz/params/base_params'
37
38
  require_relative 'brainzz/params/analytics_params'
38
39
  require_relative 'brainzz/params/stats_params'
39
40
  require_relative 'brainzz/params/video_details_params'
41
+ require_relative 'brainzz/params/channel_details_params'
40
42
  require_relative 'brainzz/params/video_stats_params'
41
43
  require_relative 'brainzz/params/channel_stats_params'
42
44
  require_relative 'brainzz/params/playlist_items_params'
43
45
 
44
46
  require_relative 'brainzz/responses/playlist_items_response'
47
+ require_relative 'brainzz/responses/details_response'
45
48
  require_relative 'brainzz/responses/video_details_response'
49
+ require_relative 'brainzz/responses/channel_details_response'
46
50
  require_relative 'brainzz/responses/video_stats_response'
47
51
  require_relative 'brainzz/responses/view_count_response'
48
52
  require_relative 'brainzz/responses/like_count_response'
@@ -62,6 +66,7 @@ require_relative 'brainzz/commands/base_command'
62
66
  require_relative 'brainzz/commands/data_command'
63
67
  require_relative 'brainzz/commands/playlist_items_command'
64
68
  require_relative 'brainzz/commands/video_details_command'
69
+ require_relative 'brainzz/commands/channel_details_command'
65
70
  require_relative 'brainzz/commands/analytics_command'
66
71
  require_relative 'brainzz/commands/stats_command'
67
72
  require_relative 'brainzz/commands/video_stats_command'
@@ -0,0 +1,29 @@
1
+ module Brainzz
2
+ class ChannelDetailsCommand < DataCommand
3
+ class << self
4
+ private
5
+
6
+ def on_execute(channel_ids)
7
+ channel_details_params = ChannelDetailsParams.new(channel_ids)
8
+
9
+ if channel_details_params.valid?
10
+ response = get(channel_details_params)
11
+ ChannelDetailsResponse.new response
12
+ else
13
+ ChannelDetailsResponse.new
14
+ end
15
+ end
16
+
17
+ def endpoint
18
+ 'channels'
19
+ end
20
+
21
+ def params(channel_details_params)
22
+ super.merge({
23
+ 'id' => channel_details_params.channel_ids.join(','),
24
+ 'part' => 'snippet,contentDetails,statistics'
25
+ })
26
+ end
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,10 @@ module Brainzz
2
2
  module Core
3
3
  extend self
4
4
 
5
+ def channel_details_for(channel_ids)
6
+ ChannelDetailsCommand.execute channel_ids
7
+ end
8
+
5
9
  def playlist_items_for(playlist_id, response = nil)
6
10
  PlaylistItemsCommand.execute playlist_id, response
7
11
  end
@@ -0,0 +1,107 @@
1
+ module Brainzz
2
+ class Channel < BaseModel
3
+ attr_accessor :id,
4
+ :title,
5
+ :published_at,
6
+ :description,
7
+ :uploads_playlist,
8
+ :likes_playlist,
9
+ :google_plus_id,
10
+ :view_count,
11
+ :comment_count,
12
+ :subscriber_count,
13
+ :video_count
14
+
15
+
16
+ def initialize(hash = {})
17
+ @hash = hash || {}
18
+
19
+ @id = transform(hash_id)
20
+
21
+ initialize_snippet
22
+ initialize_content_details
23
+ initialize_statistics
24
+ end
25
+
26
+ private
27
+
28
+ def hash_id
29
+ @hash['channelId'] || @hash['id']
30
+ end
31
+
32
+ def initialize_snippet
33
+ @title = transform(hash_title)
34
+ @description = transform(hash_description)
35
+ @published_at = transform_date(hash_published_at)
36
+ end
37
+
38
+ def snippet
39
+ @hash['snippet'] || {}
40
+ end
41
+
42
+ def hash_title
43
+ snippet['title']
44
+ end
45
+
46
+ def hash_description
47
+ snippet['description']
48
+ end
49
+
50
+ def hash_published_at
51
+ snippet['publishedAt']
52
+ end
53
+
54
+ def initialize_content_details
55
+ @uploads_playlist = transform(hash_uploads_playlist)
56
+ @likes_playlist = transform(hash_likes_playlist)
57
+ @google_plus_id = transform(hash_google_plus_id)
58
+ end
59
+
60
+ def content_details
61
+ @hash['contentDetails'] || {}
62
+ end
63
+
64
+ def related_playlists
65
+ content_details['relatedPlaylists']
66
+ end
67
+
68
+ def hash_google_plus_id
69
+ content_details['googlePlusUserId']
70
+ end
71
+
72
+ def hash_uploads_playlist
73
+ related_playlists['uploads']
74
+ end
75
+
76
+ def hash_likes_playlist
77
+ related_playlists['likes']
78
+ end
79
+
80
+ def initialize_statistics
81
+ @view_count = transform(hash_view_count)
82
+ @comment_count = transform(hash_comment_count)
83
+ @subscriber_count = transform(hash_subscriber_count)
84
+ @video_count = transform(hash_video_count)
85
+ end
86
+
87
+ def statistics
88
+ @hash['statistics'] || {}
89
+ end
90
+
91
+ def hash_view_count
92
+ statistics['viewCount']
93
+ end
94
+
95
+ def hash_comment_count
96
+ statistics['commentCount']
97
+ end
98
+
99
+ def hash_subscriber_count
100
+ statistics['subscriberCount']
101
+ end
102
+
103
+ def hash_video_count
104
+ statistics['videoCount']
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,13 @@
1
+ module Brainzz
2
+ class ChannelDetailsParams
3
+ attr_reader :channel_ids
4
+
5
+ def initialize(channel_ids)
6
+ @channel_ids = channel_ids
7
+ end
8
+
9
+ def valid?
10
+ !!(@channel_ids && !@channel_ids.empty?)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module Brainzz
2
+ class ChannelDetailsResponse < DetailsResponse
3
+ make_with_model Channel
4
+ end
5
+ end
@@ -0,0 +1,25 @@
1
+ module Brainzz
2
+ class DetailsResponse < ::Reverb::Response
3
+ class << self
4
+ private
5
+
6
+ def make_with_model(model)
7
+ @model = model
8
+ end
9
+
10
+ def model
11
+ @model
12
+ end
13
+ end
14
+
15
+ def on_success
16
+ self.data = {}
17
+
18
+ items = body['items'] || []
19
+ items.each do |item|
20
+ instance = self.class.send(:model).new(item)
21
+ self.data[instance.id] = instance
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,13 +1,5 @@
1
1
  module Brainzz
2
- class VideoDetailsResponse < ::Reverb::Response
3
- def on_success
4
- self.data = {}
5
-
6
- items = body['items'] || []
7
- items.each do |item|
8
- video = Video.new(item)
9
- self.data[video.id] = video
10
- end
11
- end
2
+ class VideoDetailsResponse < DetailsResponse
3
+ make_with_model Video
12
4
  end
13
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brainzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Herrick
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-06 00:00:00.000000000 Z
13
+ date: 2015-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -184,6 +184,7 @@ files:
184
184
  - lib/brainzz/commands/annotations_clicked_by_day_command.rb
185
185
  - lib/brainzz/commands/annotations_clicked_totals_command.rb
186
186
  - lib/brainzz/commands/base_command.rb
187
+ - lib/brainzz/commands/channel_details_command.rb
187
188
  - lib/brainzz/commands/channel_stats_command.rb
188
189
  - lib/brainzz/commands/channel_subscribers_gained_by_day_command.rb
189
190
  - lib/brainzz/commands/channel_subscribers_gained_totals_command.rb
@@ -234,6 +235,7 @@ files:
234
235
  - lib/brainzz/models/annotations_clickable_count.rb
235
236
  - lib/brainzz/models/annotations_clicked_count.rb
236
237
  - lib/brainzz/models/base_model.rb
238
+ - lib/brainzz/models/channel.rb
237
239
  - lib/brainzz/models/channel_stat.rb
238
240
  - lib/brainzz/models/channel_subscribers_gained_count.rb
239
241
  - lib/brainzz/models/channel_subscribers_lost_count.rb
@@ -255,6 +257,7 @@ files:
255
257
  - lib/brainzz/models/view_percentage.rb
256
258
  - lib/brainzz/params/analytics_params.rb
257
259
  - lib/brainzz/params/base_params.rb
260
+ - lib/brainzz/params/channel_details_params.rb
258
261
  - lib/brainzz/params/channel_stats_params.rb
259
262
  - lib/brainzz/params/playlist_items_params.rb
260
263
  - lib/brainzz/params/stats_params.rb
@@ -262,9 +265,11 @@ files:
262
265
  - lib/brainzz/params/video_stats_params.rb
263
266
  - lib/brainzz/responses/annotations_clickable_response.rb
264
267
  - lib/brainzz/responses/annotations_clicked_response.rb
268
+ - lib/brainzz/responses/channel_details_response.rb
265
269
  - lib/brainzz/responses/channel_subscribers_gained_response.rb
266
270
  - lib/brainzz/responses/channel_subscribers_lost_response.rb
267
271
  - lib/brainzz/responses/comment_count_response.rb
272
+ - lib/brainzz/responses/details_response.rb
268
273
  - lib/brainzz/responses/dislike_count_response.rb
269
274
  - lib/brainzz/responses/like_count_response.rb
270
275
  - lib/brainzz/responses/playlist_items_response.rb