twilio-ruby 3.7.1 → 3.8.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/README.md CHANGED
@@ -50,7 +50,7 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
50
50
  @call = @client.account.calls.create(
51
51
  :from => '+14159341234',
52
52
  :to => '+18004567890',
53
- :url => 'http://myapp.com/call-handler'
53
+ :url => 'http://example.com/call-handler'
54
54
  )
55
55
 
56
56
  # hangup a ringing call, but don't touch it if it's connected
@@ -60,7 +60,7 @@ auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
60
60
  @call = @client.account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662')
61
61
 
62
62
  # redirect an in-progress call
63
- @call.redirect_to('http://myapp.com/call-redirect')
63
+ @call.redirect_to('http://example.com/call-redirect')
64
64
 
65
65
  # hangup a call, no matter whether it is ringing or connected
66
66
  @call.hangup
data/examples/examples.rb CHANGED
@@ -32,7 +32,7 @@ end
32
32
  @account.calls.get('CAXXXXXXX').recordings.list.each do {|r| puts r.wav}
33
33
 
34
34
  # make a new outgoing call. returns a call object just like calls.get
35
- @call = @account.calls.create({:from => '+14159341234', :to => '+18004567890', :url => 'http://myapp.com/call-handler'})
35
+ @call = @account.calls.create({:from => '+14159341234', :to => '+18004567890', :url => 'http://example.com/call-handler'})
36
36
 
37
37
  # cancel the call if not already in progress
38
38
  @account.calls.get(@call.sid).update({:status => 'canceled'})
@@ -42,10 +42,10 @@ end
42
42
  @call.cancel
43
43
 
44
44
  # redirect and then terminate a call
45
- @account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662').update({:url => 'http://myapp.com/call-redirect'})
45
+ @account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662').update({:url => 'http://example.com/call-redirect'})
46
46
  @account.calls.get('CA386025c9bf5d6052a1d1ea42b4d16662').update({:status => 'completed'})
47
47
  # or, use the aliases...
48
- @call.redirect_to('http://myapp.com/call-redirect')
48
+ @call.redirect_to('http://example.com/call-redirect')
49
49
  @call.hangup
50
50
 
51
51
  ################ SMS MESSAGES ################
@@ -74,7 +74,7 @@ puts @account.sms.messages.get('SMXXXXXXXX').body
74
74
  @account.incoming_phone_numbers.create(:phone_number => @numbers[0].phone_number)
75
75
 
76
76
  # update an existing phone number's voice url
77
- @account.incoming_phone_numbers.get('PNdba508c5616a7f5e141789f44f022cc3').update({:voice_url => 'http://myapp.com/voice'})
77
+ @account.incoming_phone_numbers.get('PNdba508c5616a7f5e141789f44f022cc3').update({:voice_url => 'http://example.com/voice'})
78
78
 
79
79
  ################ CONFERENCES ################
80
80
 
@@ -91,3 +91,24 @@ puts @account.sms.messages.get('SMXXXXXXXX').body
91
91
 
92
92
  # and, since we're lazy loading, this would only incur one http request
93
93
  @account.conferences.get('CFbbe46ff1274e283f7e3ac1df0072ab39').participants.get('CA386025c9bf5d6052a1d1ea42b4d16662').update({:muted => 'true'})
94
+
95
+ ################ QUEUES ###################
96
+
97
+ # create a new queue
98
+ @queue = @account.queues.create(:friendly_name => 'MyQueue', :max_size => 50)
99
+
100
+ # get a list of queues for this account
101
+ @queues = @account.queues.list
102
+
103
+ # get a particular queue and its members
104
+ @queue = @account.queues.get("QQb6765b0458714964970a73dcaf55efd1")
105
+ @members = @queue.members
106
+
107
+ #list members
108
+ @members.list.each do |m|
109
+ puts m.wait_time
110
+ end
111
+
112
+ # dequeue a particular user and run twiml at a specific url
113
+ @member = @members.get('CA386025c9bf5d6052a1d1ea42b4d16662')
114
+ @member.dequeue('http://myapp.com/deque')
data/lib/twilio-ruby.rb CHANGED
@@ -33,6 +33,8 @@ require 'twilio-ruby/rest/available_phone_numbers/local'
33
33
  require 'twilio-ruby/rest/available_phone_numbers/toll_free'
34
34
  require 'twilio-ruby/rest/conferences'
35
35
  require 'twilio-ruby/rest/conferences/participants'
36
+ require 'twilio-ruby/rest/queues'
37
+ require 'twilio-ruby/rest/queues/members'
36
38
  require 'twilio-ruby/rest/recordings'
37
39
  require 'twilio-ruby/rest/transcriptions'
38
40
  require 'twilio-ruby/rest/notifications'
@@ -8,7 +8,7 @@ module Twilio
8
8
  resource :sandbox, :available_phone_numbers, :incoming_phone_numbers,
9
9
  :calls, :outgoing_caller_ids, :conferences, :sms, :recordings,
10
10
  :transcriptions, :notifications, :applications, :connect_apps,
11
- :authorized_connect_apps
11
+ :authorized_connect_apps, :queues
12
12
  end
13
13
  end
14
14
  end
@@ -216,6 +216,7 @@ module Twilio
216
216
  raise Twilio::REST::ServerError
217
217
  end
218
218
  rescue Exception
219
+ raise if request.class == Net::HTTP::Post
219
220
  if retries_left > 0 then retries_left -= 1; retry else raise end
220
221
  end
221
222
  if response.body and !response.body.empty?
@@ -0,0 +1,12 @@
1
+ module Twilio
2
+ module REST
3
+ class Queues < ListResource; end
4
+
5
+ class Queue < InstanceResource
6
+ def initialize(uri, client, params={})
7
+ super uri, client, params
8
+ resource :members
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,29 @@
1
+ module Twilio
2
+ module REST
3
+ class Members < ListResource
4
+ def initialize(uri, client)
5
+ super
6
+ # hard-code the json keys since members are special
7
+ @list_key, @instance_id_key = 'queue_members', 'call_sid'
8
+ end
9
+
10
+ def front
11
+ @instance_class.new "#{@uri}/Front", @client
12
+ end
13
+
14
+ def front!
15
+ front.refresh
16
+ end
17
+
18
+ def dequeue(url, method='POST')
19
+ front.dequeue url, method
20
+ end
21
+ end
22
+
23
+ class Member < InstanceResource
24
+ def dequeue(url, method='POST')
25
+ update :url => url, :method => method
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Twilio
2
- VERSION = '3.7.1'
2
+ VERSION = '3.8.0'
3
3
  end
@@ -31,6 +31,12 @@ describe Twilio::REST::Account do
31
31
  account.conferences.instance_variable_get('@uri').should == 'someUri/Conferences'
32
32
  end
33
33
 
34
+ it 'should set up a queues resources object' do
35
+ account = Twilio::REST::Account.new('someUri', 'someClient')
36
+ account.respond_to?(:queues).should == true
37
+ account.queues.instance_variable_get('@uri').should == 'someUri/Queues'
38
+ end
39
+
34
40
  it 'should set up a sms resource object' do
35
41
  account = Twilio::REST::Account.new('someUri', 'someClient')
36
42
  account.respond_to?(:sms).should == true
@@ -54,4 +60,4 @@ describe Twilio::REST::Account do
54
60
  account.respond_to?(:notifications).should == true
55
61
  account.notifications.instance_variable_get('@uri').should == 'someUri/Notifications'
56
62
  end
57
- end
63
+ end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Twilio::REST::Conference do
4
4
  it 'should set up a participants resources object' do
5
- call = Twilio::REST::Conference.new('someUri', 'someClient')
6
- call.respond_to?(:participants).should == true
7
- call.participants.instance_variable_get('@uri').should == 'someUri/Participants'
5
+ conference = Twilio::REST::Conference.new('someUri', 'someClient')
6
+ conference.respond_to?(:participants).should == true
7
+ conference.participants.instance_variable_get('@uri').should == 'someUri/Participants'
8
8
  end
9
- end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe Twilio::REST::Queue do
4
+ it 'should set up a members resources object' do
5
+ queue = Twilio::REST::Queue.new('someUri', 'someClient')
6
+ queue.respond_to?(:members).should == true
7
+ queue.members.instance_variable_get('@uri').should == 'someUri/Members'
8
+ end
9
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twilio-ruby
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 39
5
5
  prerelease:
6
6
  segments:
7
7
  - 3
8
- - 7
9
- - 1
10
- version: 3.7.1
8
+ - 8
9
+ - 0
10
+ version: 3.8.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Benton
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-01 00:00:00 -07:00
18
+ date: 2012-08-09 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -168,6 +168,8 @@ files:
168
168
  - lib/twilio-ruby/rest/list_resource.rb
169
169
  - lib/twilio-ruby/rest/notifications.rb
170
170
  - lib/twilio-ruby/rest/outgoing_caller_ids.rb
171
+ - lib/twilio-ruby/rest/queues.rb
172
+ - lib/twilio-ruby/rest/queues/members.rb
171
173
  - lib/twilio-ruby/rest/recordings.rb
172
174
  - lib/twilio-ruby/rest/sandbox.rb
173
175
  - lib/twilio-ruby/rest/sms.rb
@@ -185,6 +187,7 @@ files:
185
187
  - spec/rest/client_spec.rb
186
188
  - spec/rest/conference_spec.rb
187
189
  - spec/rest/instance_resource_spec.rb
190
+ - spec/rest/queue_spec.rb
188
191
  - spec/rest/recording_spec.rb
189
192
  - spec/spec_helper.rb
190
193
  - spec/util/capability_spec.rb
@@ -231,6 +234,7 @@ specification_version: 3
231
234
  summary: A simple library for communicating with the Twilio REST API, building TwiML, and generating Twilio Client Capability Tokens
232
235
  test_files:
233
236
  - spec/spec_helper.rb
237
+ - spec/rest/queue_spec.rb
234
238
  - spec/rest/call_spec.rb
235
239
  - spec/rest/conference_spec.rb
236
240
  - spec/rest/account_spec.rb