Class: Vonage::Voice
- Inherits:
-
Namespace
- Object
- Namespace
- Vonage::Voice
- Defined in:
- lib/vonage/voice.rb
Defined Under Namespace
Classes: DTMF, ListResponse, Ncco, Stream, Talk
Instance Method Summary collapse
-
#create(params) ⇒ Response
Create an outbound Call.
- #dtmf ⇒ DTMF
-
#earmuff(id) ⇒ Response
Earmuff an in progress call.
-
#get(id) ⇒ Response
Get detail of a specific call.
-
#hangup(id) ⇒ Response
Hangup an in progress call.
-
#list(params = nil, auto_advance = true) ⇒ ListResponse
Get details of your calls.
-
#mute(id) ⇒ Response
Mute an in progress call.
- #stream ⇒ Stream
- #talk ⇒ Talk
-
#transfer(id, destination:) ⇒ Response
Transfer an in progress call.
-
#unearmuff(id) ⇒ Response
Unearmuff an in progress call.
-
#unmute(id) ⇒ Response
Unmute an in progress call.
-
#update(id, params) ⇒ Response
Modify an in progress call.
-
#verify_webhook_token(token:, signature_secret: @config.signature_secret) ⇒ Boolean
Validate a JSON Web Token from a Voice API Webhook.
Instance Method Details
#create(params) ⇒ Response
Create an outbound Call.
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vonage/voice.rb', line 76 def create(params) if params.key?(:from) && params[:random_from_number] == true raise ClientError.new("`from` should not be set if `random_from_number` is `true`") end if params && !params.key?(:from) params.merge!(random_from_number: true) end request('/v1/calls', params: params, type: Post) end |
#dtmf ⇒ DTMF
281 282 283 |
# File 'lib/vonage/voice.rb', line 281 def dtmf @dtmf ||= DTMF.new(@config) end |
#earmuff(id) ⇒ Response
Earmuff an in progress call.
227 228 229 |
# File 'lib/vonage/voice.rb', line 227 def earmuff(id) update(id, action: 'earmuff') end |
#get(id) ⇒ Response
Get detail of a specific call.
146 147 148 |
# File 'lib/vonage/voice.rb', line 146 def get(id) request('/v1/calls/' + id) end |
#hangup(id) ⇒ Response
Hangup an in progress call.
182 183 184 |
# File 'lib/vonage/voice.rb', line 182 def hangup(id) update(id, action: 'hangup') end |
#list(params = nil, auto_advance = true) ⇒ ListResponse
Get details of your calls.
127 128 129 130 131 132 133 |
# File 'lib/vonage/voice.rb', line 127 def list(params = nil, auto_advance = true) if params && !params.key?(:auto_advance) params.merge!(auto_advance: true) end request('/v1/calls', params: params, response_class: ListResponse) end |
#mute(id) ⇒ Response
Mute an in progress call.
197 198 199 |
# File 'lib/vonage/voice.rb', line 197 def mute(id) update(id, action: 'mute') end |
#stream ⇒ Stream
269 270 271 |
# File 'lib/vonage/voice.rb', line 269 def stream @stream ||= Stream.new(@config) end |
#talk ⇒ Talk
275 276 277 |
# File 'lib/vonage/voice.rb', line 275 def talk @talk ||= Talk.new(@config) end |
#transfer(id, destination:) ⇒ Response
Transfer an in progress call.
263 264 265 |
# File 'lib/vonage/voice.rb', line 263 def transfer(id, destination:) update(id, action: 'transfer', destination: destination) end |
#unearmuff(id) ⇒ Response
Unearmuff an in progress call.
242 243 244 |
# File 'lib/vonage/voice.rb', line 242 def unearmuff(id) update(id, action: 'unearmuff') end |
#unmute(id) ⇒ Response
Unmute an in progress call.
212 213 214 |
# File 'lib/vonage/voice.rb', line 212 def unmute(id) update(id, action: 'unmute') end |
#update(id, params) ⇒ Response
Modify an in progress call.
167 168 169 |
# File 'lib/vonage/voice.rb', line 167 def update(id, params) request('/v1/calls/' + id, params: params, type: Put) end |
#verify_webhook_token(token:, signature_secret: @config.signature_secret) ⇒ Boolean
Validate a JSON Web Token from a Voice API Webhook.
292 293 294 |
# File 'lib/vonage/voice.rb', line 292 def verify_webhook_token(token:, signature_secret: @config.signature_secret) JWT.verify_hs256_signature(token: token, signature_secret: signature_secret) end |