twilio-ruby 4.7.0.edge → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +28 -0
  3. data/lib/twilio-ruby.rb +2 -13
  4. data/lib/twilio-ruby/rest/list_resource.rb +3 -4
  5. data/lib/twilio-ruby/rest/next_gen_list_resource.rb +2 -3
  6. data/lib/twilio-ruby/rest/pricing_client.rb +1 -1
  7. data/lib/twilio-ruby/rest/trunking_client.rb +2 -2
  8. data/lib/twilio-ruby/rest/utils.rb +1 -12
  9. data/lib/twilio-ruby/util/access_token.rb +96 -0
  10. data/lib/twilio-ruby/version.rb +1 -1
  11. data/spec/rest/pricing_client_spec.rb +15 -0
  12. data/spec/util/access_token_spec.rb +84 -0
  13. metadata +23 -43
  14. data/lib/twilio-ruby/rest/conversations/completed.rb +0 -13
  15. data/lib/twilio-ruby/rest/conversations/conversations.rb +0 -23
  16. data/lib/twilio-ruby/rest/conversations/in_progress.rb +0 -13
  17. data/lib/twilio-ruby/rest/conversations/participants.rb +0 -8
  18. data/lib/twilio-ruby/rest/conversations_client.rb +0 -99
  19. data/lib/twilio-ruby/rest/ip-messaging/channels.rb +0 -21
  20. data/lib/twilio-ruby/rest/ip-messaging/credentials.rb +0 -22
  21. data/lib/twilio-ruby/rest/ip-messaging/members.rb +0 -8
  22. data/lib/twilio-ruby/rest/ip-messaging/messages.rb +0 -8
  23. data/lib/twilio-ruby/rest/ip-messaging/roles.rb +0 -8
  24. data/lib/twilio-ruby/rest/ip-messaging/services.rb +0 -22
  25. data/lib/twilio-ruby/rest/ip-messaging/users.rb +0 -8
  26. data/lib/twilio-ruby/rest/ip_messaging_client.rb +0 -100
  27. data/spec/conversations/conversations_spec.rb +0 -61
  28. data/spec/rest/conversations_client_spec.rb +0 -13
  29. data/spec/rest/ip-messaging/channel_spec.rb +0 -21
  30. data/spec/rest/ip-messaging/service_spec.rb +0 -30
  31. data/spec/rest/ip_messaging_client_spec.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e051743dadcb3770084bc5b0539d4bd883fcea34
4
- data.tar.gz: 2d06b62b904ac55a2548529756d0ca610045d0dc
3
+ metadata.gz: f7ec300417fba6ebe8e47a95a97c8511c174d47b
4
+ data.tar.gz: 3758c5d95113ca3013b4374569f05f59e030f4b8
5
5
  SHA512:
6
- metadata.gz: 5a014ccd1b0a1a17c0c1bedd6d43f741a950ce4fa580b44ada632fd2571ba24898f6d8728bddddd55fd301318e74bdcdaaf908b67f358e6ec13d12a50089f821
7
- data.tar.gz: 0e99d6cec23cf04f01548ab4d5d936dca97e69b50679518d0fc992499e5c9de0b0b3d7099146459323b8aa24b9fe1cca0a9d870e7264ae628a48278fa3ab9dd5
6
+ metadata.gz: 99f35b8c1ad3c4b9beeaf5683be2bfb66b6c16ea42afd7b1b93c8c28653f0f97cd792ea5ff55209658f79a761c9306395b0b1499b1b61695965643369df2ef01
7
+ data.tar.gz: ced9b1a9fcb3755b5907587619b94664682d49c65909028778b95261440564a2fa9ea1324d05446d93b696d98e425768ec77edf410a0684a1cb2b3fba66c2fce
data/CHANGES.md CHANGED
@@ -1,6 +1,34 @@
1
1
  twilio-ruby changelog
2
2
  =====================
3
3
 
4
+ Version 4.7.0
5
+ -------------
6
+
7
+ Release December 3, 2015
8
+
9
+ - Add access tokens
10
+
11
+ Version 4.6.2
12
+ -------------
13
+
14
+ Release November 19, 2015
15
+
16
+ - Fix Pricing Messages
17
+
18
+ Version 4.6.1
19
+ -------------
20
+
21
+ Release November 10, 2015
22
+
23
+ - Fix TrunkingClient references
24
+
25
+ Version 4.6.0
26
+ -------------
27
+
28
+ Release October 28, 2015
29
+
30
+ - Add /Keys endpoint
31
+
4
32
  Version 4.4.0
5
33
  -------------
6
34
 
data/lib/twilio-ruby.rb CHANGED
@@ -10,6 +10,7 @@ require 'jwt'
10
10
 
11
11
  require 'twilio-ruby/version' unless defined?(Twilio::VERSION)
12
12
  require 'twilio-ruby/util'
13
+ require 'twilio-ruby/util/access_token'
13
14
  require 'twilio-ruby/util/client_config'
14
15
  require 'twilio-ruby/util/configuration'
15
16
  require 'twilio-ruby/util/request_validator'
@@ -35,17 +36,6 @@ require 'twilio-ruby/rest/pricing/phone_numbers'
35
36
  require 'twilio-ruby/rest/pricing/voice/numbers'
36
37
  require 'twilio-ruby/rest/pricing/voice'
37
38
  require 'twilio-ruby/rest/pricing/messaging'
38
- require 'twilio-ruby/rest/conversations/in_progress'
39
- require 'twilio-ruby/rest/conversations/completed'
40
- require 'twilio-ruby/rest/conversations/conversations'
41
- require 'twilio-ruby/rest/conversations/participants'
42
- require 'twilio-ruby/rest/ip-messaging/services'
43
- require 'twilio-ruby/rest/ip-messaging/channels'
44
- require 'twilio-ruby/rest/ip-messaging/members'
45
- require 'twilio-ruby/rest/ip-messaging/messages'
46
- require 'twilio-ruby/rest/ip-messaging/roles'
47
- require 'twilio-ruby/rest/ip-messaging/users'
48
- require 'twilio-ruby/rest/ip-messaging/credentials'
49
39
  require 'twilio-ruby/rest/sms'
50
40
  require 'twilio-ruby/rest/sms/short_codes'
51
41
  require 'twilio-ruby/rest/sms/messages'
@@ -107,12 +97,11 @@ require 'twilio-ruby/rest/notifications'
107
97
  require 'twilio-ruby/rest/addresses'
108
98
  require 'twilio-ruby/rest/addresses/dependent_phone_numbers'
109
99
  require 'twilio-ruby/rest/client'
110
- require 'twilio-ruby/rest/conversations_client'
111
100
  require 'twilio-ruby/rest/task_router_client'
101
+ require 'twilio-ruby/rest/trunking_client'
112
102
  require 'twilio-ruby/rest/lookups_client'
113
103
  require 'twilio-ruby/rest/pricing_client'
114
104
  require 'twilio-ruby/rest/monitor_client'
115
- require 'twilio-ruby/rest/ip_messaging_client'
116
105
  require 'rack/twilio_webhook_authentication'
117
106
 
118
107
  module Twilio
@@ -10,7 +10,7 @@ module Twilio
10
10
  'Countries' => 'Country',
11
11
  'Feedback' => 'FeedbackInstance',
12
12
  'IpAddresses' => 'IpAddress',
13
- 'Media' => 'MediaInstance'
13
+ 'Media' => 'MediaInstance',
14
14
  }
15
15
  @path, @client = path, client
16
16
  resource_name = self.class.name.split('::')[-1]
@@ -46,8 +46,7 @@ module Twilio
46
46
  raise "Can't get a resource list without a REST Client" unless @client
47
47
  response = @client.get @path, params, full_path
48
48
  resources = response[@list_key]
49
- path = @frozen_path ? @frozen_path : @path
50
- path = full_path ? path.split('.')[0] : path
49
+ path = full_path ? @path.split('.')[0] : @path
51
50
  resource_list = resources.map do |resource|
52
51
  @instance_class.new "#{path}/#{resource[@instance_id_key]}", @client,
53
52
  resource
@@ -81,7 +80,7 @@ module Twilio
81
80
  # attribute of the returned instance resource object, such as
82
81
  # its #date_created or #voice_url attributes.
83
82
  def get(sid)
84
- @instance_class.new "#{@frozen_path || @path}/#{sid}", @client
83
+ @instance_class.new "#{@path}/#{sid}", @client
85
84
  end
86
85
  alias :find :get # for the ActiveRecord lovers
87
86
 
@@ -4,12 +4,11 @@ module Twilio
4
4
  def list(params={}, full_path=false)
5
5
  raise "Can't get a resource list without a REST Client" unless @client
6
6
  response = @client.get @path, params, full_path
7
- list_key = response['meta']['key'] if response['meta']
7
+ list_key = response['meta']['key']
8
8
  raise "Couldn't find a list key in response meta" unless list_key
9
9
  resources = response[list_key]
10
- path = @frozen_path ? @frozen_path : @path
11
10
  resource_list = resources.map do |resource|
12
- @instance_class.new "#{path}/#{resource[@instance_id_key]}", @client,
11
+ @instance_class.new "#{@path}/#{resource[@instance_id_key]}", @client,
13
12
  resource
14
13
  end
15
14
  client, list_class = @client, self.class
@@ -8,7 +8,7 @@ module Twilio
8
8
 
9
9
  API_VERSION = 'v1'
10
10
 
11
- attr_reader :voice, :phone_numbers
11
+ attr_reader :voice, :phone_numbers, :messaging
12
12
 
13
13
  host 'pricing.twilio.com'
14
14
 
@@ -89,9 +89,9 @@ module Twilio
89
89
  protected
90
90
 
91
91
  ##
92
- # Set up +voice+ and +phone_numbers+ attributes.
92
+ # Set up +trunks+ attribute.
93
93
  def set_up_subresources # :doc:
94
- @voice = Twilio::REST::Trunking::Trunks.new "/#{API_VERSION}/Trunks", self
94
+ @trunks = Twilio::REST::Trunking::Trunks.new "/#{API_VERSION}/Trunks", self
95
95
  end
96
96
 
97
97
  ##
@@ -19,13 +19,6 @@ module Twilio
19
19
 
20
20
  protected
21
21
 
22
- # Freeze the base list path.
23
- # Used on list resources so filters (such as /Local) do not affect the
24
- # instance resource path.
25
- def freeze_path
26
- @frozen_path = @path
27
- end
28
-
29
22
  def resource(*resources)
30
23
  custom_resource_names = { sms: 'SMS', sip: 'SIP' }
31
24
  resources.each do |r|
@@ -38,11 +31,7 @@ module Twilio
38
31
  Twilio::REST.const_get(@submodule)
39
32
  end
40
33
  resource_class = enclosing_module.const_get resource
41
- resource_object = resource_class.new(path, @client)
42
- instance_variable_set("@#{r}", resource_object)
43
- if @frozen_path
44
- resource_object.instance_variable_set(:@frozen_path, @frozen_path)
45
- end
34
+ instance_variable_set("@#{r}", resource_class.new(path, @client))
46
35
  end
47
36
  self.class.instance_eval { attr_reader *resources }
48
37
  end
@@ -0,0 +1,96 @@
1
+ module Twilio
2
+ module Util
3
+ class AccessToken
4
+ def initialize(account_sid, signing_key_id, secret, ttl=3600, identity=nil)
5
+ @account_sid = account_sid
6
+ @signing_key_sid = signing_key_id
7
+ @secret = secret
8
+ @ttl = ttl
9
+ @identity = identity
10
+ @grants = []
11
+ end
12
+
13
+ def add_grant(grant)
14
+ @grants.push(grant)
15
+ end
16
+
17
+ def to_jwt(algorithm='HS256')
18
+ now = Time.now.to_i - 1
19
+ headers = {
20
+ 'cty' => 'twilio-fpa;v=1',
21
+ 'typ' => 'JWT'
22
+ }
23
+
24
+ grants = {}
25
+ if @identity
26
+ grants['identity'] = @identity
27
+ end
28
+
29
+ @grants.each { |grant| grants[grant.key] = grant.payload }
30
+
31
+ payload = {
32
+ 'jti' => "#{@signing_key_sid}-#{now}",
33
+ 'iss' => @signing_key_sid,
34
+ 'sub' => @account_sid,
35
+ 'nbf' => now,
36
+ 'exp' => now + @ttl,
37
+ 'grants' => grants
38
+ }
39
+ JWT.encode payload, @secret, algorithm, headers
40
+ end
41
+
42
+ def to_s
43
+ to_jwt
44
+ end
45
+
46
+ class ConversationsGrant
47
+ attr_accessor :configuration_profile_sid
48
+
49
+ def key
50
+ 'rtc'
51
+ end
52
+
53
+ def payload
54
+ payload = {}
55
+ if @configuration_profile_sid
56
+ payload['configuration_profile_sid'] = @configuration_profile_sid
57
+ end
58
+
59
+ payload
60
+ end
61
+
62
+ end
63
+
64
+ class IpMessagingGrant
65
+ attr_accessor :service_sid,
66
+ :endpoint_id,
67
+ :deployment_role_sid,
68
+ :push_credential_sid
69
+
70
+ def key
71
+ 'ip_messaging'
72
+ end
73
+
74
+ def payload
75
+ payload = {}
76
+ if @service_sid
77
+ payload['service_sid'] = @service_sid
78
+ end
79
+ if @endpoint_id
80
+ payload['endpoint_id'] = @endpoint_id
81
+ end
82
+ if @role_sid
83
+ payload['deployment_role_sid'] = @deployment_role_sid
84
+ end
85
+ if @credential_sid
86
+ payload['push_credential_sid'] = @push_credential_sid
87
+ end
88
+
89
+ payload
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+ end
96
+ end
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '4.7.0.edge'
2
+ VERSION = '4.7.0'
3
3
  end
@@ -42,4 +42,19 @@ describe Twilio::REST::PricingClient do
42
42
  '/v1/PhoneNumbers/Countries'
43
43
  )
44
44
  end
45
+
46
+ it 'should set up a messaging resources object' do
47
+ expect(@client).to respond_to(:messaging)
48
+ expect(@client.messaging.instance_variable_get('@path')).to eq(
49
+ '/v1/Messaging'
50
+ )
51
+ end
52
+
53
+ it 'should set up the country list resource on messaging' do
54
+ messaging = @client.messaging
55
+ expect(messaging).to respond_to(:countries)
56
+ expect(messaging.countries.instance_variable_get('@path')).to eq(
57
+ '/v1/Messaging/Countries'
58
+ )
59
+ end
45
60
  end
@@ -0,0 +1,84 @@
1
+ require 'spec_helper'
2
+
3
+ describe Twilio::Util::AccessToken do
4
+
5
+ it 'should generate a token for no grants' do
6
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
7
+ token = scat.to_s
8
+ expect(token).not_to be_nil
9
+ payload, header = JWT.decode token, 'secret'
10
+
11
+ expect(payload['iss']).to eq('SK123')
12
+ expect(payload['sub']).to eq('AC123')
13
+ expect(payload['nbf']).not_to be_nil
14
+ expect(payload['exp']).not_to be_nil
15
+ expect(payload['nbf'] + 3600).to eq(payload['exp'])
16
+ expect(payload['jti']).not_to be_nil
17
+ expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
18
+ expect(payload['grants']).not_to be_nil
19
+ expect(payload['grants'].count).to eq(0)
20
+ end
21
+
22
+ it 'should be able to add conversation grant' do
23
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
24
+ scat.add_grant(Twilio::Util::AccessToken::ConversationsGrant.new)
25
+
26
+ token = scat.to_s
27
+ expect(token).not_to be_nil
28
+ payload, header = JWT.decode token, 'secret'
29
+
30
+ expect(payload['iss']).to eq('SK123')
31
+ expect(payload['sub']).to eq('AC123')
32
+ expect(payload['nbf']).not_to be_nil
33
+ expect(payload['exp']).not_to be_nil
34
+ expect(payload['nbf'] + 3600).to eq(payload['exp'])
35
+ expect(payload['jti']).not_to be_nil
36
+ expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
37
+ expect(payload['grants']).not_to be_nil
38
+ expect(payload['grants'].count).to eq(1)
39
+ expect(payload['grants']['rtc']).not_to be_nil
40
+ end
41
+
42
+ it 'should be able to add endpoint grants' do
43
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
44
+ scat.add_grant(Twilio::Util::AccessToken::IpMessagingGrant.new)
45
+
46
+ token = scat.to_s
47
+ expect(token).not_to be_nil
48
+ payload, header = JWT.decode token, 'secret'
49
+
50
+ expect(payload['iss']).to eq('SK123')
51
+ expect(payload['sub']).to eq('AC123')
52
+ expect(payload['nbf']).not_to be_nil
53
+ expect(payload['exp']).not_to be_nil
54
+ expect(payload['nbf'] + 3600).to eq(payload['exp'])
55
+ expect(payload['jti']).not_to be_nil
56
+ expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
57
+ expect(payload['grants']).not_to be_nil
58
+ expect(payload['grants'].count).to eq(1)
59
+ expect(payload['grants']['ip_messaging']).not_to be_nil
60
+ end
61
+
62
+ it 'should add rest grants' do
63
+ scat = Twilio::Util::AccessToken.new 'AC123', 'SK123','secret'
64
+ scat.add_grant(Twilio::Util::AccessToken::ConversationsGrant.new)
65
+ scat.add_grant(Twilio::Util::AccessToken::IpMessagingGrant.new)
66
+
67
+ token = scat.to_s
68
+ expect(token).not_to be_nil
69
+ payload, header = JWT.decode token, 'secret'
70
+
71
+ expect(payload['iss']).to eq('SK123')
72
+ expect(payload['sub']).to eq('AC123')
73
+ expect(payload['nbf']).not_to be_nil
74
+ expect(payload['exp']).not_to be_nil
75
+ expect(payload['nbf'] + 3600).to eq(payload['exp'])
76
+ expect(payload['jti']).not_to be_nil
77
+ expect("#{payload['iss']}-#{payload['nbf']}").to eq(payload['jti'])
78
+ expect(payload['grants']).not_to be_nil
79
+ expect(payload['grants'].count).to eq(2)
80
+ expect(payload['grants']['rtc']).not_to be_nil
81
+ expect(payload['grants']['ip_messaging']).not_to be_nil
82
+ end
83
+
84
+ end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0.edge
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Benton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: builder
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.1.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 2.1.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: jwt
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '1.5'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '1.5'
69
69
  description: A simple library for communicating with the Twilio REST API, building
@@ -76,8 +76,8 @@ extra_rdoc_files:
76
76
  - README.md
77
77
  - LICENSE.md
78
78
  files:
79
- - .gitignore
80
- - .travis.yml
79
+ - ".gitignore"
80
+ - ".travis.yml"
81
81
  - AUTHORS.md
82
82
  - CHANGES.md
83
83
  - Gemfile
@@ -150,25 +150,12 @@ files:
150
150
  - lib/twilio-ruby/rest/conferences.rb
151
151
  - lib/twilio-ruby/rest/conferences/participants.rb
152
152
  - lib/twilio-ruby/rest/connect_apps.rb
153
- - lib/twilio-ruby/rest/conversations/completed.rb
154
- - lib/twilio-ruby/rest/conversations/conversations.rb
155
- - lib/twilio-ruby/rest/conversations/in_progress.rb
156
- - lib/twilio-ruby/rest/conversations/participants.rb
157
- - lib/twilio-ruby/rest/conversations_client.rb
158
153
  - lib/twilio-ruby/rest/errors.rb
159
154
  - lib/twilio-ruby/rest/incoming_phone_numbers.rb
160
155
  - lib/twilio-ruby/rest/incoming_phone_numbers/local.rb
161
156
  - lib/twilio-ruby/rest/incoming_phone_numbers/mobile.rb
162
157
  - lib/twilio-ruby/rest/incoming_phone_numbers/toll_free.rb
163
158
  - lib/twilio-ruby/rest/instance_resource.rb
164
- - lib/twilio-ruby/rest/ip-messaging/channels.rb
165
- - lib/twilio-ruby/rest/ip-messaging/credentials.rb
166
- - lib/twilio-ruby/rest/ip-messaging/members.rb
167
- - lib/twilio-ruby/rest/ip-messaging/messages.rb
168
- - lib/twilio-ruby/rest/ip-messaging/roles.rb
169
- - lib/twilio-ruby/rest/ip-messaging/services.rb
170
- - lib/twilio-ruby/rest/ip-messaging/users.rb
171
- - lib/twilio-ruby/rest/ip_messaging_client.rb
172
159
  - lib/twilio-ruby/rest/keys.rb
173
160
  - lib/twilio-ruby/rest/list_resource.rb
174
161
  - lib/twilio-ruby/rest/lookups/phone_numbers.rb
@@ -234,12 +221,12 @@ files:
234
221
  - lib/twilio-ruby/task_router/workflow_builder.rb
235
222
  - lib/twilio-ruby/twiml/response.rb
236
223
  - lib/twilio-ruby/util.rb
224
+ - lib/twilio-ruby/util/access_token.rb
237
225
  - lib/twilio-ruby/util/capability.rb
238
226
  - lib/twilio-ruby/util/client_config.rb
239
227
  - lib/twilio-ruby/util/configuration.rb
240
228
  - lib/twilio-ruby/util/request_validator.rb
241
229
  - lib/twilio-ruby/version.rb
242
- - spec/conversations/conversations_spec.rb
243
230
  - spec/rack/twilio_webhook_authentication_spec.rb
244
231
  - spec/rest/account_spec.rb
245
232
  - spec/rest/address_spec.rb
@@ -248,11 +235,7 @@ files:
248
235
  - spec/rest/call_spec.rb
249
236
  - spec/rest/client_spec.rb
250
237
  - spec/rest/conference_spec.rb
251
- - spec/rest/conversations_client_spec.rb
252
238
  - spec/rest/instance_resource_spec.rb
253
- - spec/rest/ip-messaging/channel_spec.rb
254
- - spec/rest/ip-messaging/service_spec.rb
255
- - spec/rest/ip_messaging_client_spec.rb
256
239
  - spec/rest/key_spec.rb
257
240
  - spec/rest/lookups/phone_number_spec.rb
258
241
  - spec/rest/message_spec.rb
@@ -277,6 +260,7 @@ files:
277
260
  - spec/task_router_worker_spec.rb
278
261
  - spec/task_router_workspace_spec.rb
279
262
  - spec/twilio_spec.rb
263
+ - spec/util/access_token_spec.rb
280
264
  - spec/util/capability_spec.rb
281
265
  - spec/util/client_config_spec.rb
282
266
  - spec/util/configuration_spec.rb
@@ -289,33 +273,32 @@ licenses:
289
273
  metadata: {}
290
274
  post_install_message:
291
275
  rdoc_options:
292
- - --line-numbers
293
- - --inline-source
294
- - --title
276
+ - "--line-numbers"
277
+ - "--inline-source"
278
+ - "--title"
295
279
  - twilio-ruby
296
- - --main
280
+ - "--main"
297
281
  - README.md
298
282
  require_paths:
299
283
  - lib
300
284
  required_ruby_version: !ruby/object:Gem::Requirement
301
285
  requirements:
302
- - - '>='
286
+ - - ">="
303
287
  - !ruby/object:Gem::Version
304
288
  version: 1.9.3
305
289
  required_rubygems_version: !ruby/object:Gem::Requirement
306
290
  requirements:
307
- - - '>'
291
+ - - ">="
308
292
  - !ruby/object:Gem::Version
309
- version: 1.3.1
293
+ version: '0'
310
294
  requirements: []
311
295
  rubyforge_project:
312
- rubygems_version: 2.0.14
296
+ rubygems_version: 2.4.8
313
297
  signing_key:
314
298
  specification_version: 4
315
299
  summary: A simple library for communicating with the Twilio REST API, building TwiML,
316
300
  and generating Twilio Client Capability Tokens
317
301
  test_files:
318
- - spec/conversations/conversations_spec.rb
319
302
  - spec/rack/twilio_webhook_authentication_spec.rb
320
303
  - spec/rest/account_spec.rb
321
304
  - spec/rest/address_spec.rb
@@ -324,11 +307,7 @@ test_files:
324
307
  - spec/rest/call_spec.rb
325
308
  - spec/rest/client_spec.rb
326
309
  - spec/rest/conference_spec.rb
327
- - spec/rest/conversations_client_spec.rb
328
310
  - spec/rest/instance_resource_spec.rb
329
- - spec/rest/ip-messaging/channel_spec.rb
330
- - spec/rest/ip-messaging/service_spec.rb
331
- - spec/rest/ip_messaging_client_spec.rb
332
311
  - spec/rest/key_spec.rb
333
312
  - spec/rest/lookups/phone_number_spec.rb
334
313
  - spec/rest/message_spec.rb
@@ -353,6 +332,7 @@ test_files:
353
332
  - spec/task_router_worker_spec.rb
354
333
  - spec/task_router_workspace_spec.rb
355
334
  - spec/twilio_spec.rb
335
+ - spec/util/access_token_spec.rb
356
336
  - spec/util/capability_spec.rb
357
337
  - spec/util/client_config_spec.rb
358
338
  - spec/util/configuration_spec.rb
@@ -1,13 +0,0 @@
1
- module Twilio
2
- module REST
3
- module Conversations
4
- class Completed < NextGenListResource
5
- def initialize(path, client)
6
- @path, @client = path, client
7
- @instance_class = Twilio::REST::Conversations::Conversation
8
- @instance_id_key = 'sid'
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,23 +0,0 @@
1
- module Twilio
2
- module REST
3
- module Conversations
4
- class Conversations < NextGenListResource
5
- def initialize(path, client)
6
- @path, @client = path, client
7
- @submodule = :Conversations
8
- freeze_path
9
- resource :in_progress,
10
- :completed
11
- end
12
- end
13
-
14
- class Conversation < InstanceResource
15
- def initialize(path, client, params={})
16
- super
17
- @submodule = :Conversations
18
- resource :participants
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,13 +0,0 @@
1
- module Twilio
2
- module REST
3
- module Conversations
4
- class InProgress < NextGenListResource
5
- def initialize(path, client)
6
- @path, @client = path, client
7
- @instance_class = Twilio::REST::Conversations::Conversation
8
- @instance_id_key = 'sid'
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- module Twilio
2
- module REST
3
- module Conversations
4
- class Participants < NextGenListResource; end
5
- class Participant < InstanceResource; end
6
- end
7
- end
8
- end
@@ -1,99 +0,0 @@
1
- require 'twilio-ruby/rest/base_client'
2
- module Twilio
3
- module REST
4
- class ConversationsClient < BaseClient
5
- API_VERSION = 'v1'
6
-
7
- attr_reader :conversations
8
-
9
- host 'conversations.twilio.com'
10
-
11
- ##
12
- # Instantiate a new HTTP Conversations client to talk to Twilio. The parameters
13
- # +account_sid+, +auth_token+ are required, unless you have configured
14
- # them already using the block configure syntax, and used to generate the
15
- # HTTP basic auth header in each request. The +options+ parameter is a
16
- # hash of connection configuration options. the following keys are
17
- # supported:
18
- #
19
- # === <tt>host: 'conversations.twilio.com'</tt>
20
- #
21
- # The domain to which you'd like the client to make HTTP requests. Useful
22
- # for testing. Defaults to 'conversations.twilio.com'.
23
- #
24
- # === <tt>port: 443</tt>
25
- #
26
- # The port on which to connect to the above domain. Defaults to 443 and
27
- # should be left that way except in testing environments.
28
- #
29
- # === <tt>use_ssl: true</tt>
30
- #
31
- # Declare whether ssl should be used for connections to the above domain.
32
- # Defaults to true and should be left alone except when testing.
33
- #
34
- # === <tt>ssl_verify_peer: true</tt>
35
- #
36
- # Declare whether to verify the host's ssl cert when setting up the
37
- # connection to the above domain. Defaults to true, but can be turned off
38
- # to avoid ssl certificate verification failures in environments without
39
- # the necessary ca certificates.
40
- #
41
- # === <tt>ssl_ca_file: '/path/to/ca/file'</tt>
42
- #
43
- # Specify the path to the certificate authority bundle you'd like to use
44
- # to verify Twilio's SSL certificate on each request. If not specified, a
45
- # certificate bundle extraced from Firefox is packaged with the gem and
46
- # used by default.
47
- #
48
- # === <tt>timeout: 30</tt>
49
- #
50
- # Set the time in seconds to wait before timing out the HTTP request.
51
- # Defaults to 30 seconds. If you aren't fetching giant pages of call or
52
- # SMS logs you can safely decrease this to something like 3 seconds or
53
- # lower. In paricular if you are sending SMS you can set this to 1 second
54
- # or less and swallow the exception if you don't care about the response.
55
- #
56
- # === <tt>proxy_addr: 'proxy.host.domain'</tt>
57
- #
58
- # The domain of a proxy through which you'd like the client to make HTTP
59
- # requests. Defaults to nil.
60
- #
61
- # === <tt>proxy_port: 3128</tt>
62
- #
63
- # The port on which to connect to the above proxy. Defaults to nil.
64
- #
65
- # === <tt>proxy_user: 'username'</tt>
66
- #
67
- # The user name to use for authentication with the proxy. Defaults to nil.
68
- #
69
- # === <tt>proxy_pass: 'password'</tt>
70
- #
71
- # The password to use for authentication with the proxy. Defaults to nil.
72
- #
73
- # === <tt>retry_limit: 1</tt>
74
- #
75
- # The number of times to retry a request that has failed before throwing
76
- # an exception. Defaults to one.
77
- def inspect # :nodoc:
78
- "<Twilio::REST::ConversationsClient @account_sid=#{@account_sid}>"
79
- end
80
-
81
- protected
82
-
83
- ##
84
- # Create subresource properties
85
- def set_up_subresources # :doc:
86
- @conversations = Twilio::REST::Conversations::Conversations.new "/#{API_VERSION}/Conversations", self
87
- end
88
-
89
- ##
90
- # Builds up full request path
91
- def build_full_path(path, params, method)
92
- path = path.dup
93
- path << "?#{url_encode(params)}" if method == :get && !params.empty?
94
- path
95
- end
96
-
97
- end
98
- end
99
- end
@@ -1,21 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Channels < NextGenListResource
5
- def initialize(path, client)
6
- @path, client = path, client
7
- @submodule = :IpMessaging
8
- end
9
- end
10
- class Channel < InstanceResource
11
- def initialize(path, client, params={})
12
- super
13
- @submodule = :IpMessaging
14
-
15
- resource :messages,
16
- :members
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Credentials < NextGenListResource
5
- def initialize(path, client)
6
- @path, @client = path, client
7
- @submodule = :IpMessaging
8
- end
9
- end
10
-
11
- class Credential < InstanceResource
12
- def initialize(path, client, params={})
13
- super
14
- @submodule = :IpMessaging
15
- resource :channels,
16
- :users,
17
- :roles
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,8 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Members < NextGenListResource; end
5
- class Member < InstanceResource; end
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Messages < NextGenListResource; end
5
- class Message < InstanceResource; end
6
- end
7
- end
8
- end
@@ -1,8 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Roles < NextGenListResource; end
5
- class Role < InstanceResource; end
6
- end
7
- end
8
- end
@@ -1,22 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Services < NextGenListResource
5
- def initialize(path, client)
6
- @path, @client = path, client
7
- @submodule = :IpMessaging
8
- end
9
- end
10
-
11
- class Service < InstanceResource
12
- def initialize(path, client, params={})
13
- super
14
- @submodule = :IpMessaging
15
- resource :channels,
16
- :users,
17
- :roles
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,8 +0,0 @@
1
- module Twilio
2
- module REST
3
- module IpMessaging
4
- class Users < NextGenListResource; end
5
- class User < InstanceResource; end
6
- end
7
- end
8
- end
@@ -1,100 +0,0 @@
1
- require 'twilio-ruby/rest/base_client'
2
- module Twilio
3
- module REST
4
- class IpMessagingClient < BaseClient
5
- API_VERSION = 'v1'
6
-
7
- attr_reader :services, :credentials
8
-
9
- host 'ip-messaging.twilio.com'
10
-
11
- ##
12
- # Instantiate a new HTTP Conversations client to talk to Twilio. The parameters
13
- # +account_sid+, +auth_token+ are required, unless you have configured
14
- # them already using the block configure syntax, and used to generate the
15
- # HTTP basic auth header in each request. The +options+ parameter is a
16
- # hash of connection configuration options. the following keys are
17
- # supported:
18
- #
19
- # === <tt>host: 'ip-messaging.twilio.com'</tt>
20
- #
21
- # The domain to which you'd like the client to make HTTP requests. Useful
22
- # for testing. Defaults to 'ip-messaging.twilio.com'.
23
- #
24
- # === <tt>port: 443</tt>
25
- #
26
- # The port on which to connect to the above domain. Defaults to 443 and
27
- # should be left that way except in testing environments.
28
- #
29
- # === <tt>use_ssl: true</tt>
30
- #
31
- # Declare whether ssl should be used for connections to the above domain.
32
- # Defaults to true and should be left alone except when testing.
33
- #
34
- # === <tt>ssl_verify_peer: true</tt>
35
- #
36
- # Declare whether to verify the host's ssl cert when setting up the
37
- # connection to the above domain. Defaults to true, but can be turned off
38
- # to avoid ssl certificate verification failures in environments without
39
- # the necessary ca certificates.
40
- #
41
- # === <tt>ssl_ca_file: '/path/to/ca/file'</tt>
42
- #
43
- # Specify the path to the certificate authority bundle you'd like to use
44
- # to verify Twilio's SSL certificate on each request. If not specified, a
45
- # certificate bundle extraced from Firefox is packaged with the gem and
46
- # used by default.
47
- #
48
- # === <tt>timeout: 30</tt>
49
- #
50
- # Set the time in seconds to wait before timing out the HTTP request.
51
- # Defaults to 30 seconds. If you aren't fetching giant pages of call or
52
- # SMS logs you can safely decrease this to something like 3 seconds or
53
- # lower. In paricular if you are sending SMS you can set this to 1 second
54
- # or less and swallow the exception if you don't care about the response.
55
- #
56
- # === <tt>proxy_addr: 'proxy.host.domain'</tt>
57
- #
58
- # The domain of a proxy through which you'd like the client to make HTTP
59
- # requests. Defaults to nil.
60
- #
61
- # === <tt>proxy_port: 3128</tt>
62
- #
63
- # The port on which to connect to the above proxy. Defaults to nil.
64
- #
65
- # === <tt>proxy_user: 'username'</tt>
66
- #
67
- # The user name to use for authentication with the proxy. Defaults to nil.
68
- #
69
- # === <tt>proxy_pass: 'password'</tt>
70
- #
71
- # The password to use for authentication with the proxy. Defaults to nil.
72
- #
73
- # === <tt>retry_limit: 1</tt>
74
- #
75
- # The number of times to retry a request that has failed before throwing
76
- # an exception. Defaults to one.
77
- def inspect # :nodoc:
78
- "<Twilio::REST::IpMessagingClient @account_sid=#{@account_sid}>"
79
- end
80
-
81
- protected
82
-
83
- ##
84
- # Create subresource properties
85
- def set_up_subresources # :doc:
86
- @services = Twilio::REST::IpMessaging::Services.new "/#{API_VERSION}/Services", self
87
- @credentials = Twilio::REST::IpMessaging::Credentials.new "/#{API_VERSION}/Credentials", self
88
- end
89
-
90
- ##
91
- # Builds up full request path
92
- def build_full_path(path, params, method)
93
- path = path.dup
94
- path << "?#{url_encode(params)}" if method == :get && !params.empty?
95
- path
96
- end
97
-
98
- end
99
- end
100
- end
@@ -1,61 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Twilio::REST::Conversations::Conversations do
4
-
5
- it 'creates an in_progress property' do
6
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
7
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
8
- expect(conversations).to respond_to(:in_progress)
9
- end
10
-
11
- it 'creates a completed property' do
12
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
13
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
14
- expect(conversations).to respond_to(:completed)
15
- end
16
-
17
- end
18
-
19
- describe Twilio::REST::Conversations::InProgress do
20
- it 'gets constructed by conversations' do
21
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
22
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
23
- expect(conversations.in_progress.instance_variable_get('@path')).to eq('/v1/Conversations/InProgress')
24
- end
25
- it 'uses Conversation as its instance class' do
26
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
27
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
28
- expect(conversations.in_progress.instance_variable_get('@instance_class')).to eq(Twilio::REST::Conversations::Conversation)
29
- end
30
- end
31
-
32
- describe Twilio::REST::Conversations::Completed do
33
- it 'gets constructed by conversations' do
34
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
35
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
36
- expect(conversations.completed.instance_variable_get('@path')).to eq('/v1/Conversations/Completed')
37
- end
38
- it 'uses Conversation as its instance class' do
39
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
40
- conversations = Twilio::REST::Conversations::Conversations.new '/v1/Conversations', client
41
- expect(conversations.completed.instance_variable_get('@instance_class')).to eq(Twilio::REST::Conversations::Conversation)
42
- end
43
- end
44
-
45
- describe Twilio::REST::Conversations::Conversation do
46
- it 'has correct path when fetched from /InProgress' do
47
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
48
- conversation = client.conversations.in_progress.get('CA123')
49
- expect(conversation.instance_variable_get('@path')).to eq('/v1/Conversations/CA123')
50
- end
51
- it 'has correct path when fetched from /Completed' do
52
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
53
- conversation = client.conversations.completed.get('CA123')
54
- expect(conversation.instance_variable_get('@path')).to eq('/v1/Conversations/CA123')
55
- end
56
- it 'sets up participants subresource' do
57
- client = Twilio::REST::ConversationsClient.new 'otherSid', 'otherToken'
58
- conversation = Twilio::REST::Conversations::Conversation.new '/v1/Conversations/CA123', client
59
- expect(conversation).to respond_to(:participants)
60
- end
61
- end
@@ -1,13 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Twilio::REST::ConversationsClient do
4
- before do
5
- @client = Twilio::REST::ConversationsClient.new('AC123', 'foobar')
6
- end
7
-
8
- it 'should set up an conversations resources object' do
9
- expect(@client).to respond_to(:conversations)
10
- expect(@client.conversations.instance_variable_get('@path')).to eq('/v1/Conversations')
11
- end
12
-
13
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Twilio::REST::IpMessaging::Channels do
4
- it 'sets up a members resources object' do
5
- client = Twilio::REST::IpMessagingClient.new 'otherSid', 'otherToken'
6
- service = Twilio::REST::IpMessaging::Channel.new '/v1/Services/1/Channels/1', client
7
- expect(service).to respond_to(:members)
8
- expect(service.members.instance_variable_get('@path')).to eq(
9
- '/v1/Services/1/Channels/1/Members'
10
- )
11
- end
12
-
13
- it 'sets up a messages resources object' do
14
- client = Twilio::REST::IpMessagingClient.new 'otherSid', 'otherToken'
15
- service = Twilio::REST::IpMessaging::Channel.new '/v1/Services/1/Channels/1', client
16
- expect(service).to respond_to(:messages)
17
- expect(service.messages.instance_variable_get('@path')).to eq(
18
- '/v1/Services/1/Channels/1/Messages'
19
- )
20
- end
21
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Twilio::REST::IpMessaging::Services do
4
- it 'sets up a channels resources object' do
5
- client = Twilio::REST::IpMessagingClient.new 'otherSid', 'otherToken'
6
- service = Twilio::REST::IpMessaging::Service.new '/v1/Services', client
7
- expect(service).to respond_to(:channels)
8
- expect(service.channels.instance_variable_get('@path')).to eq(
9
- '/v1/Services/Channels'
10
- )
11
- end
12
-
13
- it 'sets up a roles resources object' do
14
- client = Twilio::REST::IpMessagingClient.new 'otherSid', 'otherToken'
15
- service = Twilio::REST::IpMessaging::Service.new '/v1/Services', client
16
- expect(service).to respond_to(:roles)
17
- expect(service.roles.instance_variable_get('@path')).to eq(
18
- '/v1/Services/Roles'
19
- )
20
- end
21
-
22
- it 'sets up a users resources object' do
23
- client = Twilio::REST::IpMessagingClient.new 'otherSid', 'otherToken'
24
- service = Twilio::REST::IpMessaging::Service.new '/v1/Services', client
25
- expect(service).to respond_to(:users)
26
- expect(service.users.instance_variable_get('@path')).to eq(
27
- '/v1/Services/Users'
28
- )
29
- end
30
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Twilio::REST::IpMessagingClient do
4
- before do
5
- @client = Twilio::REST::IpMessagingClient.new('AC123', 'foobar')
6
- end
7
-
8
- it 'should set up a services resources object' do
9
- expect(@client).to respond_to(:services)
10
- expect(@client.services.instance_variable_get('@path')).to eq(
11
- '/v1/Services'
12
- )
13
- end
14
-
15
- it 'should set up a credentials resources object' do
16
- expect(@client).to respond_to(:credentials)
17
- expect(@client.credentials.instance_variable_get('@path')).to eq(
18
- '/v1/Credentials'
19
- )
20
- end
21
- end