opentok 4.3.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +11 -0
  3. data/README.md +60 -38
  4. data/lib/opentok/archive.rb +5 -2
  5. data/lib/opentok/archives.rb +15 -8
  6. data/lib/opentok/broadcast.rb +6 -2
  7. data/lib/opentok/broadcasts.rb +50 -9
  8. data/lib/opentok/client.rb +90 -0
  9. data/lib/opentok/exceptions.rb +3 -1
  10. data/lib/opentok/opentok.rb +10 -5
  11. data/lib/opentok/render.rb +78 -0
  12. data/lib/opentok/render_list.rb +14 -0
  13. data/lib/opentok/renders.rb +101 -0
  14. data/lib/opentok/session.rb +4 -4
  15. data/lib/opentok/streams.rb +8 -10
  16. data/lib/opentok/version.rb +1 -1
  17. data/spec/cassettes/OpenTok_Archives/should_create_an_archive_with_matching_multi_archive_tag_when_multiArchiveTag_is_specified.yml +50 -0
  18. data/spec/cassettes/OpenTok_Archives/should_create_an_archive_with_multi_archive_tag_value_of_nil_when_multiArchiveTag_not_specified.yml +49 -0
  19. data/spec/cassettes/OpenTok_Archives/should_create_an_archives_with_a_specified_multiArchiveTag.yml +52 -0
  20. data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_matching_multi_broadcast_tag_value_when_multiBroadcastTag_is_specified.yml +54 -0
  21. data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_multi_broadcast_tag_value_of_nil_when_multiBroadcastTag_not_specified.yml +53 -0
  22. data/spec/cassettes/OpenTok_Broadcasts/starts_a_broadcast_with_a_specified_multiBroadcastTag.yml +54 -0
  23. data/spec/cassettes/OpenTok_Renders/finds_an_Experience_Composer_render.yml +46 -0
  24. data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_all_renders.yml +108 -0
  25. data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_count_number_of_renders.yml +63 -0
  26. data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_part_of_the_renders_when_using_offset_and_count.yml +63 -0
  27. data/spec/cassettes/OpenTok_Renders/for_many_renders/should_return_renders_with_an_offset.yml +74 -0
  28. data/spec/cassettes/OpenTok_Renders/starts_an_Experience_Composer_render.yml +48 -0
  29. data/spec/cassettes/OpenTok_Renders/stops_an_Experience_Composer_render.yml +28 -0
  30. data/spec/opentok/archives_spec.rb +21 -0
  31. data/spec/opentok/broadcasts_spec.rb +54 -0
  32. data/spec/opentok/renders_spec.rb +142 -0
  33. metadata +34 -3
@@ -0,0 +1,108 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/render
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 15 Sep 2022 11:09:53 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ {
35
+ "count":6,
36
+ "items":[
37
+ {
38
+ "id":"80abaf0d-25a3-4efc-968f-6268d620668d",
39
+ "sessionId":"1_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
40
+ "projectId":"27086612",
41
+ "createdAt":1547080532099,
42
+ "updatedAt":1547080532099,
43
+ "url": "https://example.com/my-render",
44
+ "resolution": "1280x720",
45
+ "status": "started",
46
+ "streamId": "d2334b35690a92f78945"
47
+ },
48
+ {
49
+ "id":"d95f6496-df6e-4f49-86d6-832e00303602",
50
+ "sessionId":"2_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
51
+ "projectId":"27086612",
52
+ "createdAt":1547080511760,
53
+ "updatedAt":1547080518965,
54
+ "url": "https://example.com/my-render",
55
+ "resolution": "1280x720",
56
+ "status":"stopped",
57
+ "streamId": "d2334b35690a92f78945",
58
+ "reason":"Max duration exceeded"
59
+ },
60
+ {
61
+ "id":"96abaf0d-25a3-4efc-968f-6268d620668d",
62
+ "sessionId":"3_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
63
+ "projectId":"27086612",
64
+ "createdAt":1547080532099,
65
+ "updatedAt":1547080532099,
66
+ "url": "https://example.com/my-render",
67
+ "resolution": "1280x720",
68
+ "status": "started",
69
+ "streamId": "d2334b35690a92f78946"
70
+ },
71
+ {
72
+ "id":"c34f6496-df6e-4f49-86d6-832e00303602",
73
+ "sessionId":"4_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
74
+ "projectId":"27086612",
75
+ "createdAt":1547080511760,
76
+ "updatedAt":1547080518965,
77
+ "url": "https://example.com/my-render",
78
+ "resolution": "1280x720",
79
+ "status":"stopped",
80
+ "streamId": "d2334b35690a92f78912",
81
+ "reason":"Stop Requested"
82
+ },
83
+ {
84
+ "id":"52abaf0d-25a3-4efc-968f-6268d620668d",
85
+ "sessionId":"1_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
86
+ "projectId":"27086612",
87
+ "createdAt":1547080532099,
88
+ "updatedAt":1547080532099,
89
+ "url": "https://example.com/my-render",
90
+ "resolution": "1280x720",
91
+ "status": "started",
92
+ "streamId": "d2334b35690a92f78948"
93
+ },
94
+ {
95
+ "id":"a87f6496-df6e-4f49-86d6-832e00303602",
96
+ "sessionId":"2_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
97
+ "projectId":"27086612",
98
+ "createdAt":1547080511760,
99
+ "updatedAt":1547080518965,
100
+ "url": "https://example.com/my-render",
101
+ "resolution": "1280x720",
102
+ "status":"starting",
103
+ "streamId": "d2334b35690a92f78947"
104
+ }
105
+ ]
106
+ }
107
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
108
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/render?count=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 15 Sep 2022 11:32:24 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ {
35
+ "count":2,
36
+ "items":[
37
+ {
38
+ "id":"80abaf0d-25a3-4efc-968f-6268d620668d",
39
+ "sessionId":"1_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
40
+ "projectId":"27086612",
41
+ "createdAt":1547080532099,
42
+ "updatedAt":1547080532099,
43
+ "url": "https://example.com/my-render",
44
+ "resolution": "1280x720",
45
+ "status": "started",
46
+ "streamId": "d2334b35690a92f78945"
47
+ },
48
+ {
49
+ "id":"d95f6496-df6e-4f49-86d6-832e00303602",
50
+ "sessionId":"2_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
51
+ "projectId":"27086612",
52
+ "createdAt":1547080511760,
53
+ "updatedAt":1547080518965,
54
+ "url": "https://example.com/my-render",
55
+ "resolution": "1280x720",
56
+ "status":"stopped",
57
+ "streamId": "d2334b35690a92f78945",
58
+ "reason":"Max duration exceeded"
59
+ }
60
+ ]
61
+ }
62
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
63
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/render?count=2&offset=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 15 Sep 2022 11:34:05 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ {
35
+ "count":2,
36
+ "items":[
37
+ {
38
+ "id":"96abaf0d-25a3-4efc-968f-6268d620668d",
39
+ "sessionId":"3_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
40
+ "projectId":"27086612",
41
+ "createdAt":1547080532099,
42
+ "updatedAt":1547080532099,
43
+ "url": "https://example.com/my-render",
44
+ "resolution": "1280x720",
45
+ "status": "started",
46
+ "streamId": "d2334b35690a92f78946"
47
+ },
48
+ {
49
+ "id":"c34f6496-df6e-4f49-86d6-832e00303602",
50
+ "sessionId":"4_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
51
+ "projectId":"27086612",
52
+ "createdAt":1547080511760,
53
+ "updatedAt":1547080518965,
54
+ "url": "https://example.com/my-render",
55
+ "resolution": "1280x720",
56
+ "status":"stopped",
57
+ "streamId": "d2334b35690a92f78912",
58
+ "reason":"Stop Requested"
59
+ }
60
+ ]
61
+ }
62
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
63
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,74 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.opentok.com/v2/project/123456/render?offset=3
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - nginx
25
+ Date:
26
+ - Thu, 15 Sep 2022 11:29:00 GMT
27
+ Content-Type:
28
+ - application/json
29
+ Connection:
30
+ - keep-alive
31
+ body:
32
+ encoding: UTF-8
33
+ string: |-
34
+ {
35
+ "count":3,
36
+ "items":[
37
+ {
38
+ "id":"c34f6496-df6e-4f49-86d6-832e00303602",
39
+ "sessionId":"4_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
40
+ "projectId":"27086612",
41
+ "createdAt":1547080511760,
42
+ "updatedAt":1547080518965,
43
+ "url": "https://example.com/my-render",
44
+ "resolution": "1280x720",
45
+ "status":"stopped",
46
+ "streamId": "d2334b35690a92f78912",
47
+ "reason":"Stop Requested"
48
+ },
49
+ {
50
+ "id":"52abaf0d-25a3-4efc-968f-6268d620668d",
51
+ "sessionId":"1_MX4yNzA4NjYxMn5-MTU0NzA4MDUyMTEzNn5sOXU5ZnlWYXplRnZGblV4RUo3dXJpZk1-fg",
52
+ "projectId":"27086612",
53
+ "createdAt":1547080532099,
54
+ "updatedAt":1547080532099,
55
+ "url": "https://example.com/my-render",
56
+ "resolution": "1280x720",
57
+ "status": "started",
58
+ "streamId": "d2334b35690a92f78948"
59
+ },
60
+ {
61
+ "id":"a87f6496-df6e-4f49-86d6-832e00303602",
62
+ "sessionId":"2_MX4yNzA4NjYxMn5-MTU0NzA4MDUwMDc2MH5STWRiSE1jZjVoV3lBQU9nN2JuNElUV3V-fg",
63
+ "projectId":"27086612",
64
+ "createdAt":1547080511760,
65
+ "updatedAt":1547080518965,
66
+ "url": "https://example.com/my-render",
67
+ "resolution": "1280x720",
68
+ "status":"starting",
69
+ "streamId": "d2334b35690a92f78947"
70
+ }
71
+ ]
72
+ }
73
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
74
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,48 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.opentok.com/v2/project/123456/render
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"sessionId":"SESSIONID","token":"TOKEN","url":"https://example.com/my-render"}'
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 202
23
+ message: Accepted
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Thu, 15 Sep 2022 10:25:36 GMT
29
+ Content-Type:
30
+ - application/json
31
+ Connection:
32
+ - keep-alive
33
+ body:
34
+ encoding: UTF-8
35
+ string: |-
36
+ {
37
+ "id": "80abaf0d-25a3-4efc-968f-6268d620668d",
38
+ "sessionId": "SESSIONID",
39
+ "projectId": "e2343f23456g34709d2443a234",
40
+ "createdAt": 1437676551000,
41
+ "updatedAt": 1437676551000,
42
+ "url": "https://example.com/my-render",
43
+ "resolution": "1280x720",
44
+ "status": "starting",
45
+ "streamId": "e32445b743678c98230f238"
46
+ }
47
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
48
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,28 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://api.opentok.com/v2/project/123456/render/80abaf0d-25a3-4efc-968f-6268d620668d
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - OpenTok-Ruby-SDK/<%= version %>
12
+ X-Opentok-Auth:
13
+ - eyJpc3QiOiJwcm9qZWN0IiwiYWxnIjoiSFMyNTYifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.BplMVhJWx4ld7KLKXqEmow6MjNPPFw9W8IHCMfeb120
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: No Content
22
+ headers:
23
+ Date:
24
+ - Thu, 15 Sep 2022 10:51:54 GMT
25
+ Connection:
26
+ - keep-alive
27
+ recorded_at: Tue, 18 Apr 2017 10:17:40 GMT
28
+ recorded_with: VCR 6.0.0
@@ -42,6 +42,27 @@ describe OpenTok::Archives do
42
42
  expect(archive.name).to eq archive_name
43
43
  end
44
44
 
45
+ it "should create an archives with a specified multiArchiveTag", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
46
+ archive_tag = 'archive-1'
47
+ archive = archives.create session_id, :multiArchiveTag => archive_tag
48
+ expect(archive).to be_an_instance_of OpenTok::Archive
49
+ expect(archive.session_id).to eq session_id
50
+ expect(archive.multiArchiveTag).to eq archive_tag
51
+ end
52
+
53
+ it "should create an archive with matching multi_archive_tag when multiArchiveTag is specified", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
54
+ archive_tag = 'archive-1'
55
+ archive = archives.create session_id, :multiArchiveTag => archive_tag
56
+ expect(archive).to be_an_instance_of OpenTok::Archive
57
+ expect(archive.multi_archive_tag).to eq archive_tag
58
+ end
59
+
60
+ it "should create an archive with multi_archive_tag value of nil when multiArchiveTag not specified", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
61
+ archive = archives.create session_id
62
+ expect(archive).to be_an_instance_of OpenTok::Archive
63
+ expect(archive.multi_archive_tag).to be_nil
64
+ end
65
+
45
66
  it "should create audio only archives", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" } } do
46
67
  archive = archives.create session_id, :has_video => false
47
68
  expect(archive).to be_an_instance_of OpenTok::Archive
@@ -45,6 +45,22 @@ describe OpenTok::Broadcasts do
45
45
  broadcast.create(nil, {})
46
46
  }.to raise_error(ArgumentError)
47
47
  end
48
+ it 'raises an error if outputs is not set in options' do
49
+ opts = { maxDuration: 5400 }
50
+ expect { broadcast.create(nil, opts) }.to raise_error(ArgumentError)
51
+ end
52
+ it 'raises an error if outputs is set in options but is not a Hash' do
53
+ opts = { outputs: [] }
54
+ expect { broadcast.create(nil, opts) }.to raise_error(ArgumentError)
55
+ end
56
+ it 'raises an error if an HLS Broadcast object has both dvr and low_latency options set to true' do
57
+ opts = {
58
+ outputs: {
59
+ hls: { dvr: true, low_latency: true}
60
+ }
61
+ }
62
+ expect { broadcast.create(nil, opts) }.to raise_error(ArgumentError)
63
+ end
48
64
  it 'fetches a hls broadcast url', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
49
65
  opts = {
50
66
  :outputs => {
@@ -77,6 +93,44 @@ describe OpenTok::Broadcasts do
77
93
  expect(b_rtmp.broadcastUrls["rtmp"].count).to eq 1
78
94
  end
79
95
 
96
+ it 'starts a broadcast with a specified multiBroadcastTag', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
97
+ broadcast_tag = 'broadcast-1'
98
+ opts = {
99
+ :outputs => {
100
+ :hls => {}
101
+ },
102
+ :multiBroadcastTag => broadcast_tag
103
+ }
104
+ broadcast_1 = broadcast.create(session_id, opts)
105
+ expect(broadcast_1).to be_an_instance_of OpenTok::Broadcast
106
+ expect(broadcast_1.id).to eq broadcast_id
107
+ expect(broadcast_1.multiBroadcastTag).to eq broadcast_tag
108
+ end
109
+
110
+ it 'starts a broadcast with a matching multi_broadcast_tag value when multiBroadcastTag is specified', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
111
+ broadcast_tag = 'broadcast-1'
112
+ opts = {
113
+ :outputs => {
114
+ :hls => {}
115
+ },
116
+ :multiBroadcastTag => broadcast_tag
117
+ }
118
+ broadcast_1 = broadcast.create(session_id, opts)
119
+ expect(broadcast_1).to be_an_instance_of OpenTok::Broadcast
120
+ expect(broadcast_1.multi_broadcast_tag).to eq broadcast_tag
121
+ end
122
+
123
+ it 'starts a broadcast with a multi_broadcast_tag value of nil when multiBroadcastTag not specified', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
124
+ opts = {
125
+ :outputs => {
126
+ :hls => {}
127
+ }
128
+ }
129
+ broadcast_1 = broadcast.create(session_id, opts)
130
+ expect(broadcast_1).to be_an_instance_of OpenTok::Broadcast
131
+ expect(broadcast_1.multi_broadcast_tag).to be_nil
132
+ end
133
+
80
134
  it 'finds a broadcast', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
81
135
  b = broadcast.find started_broadcast_id
82
136
  expect(b).to be_an_instance_of OpenTok::Broadcast
@@ -0,0 +1,142 @@
1
+ require "opentok/render"
2
+ require "opentok/renders"
3
+ require "opentok/opentok"
4
+ require "opentok/version"
5
+ require "spec_helper"
6
+
7
+ describe OpenTok::Renders do
8
+ before(:each) do
9
+ now = Time.parse("2017-04-18 20:17:40 +1000")
10
+ allow(Time).to receive(:now) { now }
11
+ end
12
+
13
+ let(:api_key) { "123456" }
14
+ let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
15
+ let(:session_id) { "SESSIONID" }
16
+ let(:render_id) { "80abaf0d-25a3-4efc-968f-6268d620668d" }
17
+ let(:opentok) { OpenTok::OpenTok.new api_key, api_secret }
18
+ let(:token) { "TOKEN" }
19
+ let(:render) { opentok.renders }
20
+ let(:render_url) { 'https://example.com/my-render'}
21
+
22
+ subject { render }
23
+
24
+ it 'raises an error on empty sessionId' do
25
+ opts = {
26
+ :token => token,
27
+ :url => render_url
28
+ }
29
+ expect {
30
+ render.start('', opts)
31
+ }.to raise_error(ArgumentError)
32
+ end
33
+
34
+ it 'raises an error on nil sessionId' do
35
+ opts = {
36
+ :token => token,
37
+ :url => render_url
38
+ }
39
+ expect {
40
+ render.start(nil, opts)
41
+ }.to raise_error(ArgumentError)
42
+ end
43
+
44
+ it 'raises an error on empty options' do
45
+ expect {
46
+ render.start(session_id, {})
47
+ }.to raise_error(ArgumentError)
48
+ end
49
+
50
+ it 'raises an error if token is not set in options' do
51
+ opts = { :url => render_url }
52
+ expect { render.start(session_id, opts) }.to raise_error(ArgumentError)
53
+ end
54
+
55
+ it 'raises an error if url is not set in options' do
56
+ opts = { :token => token }
57
+ expect { render.start(session_id, opts) }.to raise_error(ArgumentError)
58
+ end
59
+
60
+ it 'starts an Experience Composer render', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
61
+ opts = {
62
+ :token => token,
63
+ :url => render_url
64
+ }
65
+ r = render.start(session_id, opts)
66
+ expect(r).to be_an_instance_of OpenTok::Render
67
+ expect(r.sessionId).to eq session_id
68
+ expect(r.url).to eq render_url
69
+ expect(r.status).to eq "starting"
70
+ end
71
+
72
+ it 'raises an error on empty renderId in find' do
73
+ expect {
74
+ render.find("")
75
+ }.to raise_error(ArgumentError)
76
+ end
77
+
78
+ it 'raises an error on nil renderId in find' do
79
+ expect {
80
+ render.find(nil)
81
+ }.to raise_error(ArgumentError)
82
+ end
83
+
84
+ it 'finds an Experience Composer render', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
85
+ r = render.find render_id
86
+ expect(r).to be_an_instance_of OpenTok::Render
87
+ expect(r.id).to eq render_id
88
+ end
89
+
90
+ it 'raises an error on empty renderId in stop' do
91
+ expect {
92
+ render.stop("")
93
+ }.to raise_error(ArgumentError)
94
+ end
95
+
96
+ it 'raises an error on nil renderId in stop' do
97
+ expect {
98
+ render.stop(nil)
99
+ }.to raise_error(ArgumentError)
100
+ end
101
+
102
+ it 'stops an Experience Composer render', :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
103
+ r = render.stop(render_id)
104
+ expect(r).to be_an_instance_of OpenTok::Render
105
+ end
106
+
107
+ context "for many renders" do
108
+ it 'raises an error for an invalid limit in list' do
109
+ expect {
110
+ render.list(count: 1001)
111
+ }.to raise_error(ArgumentError)
112
+ end
113
+
114
+ it "should return all renders", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
115
+ render_list = render.list
116
+ expect(render_list).to be_an_instance_of OpenTok::RenderList
117
+ expect(render_list.count).to eq 6
118
+ expect(render_list.total).to eq 6
119
+ end
120
+
121
+ it "should return renders with an offset", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
122
+ render_list = render.list :offset => 3
123
+ expect(render_list).to be_an_instance_of OpenTok::RenderList
124
+ expect(render_list.count).to eq 3
125
+ expect(render_list.total).to eq 3
126
+ end
127
+
128
+ it "should return count number of renders", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
129
+ render_list = render.list :count => 2
130
+ expect(render_list).to be_an_instance_of OpenTok::RenderList
131
+ expect(render_list.count).to eq 2
132
+ expect(render_list.total).to eq 2
133
+ end
134
+
135
+ it "should return part of the renders when using offset and count", :vcr => { :erb => { :version => OpenTok::VERSION + "-Ruby-Version-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"} } do
136
+ render_list = render.list :count => 2, :offset => 2
137
+ expect(render_list).to be_an_instance_of OpenTok::RenderList
138
+ expect(render_list.count).to eq 2
139
+ expect(render_list.total).to eq 2
140
+ end
141
+ end
142
+ end