Method: Bandwidth::Voice::APIController#modify_call
- Defined in:
- lib/bandwidth/voice_lib/voice/controllers/api_controller.rb
#modify_call(account_id, call_id, body) ⇒ void
This method returns an undefined value.
Interrupts and replaces an active call’s BXML document.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/bandwidth/voice_lib/voice/controllers/api_controller.rb', line 180 def modify_call(account_id, call_id, body) # Prepare query url. _query_builder = config.get_base_uri(Server::VOICEDEFAULT) _query_builder << '/api/v2/accounts/{accountId}/calls/{callId}' _query_builder = APIHelper.append_url_with_template_parameters( _query_builder, 'accountId' => { 'value' => account_id, 'encode' => false }, 'callId' => { 'value' => call_id, 'encode' => false } ) _query_url = APIHelper.clean_url _query_builder # Prepare headers. _headers = { 'content-type' => 'application/json; charset=utf-8' } # Prepare and execute HttpRequest. _request = config.http_client.post( _query_url, headers: _headers, parameters: body.to_json ) VoiceBasicAuth.apply(config, _request) _response = execute_request(_request) # Validate response against endpoint and global error codes. case _response.status_code when 400 raise ApiErrorException.new( 'Something\'s not quite right... Your request is invalid. Please' \ ' fix it before trying again.', _response ) when 401 raise APIException.new( 'Your credentials are invalid. Please use your Bandwidth dashboard' \ ' credentials to authenticate to the API.', _response ) when 403 raise ApiErrorException.new( 'User unauthorized to perform this action.', _response ) when 404 raise ApiErrorException.new( 'The resource specified cannot be found or does not belong to you.', _response ) when 415 raise ApiErrorException.new( 'We don\'t support that media type. If a request body is required,' \ ' please send it to us as `application/json`.', _response ) when 429 raise ApiErrorException.new( 'You\'re sending requests to this endpoint too frequently. Please' \ ' slow your request rate down and try again.', _response ) when 500 raise ApiErrorException.new( 'Something unexpected happened. Please try again.', _response ) end validate_response(_response) # Return appropriate response type. ApiResponse.new(_response) end |