// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.communication.callautomation.implementation;

import com.azure.communication.callautomation.implementation.models.CommunicationErrorResponseException;
import com.azure.communication.callautomation.implementation.models.ContinuousDtmfRecognitionRequestInternal;
import com.azure.communication.callautomation.implementation.models.PlayRequest;
import com.azure.communication.callautomation.implementation.models.RecognizeRequest;
import com.azure.communication.callautomation.implementation.models.SendDtmfRequestInternal;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.HeaderParam;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.Post;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import reactor.core.publisher.Mono;

/** An instance of this class provides access to all the operations defined in CallMedias. */
public final class CallMediasImpl {
    /** The proxy service used to perform REST calls. */
    private final CallMediasService service;

    /** The service client containing this operation class. */
    private final AzureCommunicationCallAutomationServiceImpl client;

    /**
     * Initializes an instance of CallMediasImpl.
     *
     * @param client the instance of the service client containing this operation class.
     */
    CallMediasImpl(AzureCommunicationCallAutomationServiceImpl client) {
        this.service =
                RestProxy.create(CallMediasService.class, client.getHttpPipeline(), client.getSerializerAdapter());
        this.client = client;
    }

    /**
     * The interface defining all the services for AzureCommunicationCallAutomationServiceCallMedias to be used by the
     * proxy service to perform REST calls.
     */
    @Host("{endpoint}")
    @ServiceInterface(name = "AzureCommunicationCa")
    public interface CallMediasService {
        @Post("/calling/callConnections/{callConnectionId}:play")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> play(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") PlayRequest playRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/calling/callConnections/{callConnectionId}:cancelAllMediaOperations")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> cancelAllMediaOperations(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/calling/callConnections/{callConnectionId}:recognize")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> recognize(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") RecognizeRequest recognizeRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/calling/callConnections/{callConnectionId}:startContinuousDtmfRecognition")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> startContinuousDtmfRecognition(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json")
                        ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/calling/callConnections/{callConnectionId}:stopContinuousDtmfRecognition")
        @ExpectedResponses({200})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> stopContinuousDtmfRecognition(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json")
                        ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/calling/callConnections/{callConnectionId}:sendDtmf")
        @ExpectedResponses({202})
        @UnexpectedResponseExceptionType(CommunicationErrorResponseException.class)
        Mono<Response<Void>> sendDtmf(
                @HostParam("endpoint") String endpoint,
                @PathParam("callConnectionId") String callConnectionId,
                @QueryParam("api-version") String apiVersion,
                @BodyParam("application/json") SendDtmfRequestInternal sendDtmfRequest,
                @HeaderParam("Accept") String accept,
                Context context);
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> playWithResponseAsync(String callConnectionId, PlayRequest playRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.play(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                playRequest,
                                accept,
                                context));
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> playWithResponseAsync(
            String callConnectionId, PlayRequest playRequest, Context context) {
        final String accept = "application/json";
        return service.play(
                this.client.getEndpoint(), callConnectionId, this.client.getApiVersion(), playRequest, accept, context);
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> playAsync(String callConnectionId, PlayRequest playRequest) {
        return playWithResponseAsync(callConnectionId, playRequest).flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> playAsync(String callConnectionId, PlayRequest playRequest, Context context) {
        return playWithResponseAsync(callConnectionId, playRequest, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void play(String callConnectionId, PlayRequest playRequest) {
        playAsync(callConnectionId, playRequest).block();
    }

    /**
     * Plays audio to participants in the call.
     *
     * @param callConnectionId The call connection id.
     * @param playRequest play request payload.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> playWithResponse(String callConnectionId, PlayRequest playRequest, Context context) {
        return playWithResponseAsync(callConnectionId, playRequest, context).block();
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> cancelAllMediaOperationsWithResponseAsync(String callConnectionId) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.cancelAllMediaOperations(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                accept,
                                context));
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> cancelAllMediaOperationsWithResponseAsync(String callConnectionId, Context context) {
        final String accept = "application/json";
        return service.cancelAllMediaOperations(
                this.client.getEndpoint(), callConnectionId, this.client.getApiVersion(), accept, context);
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> cancelAllMediaOperationsAsync(String callConnectionId) {
        return cancelAllMediaOperationsWithResponseAsync(callConnectionId)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> cancelAllMediaOperationsAsync(String callConnectionId, Context context) {
        return cancelAllMediaOperationsWithResponseAsync(callConnectionId, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void cancelAllMediaOperations(String callConnectionId) {
        cancelAllMediaOperationsAsync(callConnectionId).block();
    }

    /**
     * Cancel all media operations in a call.
     *
     * @param callConnectionId The call connection id.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> cancelAllMediaOperationsWithResponse(String callConnectionId, Context context) {
        return cancelAllMediaOperationsWithResponseAsync(callConnectionId, context).block();
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> recognizeWithResponseAsync(String callConnectionId, RecognizeRequest recognizeRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.recognize(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                recognizeRequest,
                                accept,
                                context));
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> recognizeWithResponseAsync(
            String callConnectionId, RecognizeRequest recognizeRequest, Context context) {
        final String accept = "application/json";
        return service.recognize(
                this.client.getEndpoint(),
                callConnectionId,
                this.client.getApiVersion(),
                recognizeRequest,
                accept,
                context);
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> recognizeAsync(String callConnectionId, RecognizeRequest recognizeRequest) {
        return recognizeWithResponseAsync(callConnectionId, recognizeRequest)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> recognizeAsync(String callConnectionId, RecognizeRequest recognizeRequest, Context context) {
        return recognizeWithResponseAsync(callConnectionId, recognizeRequest, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void recognize(String callConnectionId, RecognizeRequest recognizeRequest) {
        recognizeAsync(callConnectionId, recognizeRequest).block();
    }

    /**
     * Recognize media from call.
     *
     * @param callConnectionId The call connection id.
     * @param recognizeRequest The media recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> recognizeWithResponse(
            String callConnectionId, RecognizeRequest recognizeRequest, Context context) {
        return recognizeWithResponseAsync(callConnectionId, recognizeRequest, context).block();
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> startContinuousDtmfRecognitionWithResponseAsync(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.startContinuousDtmfRecognition(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                continuousDtmfRecognitionRequest,
                                accept,
                                context));
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> startContinuousDtmfRecognitionWithResponseAsync(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        final String accept = "application/json";
        return service.startContinuousDtmfRecognition(
                this.client.getEndpoint(),
                callConnectionId,
                this.client.getApiVersion(),
                continuousDtmfRecognitionRequest,
                accept,
                context);
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> startContinuousDtmfRecognitionAsync(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        return startContinuousDtmfRecognitionWithResponseAsync(callConnectionId, continuousDtmfRecognitionRequest)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> startContinuousDtmfRecognitionAsync(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        return startContinuousDtmfRecognitionWithResponseAsync(
                        callConnectionId, continuousDtmfRecognitionRequest, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void startContinuousDtmfRecognition(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        startContinuousDtmfRecognitionAsync(callConnectionId, continuousDtmfRecognitionRequest).block();
    }

    /**
     * Start continuous Dtmf recognition by subscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> startContinuousDtmfRecognitionWithResponse(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        return startContinuousDtmfRecognitionWithResponseAsync(
                        callConnectionId, continuousDtmfRecognitionRequest, context)
                .block();
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> stopContinuousDtmfRecognitionWithResponseAsync(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.stopContinuousDtmfRecognition(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                continuousDtmfRecognitionRequest,
                                accept,
                                context));
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> stopContinuousDtmfRecognitionWithResponseAsync(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        final String accept = "application/json";
        return service.stopContinuousDtmfRecognition(
                this.client.getEndpoint(),
                callConnectionId,
                this.client.getApiVersion(),
                continuousDtmfRecognitionRequest,
                accept,
                context);
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> stopContinuousDtmfRecognitionAsync(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        return stopContinuousDtmfRecognitionWithResponseAsync(callConnectionId, continuousDtmfRecognitionRequest)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> stopContinuousDtmfRecognitionAsync(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        return stopContinuousDtmfRecognitionWithResponseAsync(
                        callConnectionId, continuousDtmfRecognitionRequest, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void stopContinuousDtmfRecognition(
            String callConnectionId, ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest) {
        stopContinuousDtmfRecognitionAsync(callConnectionId, continuousDtmfRecognitionRequest).block();
    }

    /**
     * Stop continuous Dtmf recognition by unsubscribing to tones.
     *
     * @param callConnectionId The call connection id.
     * @param continuousDtmfRecognitionRequest The continuous recognize request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> stopContinuousDtmfRecognitionWithResponse(
            String callConnectionId,
            ContinuousDtmfRecognitionRequestInternal continuousDtmfRecognitionRequest,
            Context context) {
        return stopContinuousDtmfRecognitionWithResponseAsync(
                        callConnectionId, continuousDtmfRecognitionRequest, context)
                .block();
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> sendDtmfWithResponseAsync(
            String callConnectionId, SendDtmfRequestInternal sendDtmfRequest) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.sendDtmf(
                                this.client.getEndpoint(),
                                callConnectionId,
                                this.client.getApiVersion(),
                                sendDtmfRequest,
                                accept,
                                context));
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> sendDtmfWithResponseAsync(
            String callConnectionId, SendDtmfRequestInternal sendDtmfRequest, Context context) {
        final String accept = "application/json";
        return service.sendDtmf(
                this.client.getEndpoint(),
                callConnectionId,
                this.client.getApiVersion(),
                sendDtmfRequest,
                accept,
                context);
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> sendDtmfAsync(String callConnectionId, SendDtmfRequestInternal sendDtmfRequest) {
        return sendDtmfWithResponseAsync(callConnectionId, sendDtmfRequest)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the completion.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> sendDtmfAsync(String callConnectionId, SendDtmfRequestInternal sendDtmfRequest, Context context) {
        return sendDtmfWithResponseAsync(callConnectionId, sendDtmfRequest, context)
                .flatMap((Response<Void> res) -> Mono.empty());
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public void sendDtmf(String callConnectionId, SendDtmfRequestInternal sendDtmfRequest) {
        sendDtmfAsync(callConnectionId, sendDtmfRequest).block();
    }

    /**
     * Send dtmf tones.
     *
     * @param callConnectionId The call connection id.
     * @param sendDtmfRequest The send dtmf request.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws CommunicationErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the response.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> sendDtmfWithResponse(
            String callConnectionId, SendDtmfRequestInternal sendDtmfRequest, Context context) {
        return sendDtmfWithResponseAsync(callConnectionId, sendDtmfRequest, context).block();
    }
}
