twilio-ruby 3.1.1 → 3.2.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.
- data/lib/twilio-ruby.rb +2 -0
- data/lib/twilio-ruby/rest/client.rb +1 -1
- data/lib/twilio-ruby/util/capability.rb +61 -0
- data/lib/twilio-ruby/util/request_validator.rb +1 -1
- data/twilio-ruby.gemspec +4 -3
- metadata +49 -63
data/lib/twilio-ruby.rb
CHANGED
@@ -7,10 +7,12 @@ require 'json'
|
|
7
7
|
require 'cgi'
|
8
8
|
require 'openssl'
|
9
9
|
require 'base64'
|
10
|
+
require 'jwt'
|
10
11
|
|
11
12
|
|
12
13
|
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util"
|
13
14
|
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util/request_validator"
|
15
|
+
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/util/capability"
|
14
16
|
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/errors"
|
15
17
|
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/utils"
|
16
18
|
require "#{TWILIO_RUBY_ROOT}/twilio-ruby/rest/list_resource"
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Twilio
|
2
|
+
module Util
|
3
|
+
class Capability
|
4
|
+
|
5
|
+
include Twilio::Util
|
6
|
+
|
7
|
+
def initialize(account_sid, auth_token)
|
8
|
+
@account_sid = account_sid
|
9
|
+
@auth_token = auth_token
|
10
|
+
@capabilities = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def allow_client_incoming(client_name)
|
14
|
+
@client_name = client_name # stash for use in outgoing
|
15
|
+
scope_params = {'clientName' => client_name}
|
16
|
+
@capabilities << scope_uri_for('client', 'incoming', scope_params)
|
17
|
+
end
|
18
|
+
|
19
|
+
def allow_client_outgoing(app_sid, params = {})
|
20
|
+
@allow_client_outgoing = true
|
21
|
+
@outgoing_scope_params = {'appSid' => app_sid}
|
22
|
+
unless params.empty?
|
23
|
+
@outgoing_scope_params['appParams'] = url_encode params
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def allow_event_stream(filters = {})
|
28
|
+
scope_params = {'path' => '/2010-04-01/Events'}
|
29
|
+
scope_params['params'] = filters unless filters.empty?
|
30
|
+
@capabilities << scope_uri_for('stream', 'subscribe', scope_params)
|
31
|
+
end
|
32
|
+
|
33
|
+
def scope_uri_for(service, privilege, params = {})
|
34
|
+
scope_uri = "scope:#{service}:#{privilege}"
|
35
|
+
scope_uri << "?#{url_encode(params)}" unless params.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def generate(ttl = 3600)
|
39
|
+
|
40
|
+
capabilities = @capabilities.clone # we need a local copy to work on
|
41
|
+
|
42
|
+
# build the outgoing scope lazily so that we can use @client_name
|
43
|
+
if @allow_client_outgoing
|
44
|
+
params = @outgoing_scope_params
|
45
|
+
params.merge!({'clientName' => @client_name}) if @client_name
|
46
|
+
capabilities << scope_uri_for('client', 'outgoing', params)
|
47
|
+
end
|
48
|
+
|
49
|
+
payload = {
|
50
|
+
'scope' => capabilities.join(' '),
|
51
|
+
'iss' => @account_sid,
|
52
|
+
'exp' => (Time.now.to_i + ttl),
|
53
|
+
}
|
54
|
+
|
55
|
+
JWT.encode payload, @auth_token
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/twilio-ruby.gemspec
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "twilio-ruby"
|
3
|
-
s.version = "3.
|
3
|
+
s.version = "3.2.0"
|
4
4
|
s.author = "Andrew Benton"
|
5
5
|
s.email = "andrew@twilio.com"
|
6
|
-
s.description = "A simple library for communicating with the Twilio REST API"
|
7
|
-
s.summary = "A simple library for communicating with the Twilio REST API"
|
6
|
+
s.description = "A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens"
|
7
|
+
s.summary = "A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens"
|
8
8
|
s.homepage = "http://github.com/twilio/twilio-ruby"
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.files = Dir['lib/**/*.rb'] + Dir['test/**/*.rb'] + ['examples.rb', 'Rakefile', 'LICENSE', 'README.md', 'twilio-ruby.gemspec']
|
11
11
|
s.test_files = Dir['test/**/*.rb']
|
12
12
|
s.add_dependency("json", ">= 1.2.0")
|
13
13
|
s.add_dependency("builder", ">= 2.1.2")
|
14
|
+
s.add_dependency("jwt", ">= 0.1.2")
|
14
15
|
end
|
metadata
CHANGED
@@ -1,64 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: twilio-ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.2.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 3.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Andrew Benton
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-07-22 00:00:00 -07:00
|
12
|
+
date: 2011-07-26 00:00:00.000000000 -07:00
|
19
13
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
22
16
|
name: json
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: &17469100 !ruby/object:Gem::Requirement
|
25
18
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 31
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 2
|
33
|
-
- 0
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
34
22
|
version: 1.2.0
|
35
23
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: builder
|
39
24
|
prerelease: false
|
40
|
-
|
25
|
+
version_requirements: *17469100
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: builder
|
28
|
+
requirement: &17468340 !ruby/object:Gem::Requirement
|
41
29
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
hash: 15
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
- 1
|
49
|
-
- 2
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
50
33
|
version: 2.1.2
|
51
34
|
type: :runtime
|
52
|
-
|
53
|
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *17468340
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: jwt
|
39
|
+
requirement: &17467360 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ! '>='
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 0.1.2
|
45
|
+
type: :runtime
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *17467360
|
48
|
+
description: A simple library for communicating with the Twilio REST API, building
|
49
|
+
TwiML, and generating Twilio Client Capability Tokens
|
54
50
|
email: andrew@twilio.com
|
55
51
|
executables: []
|
56
|
-
|
57
52
|
extensions: []
|
58
|
-
|
59
53
|
extra_rdoc_files: []
|
60
|
-
|
61
|
-
files:
|
54
|
+
files:
|
62
55
|
- lib/twilio-ruby.rb
|
63
56
|
- lib/twilio-ruby/rest/client.rb
|
64
57
|
- lib/twilio-ruby/rest/list_resource.rb
|
@@ -96,6 +89,7 @@ files:
|
|
96
89
|
- lib/twilio-ruby/rest/available_phone_numbers/toll_free.rb
|
97
90
|
- lib/twilio-ruby/rest/sandbox/sandbox.rb
|
98
91
|
- lib/twilio-ruby/rest/instance_resource.rb
|
92
|
+
- lib/twilio-ruby/util/capability.rb
|
99
93
|
- lib/twilio-ruby/util/request_validator.rb
|
100
94
|
- lib/twilio-ruby/util.rb
|
101
95
|
- lib/twilio-ruby/twiml/response.rb
|
@@ -108,36 +102,28 @@ files:
|
|
108
102
|
has_rdoc: true
|
109
103
|
homepage: http://github.com/twilio/twilio-ruby
|
110
104
|
licenses: []
|
111
|
-
|
112
105
|
post_install_message:
|
113
106
|
rdoc_options: []
|
114
|
-
|
115
|
-
require_paths:
|
107
|
+
require_paths:
|
116
108
|
- lib
|
117
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
110
|
none: false
|
119
|
-
requirements:
|
120
|
-
- -
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
|
123
|
-
|
124
|
-
- 0
|
125
|
-
version: "0"
|
126
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
116
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
135
121
|
requirements: []
|
136
|
-
|
137
122
|
rubyforge_project:
|
138
123
|
rubygems_version: 1.6.2
|
139
124
|
signing_key:
|
140
125
|
specification_version: 3
|
141
|
-
summary: A simple library for communicating with the Twilio REST API
|
142
|
-
|
126
|
+
summary: A simple library for communicating with the Twilio REST API, building TwiML,
|
127
|
+
and generating Twilio Client Capability Tokens
|
128
|
+
test_files:
|
143
129
|
- test/twilio_spec.rb
|