telapi 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Telapi::Ruby
1
+ # TelAPI Ruby Gem
2
2
 
3
3
  See www.telapi.com to signup for TelAPI.
4
4
 
@@ -153,6 +153,10 @@ Refer to the documentation for more examples.
153
153
  )
154
154
  end
155
155
 
156
+ ## Compatibility
157
+
158
+ Currently targeted for Ruby 1.9.
159
+
156
160
  ## Contributing
157
161
 
158
162
  1. Fork it
@@ -18,6 +18,7 @@ require 'telapi/fraud'
18
18
  require 'telapi/incoming_phone_number'
19
19
  require 'telapi/message'
20
20
  require 'telapi/notification'
21
+ require 'telapi/participant'
21
22
  require 'telapi/recording'
22
23
  require 'telapi/transcription'
23
24
 
@@ -7,9 +7,10 @@ module Telapi
7
7
  # See http://www.telapi.com/docs/api/rest/conferences/list/
8
8
  #
9
9
  # Optional params is a hash containing:
10
- # +MemberID+:: string
11
- # +Muted+:: true or false
12
- # +Deafed+:: true or false
10
+ # +FriendlyName+:: string
11
+ # +Status+:: init, in-progress, or completed
12
+ # +DateCreate+:: date in the following format: YYYY-MM-DD
13
+ # +DateUpdated+:: date in the following format: YYYY-MM-DD
13
14
  # +Page+:: integer greater than 0
14
15
  # +PageSize+:: integer greater than 0
15
16
  def list(optional_params = {})
@@ -21,185 +22,49 @@ module Telapi
21
22
  # See http://www.telapi.com/docs/api/rest/conferences/view/
22
23
  #
23
24
  # Required params:
24
- # +conference_name+:: conference name
25
- #
26
- # Optional params is a hash containing:
27
- # +MemberID+:: string
28
- # +Muted+:: true or (false)
29
- # +Deafed+:: true or (false)
30
- def get(conference_name, optional_params = {})
31
- response = Network.get(['Conferences', conference_name], optional_params)
25
+ # +conference_sid+:: conference identifier
26
+ def get(conference_sid)
27
+ response = Network.get(['Conferences', conference_sid])
32
28
  Conference.new(response)
33
29
  end
34
30
 
35
- # Mute a member of a conference call, returning a Telapi::Conference object
36
- # See http://www.telapi.com/docs/api/rest/conferences/mute/
37
- #
38
- # Required params:
39
- # +conference_name+:: conference name
40
- # +member_id+:: string
41
- def mute_member(conference_name, member_id)
42
- opts = { :MemberID => member_id }
43
- response = Network.post(['Conferences', conference_name, 'Mute'], opts)
44
- Conference.new(response)
45
- end
46
-
47
- # Unmute a member of a conference call, returning a Telapi::Conference object
48
- # See http://www.telapi.com/docs/api/rest/conferences/unmute/
49
- #
31
+ # Returns a resource collection containing Telapi::Participant objects
32
+ # See http://www.telapi.com/docs/api/rest/conferences/list-participants/
50
33
  # Required params:
51
- # +conference_name+:: conference name
52
- # +member_id+:: string
53
- def unmute_member(conference_name, member_id)
54
- opts = { :MemberID => member_id }
55
- response = Network.post(['Conferences', conference_name, 'UnMute'], opts)
56
- Conference.new(response)
57
- end
58
-
59
- # Deaf audio for a specific member of a conference call, returning a Telapi::Conference object
60
- # See http://www.telapi.com/docs/api/rest/conferences/deaf/
61
- #
62
- # Required params:
63
- # +conference_name+:: conference name
64
- # +member_id+:: string
65
- def deaf_member(conference_name, member_id)
66
- opts = { :MemberID => member_id }
67
- response = Network.post(['Conferences', conference_name, 'Deaf'], opts)
68
- Conference.new(response)
69
- end
70
-
71
- # Restore audio for a specific member of a conference call, returning a Telapi::Conference object
72
- # See http://www.telapi.com/docs/api/rest/conferences/undeaf/
34
+ # +conference_sid+:: conference identifier
73
35
  #
74
- # Required params:
75
- # +conference_name+:: conference name
76
- # +member_id+:: string
77
- def undeaf_member(conference_name, member_id)
78
- opts = { :MemberID => member_id }
79
- response = Network.post(['Conferences', conference_name, 'UnDeaf'], opts)
80
- Conference.new(response)
81
- end
82
-
83
- # Hangup a specific member of a conference call, returning a Telapi::Conference object
84
- # See http://www.telapi.com/docs/api/rest/conferences/hangup/
85
- #
86
- # Required params:
87
- # +conference_name+:: conference name
88
- # +member_id+:: string
89
- def hangup_member(conference_name, member_id)
90
- opts = { :MemberID => member_id }
91
- response = Network.post(['Conferences', conference_name, 'Hangup'], opts)
92
- Conference.new(response)
93
- end
94
-
95
- # Remove a specific member of a conference call, returning a Telapi::Conference object
96
- # See http://www.telapi.com/docs/api/rest/conferences/kick/
97
- #
98
- # Required params:
99
- # +conference_name+:: conference name
100
- # +member_id+:: string
101
- def kick_member(conference_name, member_id)
102
- opts = { :MemberID => member_id }
103
- response = Network.post(['Conferences', conference_name, 'Kick'], opts)
104
- Conference.new(response)
105
- end
106
-
107
- # Send message that will be read in an audible voice to conference members, returning a Telapi::Conference object
108
- # See http://www.telapi.com/docs/api/rest/conferences/speak-text/
109
- #
110
- # Required params:
111
- # +conference_name+:: conference name
112
- # +member_id+:: string
113
- # +text+:: string
114
- def speak_text(conference_name, member_id, text)
115
- opts = { :MemberID => member_id, :Text => text }
116
- response = Network.post(['Conferences', conference_name, 'Say'], opts)
117
- Conference.new(response)
118
- end
119
-
120
- # Play pre-recorded sound from a file to conference members, returning a Telapi::Conference object
121
- # See http://www.telapi.com/docs/api/rest/conferences/play-audio/
122
- #
123
- # Required params:
124
- # +conference_name+:: conference name
125
- # +member_id+:: string
126
- # +sound_url+:: valid URL
127
- def play_audio(conference_name, member_id, sound_url)
128
- opts = { :MemberID => member_id, :Url => sound_url }
129
- response = Network.post(['Conferences', conference_name, 'Play'], opts)
130
- Conference.new(response)
131
- end
132
-
133
- # Record conference, returning a Telapi::Conference object
134
- # See http://www.telapi.com/docs/api/rest/conferences/start-recording/
135
- #
136
- # Required params:
137
- # +conference_name+:: conference name
138
- def start_recording(conference_name)
139
- response = Network.post(['Conferences', conference_name, 'RecordStart'])
140
- Conference.new(response)
36
+ # Optional params:
37
+ # +Muted+:: true or (false)
38
+ # +Deaf+:: true or (false)
39
+ # +Page+:: integer greater than 0
40
+ # +PageSize+:: integer greater than 0
41
+ def participants(conference_sid, optional_params = {})
42
+ response = Network.get(['Conferences', conference_sid, 'Participants'], optional_params)
43
+ ResourceCollection.new(response, 'participants', Participant)
141
44
  end
142
45
 
143
- # End recording of conference, returning a Telapi::Conference object
144
- # See http://www.telapi.com/docs/api/rest/conferences/stop-recording/
145
- #
46
+ # Returns a Telapi::Participant object
47
+ # See http://www.telapi.com/docs/api/rest/conferences/view-participant/
146
48
  # Required params:
147
- # +conference_name+:: conference name
148
- def stop_recording(conference_name)
149
- response = Network.post(['Conferences', conference_name, 'RecordStop'])
150
- Conference.new(response)
49
+ # +conference_sid+:: conference identifier
50
+ # +call_sid+:: call identifier
51
+ def participant(conference_sid, call_sid)
52
+ response = Network.get(['Conferences', conference_sid, 'Participants', call_sid])
53
+ Participant.new(response)
151
54
  end
152
55
 
153
56
  end
154
57
 
155
- # See ::mute_member
156
- def mute_member(member_id)
157
- self.class.mute_member(self.name, member_id)
158
- end
159
-
160
- # See ::unmute_member
161
- def unmute_member(member_id)
162
- self.class.unmute_member(self.name, member_id)
163
- end
164
-
165
- # See ::deaf_member
166
- def deaf_member(member_id)
167
- self.class.deaf_member(self.name, member_id)
168
- end
169
-
170
- # See ::undeaf_member
171
- def undeaf_member(member_id)
172
- self.class.undeaf_member(self.name, member_id)
173
- end
174
-
175
- # See ::hangup_member
176
- def hangup_member(member_id)
177
- self.class.hangup_member(self.name, member_id)
178
- end
179
-
180
- # See ::kick_member
181
- def kick_member(member_id)
182
- self.class.kick_member(self.name, member_id)
183
- end
184
-
185
- # See ::speak_text
186
- def speak_text(member_id, text)
187
- self.class.speak_text(self.name, member_id, text)
188
- end
189
-
190
- # See ::play_audio
191
- def play_audio(member_id, sound_url)
192
- self.class.play_audio(self.name, member_id, sound_url)
193
- end
194
-
195
- # See ::start_recording
196
- def start_recording
197
- self.class.start_recording(self.name)
58
+ # See ::participants
59
+ def participants(optional_params = {})
60
+ self.class.participants(self.sid, optional_params)
198
61
  end
199
62
 
200
- # See ::stop_recording
201
- def stop_recording
202
- self.class.stop_recording(self.name)
63
+ # See ::participant
64
+ # Required params:
65
+ # +call_sid+:: call (participant) identifier
66
+ def participant(call_sid)
67
+ self.class.participant(self.sid, call_sid)
203
68
  end
204
69
 
205
70
  end
@@ -0,0 +1,64 @@
1
+ module Telapi
2
+ # A Participant is always generated via Conferences but
3
+ # this class also provides some convenience methods to access
4
+ # them directly, thereby reducing API calls.
5
+ class Participant < Resource
6
+ class << self
7
+ # Convenient alternative to Conference::participants
8
+ def list(conference_sid, optional_params = {})
9
+ Conference.participants(conference_sid, optional_params)
10
+ end
11
+
12
+ # Convenient alternative to Conference::participant
13
+ def get(conference_sid, call_sid)
14
+ Conference.participant(conference_sid, call_sid)
15
+ end
16
+ end
17
+
18
+ # Deaf a participant of a conference call, returning a Telapi::Participant object
19
+ # See http://www.telapi.com/docs/api/rest/conferences/deaf-or-mute/
20
+ def deaf
21
+ response = Network.post(['Conferences', self.conference_sid, 'Participant', self.call_sid], { :Deaf => true })
22
+ Participant.new(response)
23
+ end
24
+
25
+ # Undeaf a participant of a conference call, returning a Telapi::Participant object
26
+ # See http://www.telapi.com/docs/api/rest/conferences/deaf-or-mute/
27
+ def undeaf
28
+ response = Network.post(['Conferences', self.conference_sid, 'Participant', self.call_sid], { :Deaf => false })
29
+ Participant.new(response)
30
+ end
31
+
32
+ # Mute a participant of a conference call, returning a Telapi::Participant object
33
+ # See http://www.telapi.com/docs/api/rest/conferences/deaf-or-mute/
34
+ def mute
35
+ response = Network.post(['Conferences', self.conference_sid, 'Participant', self.call_sid], { :Muted => true })
36
+ Participant.new(response)
37
+ end
38
+
39
+ # Unmute a participant of a conference call, returning a Telapi::Participant object
40
+ # See http://www.telapi.com/docs/api/rest/conferences/deaf-or-mute/
41
+ def unmute
42
+ response = Network.post(['Conferences', self.conference_sid, 'Participant', self.call_sid], { :Muted => false })
43
+ Participant.new(response)
44
+ end
45
+
46
+ # Hangup a participant of a conference call, returning a Telapi::Participant object
47
+ # See http://www.telapi.com/docs/api/rest/conferences/hangup-participant/
48
+ def hangup
49
+ response = Network.delete(['Conferences', self.conference_sid, 'Participant', self.call_sid])
50
+ Participant.new(response)
51
+ end
52
+
53
+ # Play pre-recorded sound from a file to conference members, returning a Telapi::Participant object
54
+ # See http://www.telapi.com/docs/api/rest/conferences/play-audio/
55
+ #
56
+ # Required params:
57
+ # +sound_url+:: URL containing an audio file
58
+ def play_audio(sound_url = 'http://www.telapi.com/audio.mp3')
59
+ response = Network.post(['Conferences', self.conference_sid, 'Participant', self.call_sid], { :AudioUrl => sound_url })
60
+ Participant.new(response)
61
+ end
62
+
63
+ end
64
+ end
@@ -1,3 +1,3 @@
1
1
  module Telapi
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -17,7 +17,7 @@ describe Telapi::Conference do
17
17
  end
18
18
 
19
19
  context "when conferences exist" do
20
- before { stub_telapi_request('{ "conferences": [{ "name": "TelAPIChat" }] }') }
20
+ before { stub_telapi_request('{ "conferences": [{ "friendly_name": "testing" }] }') }
21
21
 
22
22
  it "has a collection of Conference objects" do
23
23
  klass.list.first.should be_a(klass)
@@ -32,143 +32,41 @@ describe Telapi::Conference do
32
32
  end
33
33
  end
34
34
 
35
- describe ".mute_member" do
36
- it "calls api via http post and returns a Conference resource" do
37
- api_should_use(:post)
38
- klass.mute_member('abc123', '123').should be_a(klass)
39
- end
40
- end
41
-
42
- describe "#mute_member" do
43
- it "proxies to Conference.mute_member" do
44
- klass.should_receive(:mute_member)
45
- klass.get('abc123').mute_member('123')
46
- end
47
- end
48
-
49
- describe ".unmute_member" do
50
- it "calls api via http post and returns a Conference resource" do
51
- api_should_use(:post)
52
- klass.unmute_member('abc123', '123').should be_a(klass)
53
- end
54
- end
55
-
56
- describe "#unmute_member" do
57
- it "proxies to Conference.unmute_member" do
58
- klass.should_receive(:unmute_member)
59
- klass.get('abc123').unmute_member('123')
60
- end
61
- end
62
-
63
- describe ".deaf_member" do
64
- it "calls api via http post and returns a Conference resource" do
65
- api_should_use(:post)
66
- klass.deaf_member('abc123', '123').should be_a(klass)
67
- end
68
- end
69
-
70
- describe "#deaf_member" do
71
- it "proxies to Conference.deaf_member" do
72
- klass.should_receive(:deaf_member)
73
- klass.get('abc123').deaf_member('123')
74
- end
75
- end
76
-
77
- describe ".undeaf_member" do
78
- it "calls api via http post and returns a Conference resource" do
79
- api_should_use(:post)
80
- klass.undeaf_member('abc123', '123').should be_a(klass)
81
- end
82
- end
83
-
84
- describe "#undeaf_member" do
85
- it "proxies to Conference.undeaf_member" do
86
- klass.should_receive(:undeaf_member)
87
- klass.get('abc123').undeaf_member('123')
88
- end
89
- end
90
-
91
- describe ".hangup_member" do
92
- it "calls api via http post and returns a Conference resource" do
93
- api_should_use(:post)
94
- klass.hangup_member('abc123', '123').should be_a(klass)
95
- end
96
- end
97
-
98
- describe "#hangup_member" do
99
- it "proxies to Conference.hangup_member" do
100
- klass.should_receive(:hangup_member)
101
- klass.get('abc123').hangup_member('123')
102
- end
103
- end
104
-
105
- describe ".kick_member" do
106
- it "calls api via http post and returns a Conference resource" do
107
- api_should_use(:post)
108
- klass.kick_member('abc123', '123').should be_a(klass)
109
- end
110
- end
111
-
112
- describe "#kick_member" do
113
- it "proxies to Conference.kick_member" do
114
- klass.should_receive(:kick_member)
115
- klass.get('abc123').kick_member('123')
116
- end
117
- end
118
-
119
- describe ".speak_text" do
120
- it "calls api via http post and returns a Conference resource" do
121
- api_should_use(:post)
122
- klass.speak_text('abc123', '123', 'hi').should be_a(klass)
123
- end
124
- end
125
-
126
- describe "#speak_text" do
127
- it "proxies to Conference.speak_text" do
128
- klass.should_receive(:speak_text)
129
- klass.get('abc123').speak_text('123', 'hi')
130
- end
131
- end
35
+ describe ".participants" do
36
+ before { stub_telapi_request('{ "participants": [] }') }
132
37
 
133
- describe ".play_audio" do
134
- it "calls api via http post and returns a Conference resource" do
135
- api_should_use(:post)
136
- klass.play_audio('abc123', '123', 'http://url').should be_a(klass)
38
+ it "calls api via http get and returns a ResourceCollection" do
39
+ api_should_use(:get)
40
+ klass.participants('abc123').should be_a(Telapi::ResourceCollection)
137
41
  end
138
- end
139
42
 
140
- describe "#play_audio" do
141
- it "proxies to Conference.play_audio" do
142
- klass.should_receive(:play_audio)
143
- klass.get('abc123').play_audio('123', 'http://url')
144
- end
145
- end
43
+ context "when Participants exist" do
44
+ before { stub_telapi_request('{ "participants": [{ "duration": "6" }] }') }
146
45
 
147
- describe ".start_recording" do
148
- it "calls api via http post and returns a Conference resource" do
149
- api_should_use(:post)
150
- klass.start_recording('abc123').should be_a(klass)
46
+ it "has a collection of Participant objects" do
47
+ klass.participants('abc123').first.should be_a(Telapi::Participant)
48
+ end
151
49
  end
152
50
  end
153
51
 
154
- describe "#start_recording" do
155
- it "proxies to Conference.start_recording" do
156
- klass.should_receive(:start_recording)
157
- klass.get('abc123').start_recording
52
+ describe "#participants" do
53
+ it "proxies to Conference.participants" do
54
+ klass.should_receive(:participants)
55
+ klass.get('abc123').participants
158
56
  end
159
57
  end
160
58
 
161
- describe ".stop_recording" do
162
- it "calls api via http post and returns a Conference resource" do
163
- api_should_use(:post)
164
- klass.stop_recording('abc123').should be_a(klass)
59
+ describe ".participant" do
60
+ it "calls api via http get and returns a Participant" do
61
+ api_should_use(:get)
62
+ klass.participant('abc123', '123').should be_a(Telapi::Participant)
165
63
  end
166
64
  end
167
65
 
168
- describe "#stop_recording" do
169
- it "proxies to Conference.stop_recording" do
170
- klass.should_receive(:stop_recording)
171
- klass.get('abc123').stop_recording
66
+ describe "#participant" do
67
+ it "proxies to Conference.participant" do
68
+ klass.should_receive(:participant)
69
+ klass.get('abc123').participant('123')
172
70
  end
173
71
  end
174
72
  end
@@ -0,0 +1,68 @@
1
+ require 'spec_helper'
2
+
3
+ describe Telapi::Participant do
4
+ before do
5
+ stub_telapi_request
6
+ set_account_sid_and_auth_token
7
+ end
8
+
9
+ it { should be_kind_of(Telapi::Participant) }
10
+
11
+ describe ".list" do
12
+ it "proxies to Conference.participants" do
13
+ Telapi::Conference.should_receive(:participants).with('abc123', {})
14
+ klass.list('abc123')
15
+ end
16
+ end
17
+
18
+ describe ".get" do
19
+ it "proxies to Conference.participant" do
20
+ Telapi::Conference.should_receive(:participant).with('abc123', '123')
21
+ klass.get('abc123', '123')
22
+ end
23
+ end
24
+
25
+ let(:participant) { klass.get('abc123', '123') }
26
+
27
+ describe "#deaf" do
28
+ it "calls api via http post and returns a Participant resource" do
29
+ api_should_use(:post)
30
+ participant.deaf.should be_a(klass)
31
+ end
32
+ end
33
+
34
+ describe "#undeaf" do
35
+ it "calls api via http post and returns a Participant resource" do
36
+ api_should_use(:post)
37
+ participant.undeaf.should be_a(klass)
38
+ end
39
+ end
40
+
41
+ describe "#mute" do
42
+ it "calls api via http post and returns a Participant resource" do
43
+ api_should_use(:post)
44
+ participant.mute.should be_a(klass)
45
+ end
46
+ end
47
+
48
+ describe "#unmute" do
49
+ it "calls api via http post and returns a Participant resource" do
50
+ api_should_use(:post)
51
+ participant.unmute.should be_a(klass)
52
+ end
53
+ end
54
+
55
+ describe "#hangup" do
56
+ it "calls api via http delete and returns a Participant resource" do
57
+ api_should_use(:delete)
58
+ participant.hangup.should be_a(klass)
59
+ end
60
+ end
61
+
62
+ describe "#play_audio" do
63
+ it "calls api via http post and returns a Participant resource" do
64
+ api_should_use(:post)
65
+ participant.play_audio('http://url').should be_a(klass)
66
+ end
67
+ end
68
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-11 00:00:00.000000000 Z
12
+ date: 2012-09-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -152,6 +152,7 @@ files:
152
152
  - lib/telapi/message.rb
153
153
  - lib/telapi/network.rb
154
154
  - lib/telapi/notification.rb
155
+ - lib/telapi/participant.rb
155
156
  - lib/telapi/recording.rb
156
157
  - lib/telapi/resource.rb
157
158
  - lib/telapi/resource_collection.rb
@@ -174,6 +175,7 @@ files:
174
175
  - spec/telapi/message_spec.rb
175
176
  - spec/telapi/network_spec.rb
176
177
  - spec/telapi/notification_spec.rb
178
+ - spec/telapi/participant_spec.rb
177
179
  - spec/telapi/recording_spec.rb
178
180
  - spec/telapi/resource_collection_spec.rb
179
181
  - spec/telapi/resource_spec.rb
@@ -221,6 +223,7 @@ test_files:
221
223
  - spec/telapi/message_spec.rb
222
224
  - spec/telapi/network_spec.rb
223
225
  - spec/telapi/notification_spec.rb
226
+ - spec/telapi/participant_spec.rb
224
227
  - spec/telapi/recording_spec.rb
225
228
  - spec/telapi/resource_collection_spec.rb
226
229
  - spec/telapi/resource_spec.rb