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.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/vonage/voice.rb', line 74 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
279 280 281 |
# File 'lib/vonage/voice.rb', line 279 def dtmf @dtmf ||= DTMF.new(@config) end |
#earmuff(id) ⇒ Response
Earmuff an in progress call.
225 226 227 |
# File 'lib/vonage/voice.rb', line 225 def earmuff(id) update(id, action: 'earmuff') end |
#get(id) ⇒ Response
Get detail of a specific call.
144 145 146 |
# File 'lib/vonage/voice.rb', line 144 def get(id) request('/v1/calls/' + id) end |
#hangup(id) ⇒ Response
Hangup an in progress call.
180 181 182 |
# File 'lib/vonage/voice.rb', line 180 def hangup(id) update(id, action: 'hangup') end |
#list(params = nil, auto_advance = true) ⇒ ListResponse
Get details of your calls.
125 126 127 128 129 130 131 |
# File 'lib/vonage/voice.rb', line 125 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.
195 196 197 |
# File 'lib/vonage/voice.rb', line 195 def mute(id) update(id, action: 'mute') end |
#stream ⇒ Stream
267 268 269 |
# File 'lib/vonage/voice.rb', line 267 def stream @stream ||= Stream.new(@config) end |
#talk ⇒ Talk
273 274 275 |
# File 'lib/vonage/voice.rb', line 273 def talk @talk ||= Talk.new(@config) end |
#transfer(id, destination:) ⇒ Response
Transfer an in progress call.
261 262 263 |
# File 'lib/vonage/voice.rb', line 261 def transfer(id, destination:) update(id, action: 'transfer', destination: destination) end |
#unearmuff(id) ⇒ Response
Unearmuff an in progress call.
240 241 242 |
# File 'lib/vonage/voice.rb', line 240 def unearmuff(id) update(id, action: 'unearmuff') end |
#unmute(id) ⇒ Response
Unmute an in progress call.
210 211 212 |
# File 'lib/vonage/voice.rb', line 210 def unmute(id) update(id, action: 'unmute') end |
#update(id, params) ⇒ Response
Modify an in progress call.
165 166 167 |
# File 'lib/vonage/voice.rb', line 165 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.
290 291 292 |
# File 'lib/vonage/voice.rb', line 290 def verify_webhook_token(token:, signature_secret: @config.signature_secret) JWT.verify_hs256_signature(token: token, signature_secret: signature_secret) end |