@@ -225,6 +225,54 @@ def modify_call(self,
225225
226226 # Return appropriate type
227227 return ApiResponse (_response )
228+
229+ def modify_call_bxml (self , account_id , call_id , body ):
230+ """Does a PUT request to /api/v2/accounts/{accountId}/calls/{callId}/bxml.
231+
232+ Interrupts and replaces an active call's BXML document, sending the new BXML.
233+
234+ Args:
235+ account_id (string): Bandwidth Account ID. Ex: "99001234"
236+ call_id (string): ID of the call for which you wish to replace the active BXML instructions.
237+ body (string): XML string in valid BXML format
238+ """
239+
240+ # Prepare query URL
241+ _url_path = '/api/v2/accounts/{accountId}/calls/{callId}/bxml'
242+ _url_path = APIHelper .append_url_with_template_parameters (_url_path , {
243+ 'accountId' : {'value' : account_id , 'encode' : False },
244+ 'callId' : {'value' : call_id , 'encode' : False }
245+ })
246+ _query_builder = self .config .get_base_uri (Server .VOICEDEFAULT )
247+ _query_builder += _url_path
248+ _query_url = APIHelper .clean_url (_query_builder )
249+
250+ # Prepare headers
251+ _headers = {
252+ 'content-type' : 'application/xml; charset=utf-8'
253+ }
254+
255+ # Prepare and execute request
256+ _request = self .config .http_client .put (_query_url , headers = _headers , parameters = body )
257+ VoiceBasicAuth .apply (self .config , _request )
258+ _response = self .execute_request (_request )
259+
260+ # Endpoint and global error handling using HTTP status codes.
261+ if _response .status_code == 400 :
262+ raise ApiErrorException ('Something\' s not quite right... Your request is invalid. Please fix it before trying again.' , _response )
263+ elif _response .status_code == 401 :
264+ raise APIException ('Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API.' , _response )
265+ elif _response .status_code == 403 :
266+ raise ApiErrorException ('User unauthorized to perform this action.' , _response )
267+ elif _response .status_code == 404 :
268+ raise ApiErrorException ('The resource specified cannot be found or does not belong to you.' , _response )
269+ elif _response .status_code == 415 :
270+ raise ApiErrorException ('We don\' t support that media type. If a request body is required, please send it to us as `application/json`.' , _response )
271+ elif _response .status_code == 429 :
272+ raise ApiErrorException ('You\' re sending requests to this endpoint too frequently. Please slow your request rate down and try again.' , _response )
273+ elif _response .status_code == 500 :
274+ raise ApiErrorException ('Something unexpected happened. Please try again.' , _response )
275+ self .validate_response (_response )
228276
229277 def modify_call_recording_state (self ,
230278 account_id ,
0 commit comments