sproutvideo-rb 1.2.0 → 1.2.1

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.
@@ -0,0 +1,73 @@
1
+ module Sproutvideo
2
+ class Analytics < Resource
3
+
4
+ def self.play_counts(options={})
5
+ url = "/stats/counts"
6
+ if options.include?(:video_id)
7
+ video_id = options.delete(:video_id)
8
+ url += "/#{video_id}"
9
+ end
10
+ get(url, options)
11
+ end
12
+
13
+ def self.domains(options={})
14
+ url = "/stats/domains"
15
+ if options.include?(:video_id)
16
+ video_id = options.delete(:video_id)
17
+ url += "/#{video_id}"
18
+ end
19
+ get(url, options)
20
+ end
21
+
22
+ def self.geo(options={})
23
+ url = "/stats/geo"
24
+ if options.include?(:video_id)
25
+ video_id = options.delete(:video_id)
26
+ url += "/#{video_id}"
27
+ end
28
+ get(url, options)
29
+ end
30
+
31
+ def self.video_types(options={})
32
+ url = "/stats/video_types"
33
+ if options.include?(:video_id)
34
+ video_id = options.delete(:video_id)
35
+ url += "/#{video_id}"
36
+ end
37
+ get(url, options)
38
+ end
39
+
40
+ def self.playback_types(options={})
41
+ url = "/stats/playback_types"
42
+ if options.include?(:video_id)
43
+ video_id = options.delete(:video_id)
44
+ url += "/#{video_id}"
45
+ end
46
+ get(url, options)
47
+ end
48
+
49
+ def self.device_types(options={})
50
+ url = "/stats/device_types"
51
+ if options.include?(:video_id)
52
+ video_id = options.delete(:video_id)
53
+ url += "/#{video_id}"
54
+ end
55
+ get(url, options)
56
+ end
57
+
58
+ def self.engagement(options={})
59
+ url = "/stats/engagement"
60
+ if options.include?(:video_id)
61
+ video_id = options.delete(:video_id)
62
+ url += "/#{video_id}"
63
+ end
64
+ get(url, options)
65
+ end
66
+
67
+ def self.engagement_sessions(video_id, options={})
68
+ url = "/stats/engagement/#{video_id}/sessions"
69
+ get(url, options)
70
+ end
71
+
72
+ end
73
+ end
@@ -1,3 +1,3 @@
1
1
  module Sproutvideo
2
- VERSION = "1.2.0"
2
+ VERSION = "1.2.1"
3
3
  end
@@ -0,0 +1,205 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
2
+ describe Sproutvideo::Analytics do
3
+ before(:each) do
4
+ @api_key = 'abc123'
5
+ Sproutvideo.api_key = @api_key
6
+ Sproutvideo.base_url = 'https://api.sproutvideo.com/v1'
7
+ @msg = mock(:to_s => "{}", :code => 200)
8
+ end
9
+
10
+ describe "#play_counts" do
11
+ before(:each) do
12
+ @url = "#{Sproutvideo.base_url}/stats/counts"
13
+ end
14
+
15
+ it "should GET the correct url for overall method call and return a response" do
16
+ RestClient.should_receive(:get).with(
17
+ @url,
18
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
19
+ Sproutvideo::Analytics.play_counts.class.should == Sproutvideo::Response
20
+ end
21
+ it "should GET the correct url for individual video method call and return a response" do
22
+ RestClient.should_receive(:get).with(
23
+ "#{@url}/abc123",
24
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
25
+ Sproutvideo::Analytics.play_counts(:video_id => 'abc123').class.should == Sproutvideo::Response
26
+ end
27
+ it "should GET the correct url if dates are passed in" do
28
+ RestClient.should_receive(:get).with(
29
+ @url,
30
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
31
+ Sproutvideo::Analytics.play_counts(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
32
+ end
33
+ end
34
+
35
+ describe "#domains" do
36
+ before(:each) do
37
+ @url = "#{Sproutvideo.base_url}/stats/domains"
38
+ end
39
+
40
+ it "should GET the correct url for overall method call and return a response" do
41
+ RestClient.should_receive(:get).with(
42
+ @url,
43
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
44
+ Sproutvideo::Analytics.domains.class.should == Sproutvideo::Response
45
+ end
46
+ it "should GET the correct url for individual video method call and return a response" do
47
+ RestClient.should_receive(:get).with(
48
+ "#{@url}/abc123",
49
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
50
+ Sproutvideo::Analytics.domains(:video_id => 'abc123').class.should == Sproutvideo::Response
51
+ end
52
+ it "should GET the correct url if dates are passed in" do
53
+ RestClient.should_receive(:get).with(
54
+ @url,
55
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
56
+ Sproutvideo::Analytics.domains(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
57
+ end
58
+ end
59
+
60
+ describe "#geo" do
61
+ before(:each) do
62
+ @url = "#{Sproutvideo.base_url}/stats/geo"
63
+ end
64
+
65
+ it "should GET the correct url for overall method call and return a response" do
66
+ RestClient.should_receive(:get).with(
67
+ @url,
68
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
69
+ Sproutvideo::Analytics.geo.class.should == Sproutvideo::Response
70
+ end
71
+ it "should GET the correct url for individual video method call and return a response" do
72
+ RestClient.should_receive(:get).with(
73
+ "#{@url}/abc123",
74
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
75
+ Sproutvideo::Analytics.geo(:video_id => 'abc123').class.should == Sproutvideo::Response
76
+ end
77
+ it "should GET the correct url if dates are passed in" do
78
+ RestClient.should_receive(:get).with(
79
+ @url,
80
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
81
+ Sproutvideo::Analytics.geo(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
82
+ end
83
+ it "should GET the correct url if a country is passed in" do
84
+ RestClient.should_receive(:get).with(
85
+ "#{@url}/abc123",
86
+ {'SproutVideo-Api-Key' => @api_key, :params => {:country => 'US', :start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
87
+ Sproutvideo::Analytics.geo(:video_id => 'abc123', :country => 'US', :start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
88
+ end
89
+ end
90
+
91
+ describe "#video_types" do
92
+ before(:each) do
93
+ @url = "#{Sproutvideo.base_url}/stats/video_types"
94
+ end
95
+
96
+ it "should GET the correct url for overall method call and return a response" do
97
+ RestClient.should_receive(:get).with(
98
+ @url,
99
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
100
+ Sproutvideo::Analytics.video_types.class.should == Sproutvideo::Response
101
+ end
102
+ it "should GET the correct url for individual video method call and return a response" do
103
+ RestClient.should_receive(:get).with(
104
+ "#{@url}/abc123",
105
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
106
+ Sproutvideo::Analytics.video_types(:video_id => 'abc123').class.should == Sproutvideo::Response
107
+ end
108
+ it "should GET the correct url if dates are passed in" do
109
+ RestClient.should_receive(:get).with(
110
+ @url,
111
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
112
+ Sproutvideo::Analytics.video_types(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
113
+ end
114
+ end
115
+
116
+ describe "#playback_types" do
117
+ before(:each) do
118
+ @url = "#{Sproutvideo.base_url}/stats/playback_types"
119
+ end
120
+
121
+ it "should GET the correct url for overall method call and return a response" do
122
+ RestClient.should_receive(:get).with(
123
+ @url,
124
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
125
+ Sproutvideo::Analytics.playback_types.class.should == Sproutvideo::Response
126
+ end
127
+ it "should GET the correct url for individual video method call and return a response" do
128
+ RestClient.should_receive(:get).with(
129
+ "#{@url}/abc123",
130
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
131
+ Sproutvideo::Analytics.playback_types(:video_id => 'abc123').class.should == Sproutvideo::Response
132
+ end
133
+ it "should GET the correct url if dates are passed in" do
134
+ RestClient.should_receive(:get).with(
135
+ @url,
136
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
137
+ Sproutvideo::Analytics.playback_types(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
138
+ end
139
+ end
140
+
141
+ describe "#device_types" do
142
+ before(:each) do
143
+ @url = "#{Sproutvideo.base_url}/stats/device_types"
144
+ end
145
+
146
+ it "should GET the correct url for overall method call and return a response" do
147
+ RestClient.should_receive(:get).with(
148
+ @url,
149
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
150
+ Sproutvideo::Analytics.device_types.class.should == Sproutvideo::Response
151
+ end
152
+ it "should GET the correct url for individual video method call and return a response" do
153
+ RestClient.should_receive(:get).with(
154
+ "#{@url}/abc123",
155
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
156
+ Sproutvideo::Analytics.device_types(:video_id => 'abc123').class.should == Sproutvideo::Response
157
+ end
158
+ it "should GET the correct url if dates are passed in" do
159
+ RestClient.should_receive(:get).with(
160
+ @url,
161
+ {'SproutVideo-Api-Key' => @api_key, :params => {:start_date => '2012-12-31', :end_date => '2013-12-31'}}).and_return(@msg)
162
+ Sproutvideo::Analytics.device_types(:start_date => '2012-12-31', :end_date => '2013-12-31').class.should == Sproutvideo::Response
163
+ end
164
+ end
165
+
166
+ describe "#engagement" do
167
+ before(:each) do
168
+ @url = "#{Sproutvideo.base_url}/stats/engagement"
169
+ end
170
+
171
+ it "should GET the correct url for overall method call and return a response" do
172
+ RestClient.should_receive(:get).with(
173
+ @url,
174
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
175
+ Sproutvideo::Analytics.engagement.class.should == Sproutvideo::Response
176
+ end
177
+ it "should GET the correct url for individual video method call and return a response" do
178
+ RestClient.should_receive(:get).with(
179
+ "#{@url}/abc123",
180
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
181
+ Sproutvideo::Analytics.engagement(:video_id => 'abc123').class.should == Sproutvideo::Response
182
+ end
183
+ end
184
+
185
+ describe "#engagement_sessions" do
186
+ before(:each) do
187
+ @url = "#{Sproutvideo.base_url}/stats/engagement/abc123/sessions"
188
+ end
189
+ it "should GET the correct url for overall method call and return a response" do
190
+ RestClient.should_receive(:get).with(
191
+ @url,
192
+ {'SproutVideo-Api-Key' => @api_key, :params => {}}).and_return(@msg)
193
+ Sproutvideo::Analytics.engagement_sessions('abc123').class.should == Sproutvideo::Response
194
+ end
195
+
196
+ it "should use pagination params" do
197
+ RestClient.should_receive(:get).with(
198
+ @url,
199
+ {'SproutVideo-Api-Key' => @api_key, :params => {:page => 2, :per_page => 5}}).and_return(@msg)
200
+ Sproutvideo::Analytics.engagement_sessions('abc123', :page => 2, :per_page => 5)
201
+ end
202
+ end
203
+
204
+
205
+ end
@@ -4,14 +4,14 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{sproutvideo-rb}
8
- s.version = "1.2.0"
7
+ s.name = "sproutvideo-rb"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["SproutVideo"]
12
- s.date = %q{2013-01-08}
13
- s.description = %q{SproutVideo API Client}
14
- s.email = %q{support@sproutvideo.com}
12
+ s.date = "2013-01-24"
13
+ s.description = "SproutVideo API Client"
14
+ s.email = "support@sproutvideo.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
17
  "README.markdown"
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "Rakefile",
25
25
  "lib/sproutvideo.rb",
26
26
  "lib/sproutvideo/access_grant.rb",
27
+ "lib/sproutvideo/analytics.rb",
27
28
  "lib/sproutvideo/login.rb",
28
29
  "lib/sproutvideo/playlist.rb",
29
30
  "lib/sproutvideo/resource.rb",
@@ -34,6 +35,7 @@ Gem::Specification.new do |s|
34
35
  "lib/sproutvideo/video.rb",
35
36
  "spec/spec_helper.rb",
36
37
  "spec/sproutvideo/access_grant_spec.rb",
38
+ "spec/sproutvideo/analytics_spec.rb",
37
39
  "spec/sproutvideo/login_spec.rb",
38
40
  "spec/sproutvideo/playlist_spec.rb",
39
41
  "spec/sproutvideo/resource_spec.rb",
@@ -44,17 +46,16 @@ Gem::Specification.new do |s|
44
46
  "spec/sproutvideo_spec.rb",
45
47
  "sproutvideo-rb.gemspec"
46
48
  ]
47
- s.homepage = %q{http://github.com/sproutvideo/sproutvideo-rb}
49
+ s.homepage = "http://github.com/sproutvideo/sproutvideo-rb"
48
50
  s.licenses = ["MIT"]
49
51
  s.require_paths = ["lib"]
50
- s.rubygems_version = %q{1.3.6}
51
- s.summary = %q{SproutVideo API Client}
52
+ s.rubygems_version = "1.8.24"
53
+ s.summary = "SproutVideo API Client"
52
54
 
53
55
  if s.respond_to? :specification_version then
54
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
55
56
  s.specification_version = 3
56
57
 
57
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
58
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
59
  s.add_runtime_dependency(%q<rest-client>, [">= 0"])
59
60
  s.add_runtime_dependency(%q<multi_json>, [">= 0"])
60
61
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sproutvideo-rb
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 29
5
+ prerelease:
5
6
  segments:
6
7
  - 1
7
8
  - 2
8
- - 0
9
- version: 1.2.0
9
+ - 1
10
+ version: 1.2.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - SproutVideo
@@ -14,99 +15,112 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2013-01-08 00:00:00 -05:00
18
- default_executable:
18
+ date: 2013-01-24 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
- name: rest-client
22
- prerelease: false
23
21
  requirement: &id001 !ruby/object:Gem::Requirement
22
+ none: false
24
23
  requirements:
25
24
  - - ">="
26
25
  - !ruby/object:Gem::Version
26
+ hash: 3
27
27
  segments:
28
28
  - 0
29
29
  version: "0"
30
+ prerelease: false
30
31
  type: :runtime
32
+ name: rest-client
31
33
  version_requirements: *id001
32
34
  - !ruby/object:Gem::Dependency
33
- name: multi_json
34
- prerelease: false
35
35
  requirement: &id002 !ruby/object:Gem::Requirement
36
+ none: false
36
37
  requirements:
37
38
  - - ">="
38
39
  - !ruby/object:Gem::Version
40
+ hash: 3
39
41
  segments:
40
42
  - 0
41
43
  version: "0"
44
+ prerelease: false
42
45
  type: :runtime
46
+ name: multi_json
43
47
  version_requirements: *id002
44
48
  - !ruby/object:Gem::Dependency
45
- name: rspec
46
- prerelease: false
47
49
  requirement: &id003 !ruby/object:Gem::Requirement
50
+ none: false
48
51
  requirements:
49
52
  - - ~>
50
53
  - !ruby/object:Gem::Version
54
+ hash: 47
51
55
  segments:
52
56
  - 2
53
57
  - 8
54
58
  - 0
55
59
  version: 2.8.0
60
+ prerelease: false
56
61
  type: :development
62
+ name: rspec
57
63
  version_requirements: *id003
58
64
  - !ruby/object:Gem::Dependency
59
- name: rdoc
60
- prerelease: false
61
65
  requirement: &id004 !ruby/object:Gem::Requirement
66
+ none: false
62
67
  requirements:
63
68
  - - ~>
64
69
  - !ruby/object:Gem::Version
70
+ hash: 31
65
71
  segments:
66
72
  - 3
67
73
  - 12
68
74
  version: "3.12"
75
+ prerelease: false
69
76
  type: :development
77
+ name: rdoc
70
78
  version_requirements: *id004
71
79
  - !ruby/object:Gem::Dependency
72
- name: bundler
73
- prerelease: false
74
80
  requirement: &id005 !ruby/object:Gem::Requirement
81
+ none: false
75
82
  requirements:
76
83
  - - ~>
77
84
  - !ruby/object:Gem::Version
85
+ hash: 23
78
86
  segments:
79
87
  - 1
80
88
  - 0
81
89
  - 0
82
90
  version: 1.0.0
91
+ prerelease: false
83
92
  type: :development
93
+ name: bundler
84
94
  version_requirements: *id005
85
95
  - !ruby/object:Gem::Dependency
86
- name: jeweler
87
- prerelease: false
88
96
  requirement: &id006 !ruby/object:Gem::Requirement
97
+ none: false
89
98
  requirements:
90
99
  - - ~>
91
100
  - !ruby/object:Gem::Version
101
+ hash: 49
92
102
  segments:
93
103
  - 1
94
104
  - 8
95
105
  - 3
96
106
  version: 1.8.3
107
+ prerelease: false
97
108
  type: :development
109
+ name: jeweler
98
110
  version_requirements: *id006
99
111
  - !ruby/object:Gem::Dependency
100
- name: rcov
101
- prerelease: false
102
112
  requirement: &id007 !ruby/object:Gem::Requirement
113
+ none: false
103
114
  requirements:
104
115
  - - ">="
105
116
  - !ruby/object:Gem::Version
117
+ hash: 3
106
118
  segments:
107
119
  - 0
108
120
  version: "0"
121
+ prerelease: false
109
122
  type: :development
123
+ name: rcov
110
124
  version_requirements: *id007
111
125
  description: SproutVideo API Client
112
126
  email: support@sproutvideo.com
@@ -125,6 +139,7 @@ files:
125
139
  - Rakefile
126
140
  - lib/sproutvideo.rb
127
141
  - lib/sproutvideo/access_grant.rb
142
+ - lib/sproutvideo/analytics.rb
128
143
  - lib/sproutvideo/login.rb
129
144
  - lib/sproutvideo/playlist.rb
130
145
  - lib/sproutvideo/resource.rb
@@ -135,6 +150,7 @@ files:
135
150
  - lib/sproutvideo/video.rb
136
151
  - spec/spec_helper.rb
137
152
  - spec/sproutvideo/access_grant_spec.rb
153
+ - spec/sproutvideo/analytics_spec.rb
138
154
  - spec/sproutvideo/login_spec.rb
139
155
  - spec/sproutvideo/playlist_spec.rb
140
156
  - spec/sproutvideo/resource_spec.rb
@@ -144,7 +160,6 @@ files:
144
160
  - spec/sproutvideo/video_spec.rb
145
161
  - spec/sproutvideo_spec.rb
146
162
  - sproutvideo-rb.gemspec
147
- has_rdoc: true
148
163
  homepage: http://github.com/sproutvideo/sproutvideo-rb
149
164
  licenses:
150
165
  - MIT
@@ -154,23 +169,27 @@ rdoc_options: []
154
169
  require_paths:
155
170
  - lib
156
171
  required_ruby_version: !ruby/object:Gem::Requirement
172
+ none: false
157
173
  requirements:
158
174
  - - ">="
159
175
  - !ruby/object:Gem::Version
176
+ hash: 3
160
177
  segments:
161
178
  - 0
162
179
  version: "0"
163
180
  required_rubygems_version: !ruby/object:Gem::Requirement
181
+ none: false
164
182
  requirements:
165
183
  - - ">="
166
184
  - !ruby/object:Gem::Version
185
+ hash: 3
167
186
  segments:
168
187
  - 0
169
188
  version: "0"
170
189
  requirements: []
171
190
 
172
191
  rubyforge_project:
173
- rubygems_version: 1.3.6
192
+ rubygems_version: 1.8.24
174
193
  signing_key:
175
194
  specification_version: 3
176
195
  summary: SproutVideo API Client