@@ -370,6 +370,116 @@ public async Task ModifyCallAsync(
370370 this . ValidateResponse ( response , context ) ;
371371 }
372372
373+ /// <summary>
374+ /// Replaces an active call's BXML document.
375+ /// </summary>
376+ /// <param name="accountId">Required parameter: Example: .</param>
377+ /// <param name="callId">Required parameter: Example: .</param>
378+ /// <param name="body">Required parameter: Example: .</param>
379+ public void ModifyCallBxml (
380+ string accountId ,
381+ string callId ,
382+ string body )
383+ {
384+ Task t = this . ModifyCallBxmlAsync ( accountId , callId , body ) ;
385+ ApiHelper . RunTaskSynchronously ( t ) ;
386+ }
387+
388+ /// <summary>
389+ /// Interrupts and replaces an active call's BXML document.
390+ /// </summary>
391+ /// <param name="accountId">Required parameter: Example: .</param>
392+ /// <param name="callId">Required parameter: Example: .</param>
393+ /// <param name="body">Required parameter: Example: .</param>
394+ /// <param name="cancellationToken"> cancellationToken. </param>
395+ /// <returns>Returns the void response from the API call.</returns>
396+ public async Task ModifyCallBxmlAsync (
397+ string accountId ,
398+ string callId ,
399+ string body ,
400+ CancellationToken cancellationToken = default )
401+ {
402+ // the base uri for api requests.
403+ string baseUri = this . Config . GetBaseUri ( Server . VoiceDefault ) ;
404+
405+ // prepare query string for API call.
406+ StringBuilder queryBuilder = new StringBuilder ( baseUri ) ;
407+ queryBuilder . Append ( "/api/v2/accounts/{accountId}/calls/{callId}/bxml" ) ;
408+
409+ // process optional template parameters.
410+ ApiHelper . AppendUrlWithTemplateParameters ( queryBuilder , new Dictionary < string , object > ( )
411+ {
412+ { "accountId" , accountId } ,
413+ { "callId" , callId } ,
414+ } ) ;
415+
416+ // append request with appropriate headers and parameters
417+ var headers = new Dictionary < string , string > ( )
418+ {
419+ { "user-agent" , this . UserAgent } ,
420+ { "content-type" , "application/xml; charset=utf-8" } ,
421+ } ;
422+
423+ // append body params.
424+ var bodyText = body ;
425+
426+ // prepare the API call request to fetch the response.
427+ HttpRequest httpRequest = this . GetClientInstance ( ) . PutBody ( queryBuilder . ToString ( ) , headers , bodyText ) ;
428+
429+ if ( this . HttpCallBack != null )
430+ {
431+ this . HttpCallBack . OnBeforeHttpRequestEventHandler ( this . GetClientInstance ( ) , httpRequest ) ;
432+ }
433+
434+ httpRequest = await this . AuthManagers [ "voice" ] . ApplyAsync ( httpRequest ) . ConfigureAwait ( false ) ;
435+
436+ // invoke request and get response.
437+ HttpStringResponse response = await this . GetClientInstance ( ) . ExecuteAsStringAsync ( httpRequest , cancellationToken ) . ConfigureAwait ( false ) ;
438+ HttpContext context = new HttpContext ( httpRequest , response ) ;
439+ if ( this . HttpCallBack != null )
440+ {
441+ this . HttpCallBack . OnAfterHttpResponseEventHandler ( this . GetClientInstance ( ) , response ) ;
442+ }
443+
444+ if ( response . StatusCode == 400 )
445+ {
446+ throw new ApiErrorException ( "Something's not quite right... Your request is invalid. Please fix it before trying again." , context ) ;
447+ }
448+
449+ if ( response . StatusCode == 401 )
450+ {
451+ throw new ApiException ( "Your credentials are invalid. Please use your Bandwidth dashboard credentials to authenticate to the API." , context ) ;
452+ }
453+
454+ if ( response . StatusCode == 403 )
455+ {
456+ throw new ApiErrorException ( "User unauthorized to perform this action." , context ) ;
457+ }
458+
459+ if ( response . StatusCode == 404 )
460+ {
461+ throw new ApiErrorException ( "The resource specified cannot be found or does not belong to you." , context ) ;
462+ }
463+
464+ if ( response . StatusCode == 415 )
465+ {
466+ throw new ApiErrorException ( "We don't support that media type. If a request body is required, please send it to us as `application/xml`." , context ) ;
467+ }
468+
469+ if ( response . StatusCode == 429 )
470+ {
471+ throw new ApiErrorException ( "You're sending requests to this endpoint too frequently. Please slow your request rate down and try again." , context ) ;
472+ }
473+
474+ if ( response . StatusCode == 500 )
475+ {
476+ throw new ApiErrorException ( "Something unexpected happened. Please try again." , context ) ;
477+ }
478+
479+ // handle errors defined at the API level.
480+ this . ValidateResponse ( response , context ) ;
481+ }
482+
373483 /// <summary>
374484 /// Pauses or resumes a recording.
375485 /// </summary>
0 commit comments