opentok 2.4.1 → 2.5.0
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 +4 -4
- data/.travis.yml +5 -5
- data/README.md +19 -1
- data/lib/opentok/client.rb +25 -0
- data/lib/opentok/exceptions.rb +2 -0
- data/lib/opentok/opentok.rb +5 -0
- data/lib/opentok/sip.rb +13 -0
- data/lib/opentok/version.rb +1 -1
- data/spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml +38 -0
- data/spec/opentok/sip_spec.rb +30 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1052af9a1320e87a85a196abc070ae11e2787b46
|
4
|
+
data.tar.gz: e9cc897d05cd2a4ec6bbba1f6051977c4038ed2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be8e2df42f9d64cd0541b9c0a631743ed03bcafe58a096deb2e47d2897d9b999a9e7062e1ca1f1a3f23294b9431e781cbe28653b6f25c945117638ff7874a31d
|
7
|
+
data.tar.gz: d64e401d965f0ca415ed34704abe17fbed51c82240da918ca2d5660adad8dc4911731a84e334f5f3d00dd1671f1134bd4be0e50df45bc4ca70ff5ca1acd32a68
|
data/.travis.yml
CHANGED
@@ -6,11 +6,11 @@ cache: bundler
|
|
6
6
|
before_install: gem update bundler
|
7
7
|
rvm:
|
8
8
|
- 1.9.3
|
9
|
-
- 2.0
|
10
|
-
- 2.1
|
11
|
-
- 2.2
|
12
|
-
- 2.3
|
13
|
-
- 2.4
|
9
|
+
- 2.0
|
10
|
+
- 2.1
|
11
|
+
- 2.2
|
12
|
+
- 2.3
|
13
|
+
- 2.4
|
14
14
|
notifications:
|
15
15
|
slack:
|
16
16
|
secure: agVll2R9PTPvJMcUgbvOh9eGt60zGDc8kPUwEsiQr828rCgXh/ZxD5irYDyKQg3ZsS8+f3MjFCwzU7uQALkia2pDrie9d8g8m1dt4Q5U7Qm6QecshvE0U9JwbB5Ngxaftbqyf0XEFrE7CKs7RI1BzFRpe8m+fdZgfwccX8Gb7pc=
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Bundler helps manage dependencies for Ruby projects. Find more info here: <http:
|
|
17
17
|
Add this gem to your `Gemfile`:
|
18
18
|
|
19
19
|
```ruby
|
20
|
-
gem "opentok", "~> 2.
|
20
|
+
gem "opentok", "~> 2.5.0"
|
21
21
|
```
|
22
22
|
|
23
23
|
Allow bundler to install the change.
|
@@ -178,6 +178,24 @@ as the `:archive_mode` property of the `options` parameter passed into the
|
|
178
178
|
For more information on archiving, see the
|
179
179
|
[OpenTok archiving](https://tokbox.com/opentok/tutorials/archiving/) programming guide.
|
180
180
|
|
181
|
+
|
182
|
+
## Initiating a SIP call
|
183
|
+
|
184
|
+
You can initiate a SIP call using the `opentok.sip.dial(session_id, token, sip_uri, opts)` method. This requires a SIP url. You will often need to pass options for authenticating to the SIP provider and specifying encrypted session establishment.
|
185
|
+
|
186
|
+
|
187
|
+
```ruby
|
188
|
+
opts = { "auth" => { "username" => sip_username,
|
189
|
+
"password" => sip_password },
|
190
|
+
"secure" => "true"
|
191
|
+
}
|
192
|
+
response = opentok.sip.dial(session_id, token, "sip:+15128675309@acme.pstn.example.com;transport=tls", opts)
|
193
|
+
```
|
194
|
+
|
195
|
+
For more information on SIP Interconnect, see the
|
196
|
+
[OpenTok SIP Interconnect](https://tokbox.com/developer/guides/sip/) programming guide.
|
197
|
+
|
198
|
+
|
181
199
|
# Samples
|
182
200
|
|
183
201
|
There are two sample applications included in this repository. To get going as fast as possible, clone the whole
|
data/lib/opentok/client.rb
CHANGED
@@ -162,5 +162,30 @@ module OpenTok
|
|
162
162
|
rescue StandardError => e
|
163
163
|
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
164
164
|
end
|
165
|
+
|
166
|
+
def dial(session_id, token, sip_uri, opts)
|
167
|
+
opts.extend(HashExtensions)
|
168
|
+
body = { "sessionId" => session_id,
|
169
|
+
"token" => token,
|
170
|
+
"sip" => { "uri" => sip_uri }.merge(opts.camelize_keys!)
|
171
|
+
}
|
172
|
+
|
173
|
+
response = self.class.post("/v2/project/#{@api_key}/dial", {
|
174
|
+
:body => body.to_json,
|
175
|
+
:headers => generate_headers("Content-Type" => "application/json")
|
176
|
+
})
|
177
|
+
case response.code
|
178
|
+
when 200
|
179
|
+
response
|
180
|
+
when 403
|
181
|
+
raise OpenTokAuthenticationError, "Authentication failed while dialing a sip session. API Key: #{@api_key}"
|
182
|
+
when 404
|
183
|
+
raise OpenTokSipError, "The sip session could not be dialed. The Session ID does not exist: #{session_id}"
|
184
|
+
else
|
185
|
+
raise OpenTokSipError, "The sip session could not be dialed"
|
186
|
+
end
|
187
|
+
rescue StandardError => e
|
188
|
+
raise OpenTokError, "Failed to connect to OpenTok. Response code: #{e.message}"
|
189
|
+
end
|
165
190
|
end
|
166
191
|
end
|
data/lib/opentok/exceptions.rb
CHANGED
@@ -4,6 +4,8 @@ module OpenTok
|
|
4
4
|
class OpenTokError < StandardError; end
|
5
5
|
# Defines errors raised by archive-related methods of the OpenTok Ruby SDK.
|
6
6
|
class OpenTokArchiveError < OpenTokError; end
|
7
|
+
# Defines errors raised by SIP methods of the OpenTok Ruby SDK.
|
8
|
+
class OpenTokSipError < OpenTokError; end
|
7
9
|
# Defines errors raised when you attempt an operation using an invalid OpenTok API key or secret.
|
8
10
|
class OpenTokAuthenticationError < OpenTokError; end
|
9
11
|
|
data/lib/opentok/opentok.rb
CHANGED
@@ -3,6 +3,7 @@ require "opentok/session"
|
|
3
3
|
require "opentok/client"
|
4
4
|
require "opentok/token_generator"
|
5
5
|
require "opentok/archives"
|
6
|
+
require "opentok/sip"
|
6
7
|
|
7
8
|
require "resolv"
|
8
9
|
require "set"
|
@@ -172,6 +173,10 @@ module OpenTok
|
|
172
173
|
@archives ||= Archives.new client
|
173
174
|
end
|
174
175
|
|
176
|
+
def sip
|
177
|
+
@sip ||= Sip.new client
|
178
|
+
end
|
179
|
+
|
175
180
|
protected
|
176
181
|
|
177
182
|
def client
|
data/lib/opentok/sip.rb
ADDED
data/lib/opentok/version.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.opentok.com/v2/project/123456/dial
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"sessionId":"SESSIONID","token":"TOKENID","sip":{"uri":"sip:+15128675309@acme.pstn.example.com;transport=tls","auth":{"username":"bob","password":"abc123"},"secure":"true"}}'
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- OpenTok-Ruby-SDK/<%= version %>
|
12
|
+
X-Opentok-Auth:
|
13
|
+
- eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiIsImlzdCI6InByb2plY3QifQ.eyJpc3MiOiIxMjM0NTYiLCJpYXQiOjE0OTI1MTA2NjAsImV4cCI6MTQ5MjUxMDk2MH0.Oh_JHhtEUKK1pPV4s6neXJj_RXI8EcEpJRRpG_2c9U0
|
14
|
+
Content-Type:
|
15
|
+
- application/json
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Mon, 17 Apr 2017 22:40:03 GMT
|
25
|
+
Content-Type:
|
26
|
+
- application/json
|
27
|
+
Connection:
|
28
|
+
- keep-alive
|
29
|
+
Content-Length:
|
30
|
+
- '311'
|
31
|
+
Strict-Transport-Security:
|
32
|
+
- max-age=31536000; includeSubdomains
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: '{"id":"2299ba24-a6de-417c-88f7-28da54a441cf","projectId":"123456","sessionId":"SESSIONID","connectionId":"833a7182-61a5-49d4-baae-c324b09953af","streamId":"b1963d15-537f-459a-be89-e00fc310b82b","createdAt":1492468803946,"updatedAt":1492468803946}'
|
36
|
+
http_version:
|
37
|
+
recorded_at: Mon, 17 Apr 2017 22:40:01 GMT
|
38
|
+
recorded_with: VCR 2.8.0
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "opentok/opentok"
|
2
|
+
require "opentok/sip"
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe OpenTok::Sip do
|
6
|
+
before(:each) do
|
7
|
+
now = Time.parse("2017-04-18 20:17:40 +1000")
|
8
|
+
allow(Time).to receive(:now) { now }
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:api_key) { "123456" }
|
12
|
+
let(:api_secret) { "1234567890abcdef1234567890abcdef1234567890" }
|
13
|
+
let(:session_id) { "SESSIONID" }
|
14
|
+
let(:expiring_token) { "TOKENID" }
|
15
|
+
let(:sip_uri) { "sip:+15128675309@acme.pstn.example.com;transport=tls" }
|
16
|
+
let(:sip_username) { "bob" }
|
17
|
+
let(:sip_password) { "abc123" }
|
18
|
+
let(:opentok) { OpenTok::OpenTok.new api_key, api_secret }
|
19
|
+
let(:sip) { opentok.sip }
|
20
|
+
subject { sip }
|
21
|
+
|
22
|
+
it "receives a valid response", :vcr => { :erb => { :version => OpenTok::VERSION } } do
|
23
|
+
opts = { "auth" => { "username" => sip_username,
|
24
|
+
"password" => sip_password },
|
25
|
+
"secure" => "true"
|
26
|
+
}
|
27
|
+
response = sip.dial(session_id, expiring_token, sip_uri, opts)
|
28
|
+
expect(response).not_to be_nil
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opentok
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stijn Mathysen
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-
|
15
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bundler
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/opentok/extensions/hash.rb
|
190
190
|
- lib/opentok/opentok.rb
|
191
191
|
- lib/opentok/session.rb
|
192
|
+
- lib/opentok/sip.rb
|
192
193
|
- lib/opentok/token_generator.rb
|
193
194
|
- lib/opentok/version.rb
|
194
195
|
- opentok.gemspec
|
@@ -235,10 +236,12 @@ files:
|
|
235
236
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml
|
236
237
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml
|
237
238
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/with_an_addendum_to_the_user_agent_string/should_append_the_addendum_to_the_user_agent_header.yml
|
239
|
+
- spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml
|
238
240
|
- spec/matchers/token.rb
|
239
241
|
- spec/opentok/archives_spec.rb
|
240
242
|
- spec/opentok/opentok_spec.rb
|
241
243
|
- spec/opentok/session_spec.rb
|
244
|
+
- spec/opentok/sip_spec.rb
|
242
245
|
- spec/shared/opentok_generates_tokens.rb
|
243
246
|
- spec/shared/session_generates_tokens.rb
|
244
247
|
- spec/spec_helper.rb
|
@@ -291,10 +294,12 @@ test_files:
|
|
291
294
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_routed_media_sessions_with_a_location_hint.yml
|
292
295
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/_create_session/creates_sessions_with_a_location_hint.yml
|
293
296
|
- spec/cassettes/OpenTok_OpenTok/when_initialized_properly/with_an_addendum_to_the_user_agent_string/should_append_the_addendum_to_the_user_agent_header.yml
|
297
|
+
- spec/cassettes/OpenTok_Sip/receives_a_valid_response.yml
|
294
298
|
- spec/matchers/token.rb
|
295
299
|
- spec/opentok/archives_spec.rb
|
296
300
|
- spec/opentok/opentok_spec.rb
|
297
301
|
- spec/opentok/session_spec.rb
|
302
|
+
- spec/opentok/sip_spec.rb
|
298
303
|
- spec/shared/opentok_generates_tokens.rb
|
299
304
|
- spec/shared/session_generates_tokens.rb
|
300
305
|
- spec/spec_helper.rb
|