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

package com.azure.ai.personalizer.implementation;

import com.azure.ai.personalizer.models.ErrorResponseException;
import com.azure.ai.personalizer.models.PersonalizerRewardMultiSlotOptions;
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.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 MultiSlotEvents. */
public final class MultiSlotEventsImpl {
    /** The proxy service used to perform REST calls. */
    private final MultiSlotEventsService service;

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

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

    /**
     * The interface defining all the services for PersonalizerClientV1Preview3MultiSlotEvents to be used by the proxy
     * service to perform REST calls.
     */
    @Host("{Endpoint}/personalizer/{ApiVersion}")
    @ServiceInterface(name = "PersonalizerClientV1")
    public interface MultiSlotEventsService {
        @Post("/multislot/events/{eventId}/reward")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(ErrorResponseException.class)
        Mono<Response<Void>> reward(
                @HostParam("Endpoint") String endpoint,
                @HostParam("ApiVersion") String apiVersion,
                @PathParam("eventId") String eventId,
                @BodyParam("application/json") PersonalizerRewardMultiSlotOptions body,
                @HeaderParam("Accept") String accept,
                Context context);

        @Post("/multislot/events/{eventId}/activate")
        @ExpectedResponses({204})
        @UnexpectedResponseExceptionType(ErrorResponseException.class)
        Mono<Response<Void>> activate(
                @HostParam("Endpoint") String endpoint,
                @HostParam("ApiVersion") String apiVersion,
                @PathParam("eventId") String eventId,
                @HeaderParam("Accept") String accept,
                Context context);
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> rewardWithResponseAsync(String eventId, PersonalizerRewardMultiSlotOptions body) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.reward(
                                this.client.getEndpoint(),
                                this.client.getApiVersion(),
                                eventId,
                                body,
                                accept,
                                context));
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> rewardWithResponseAsync(
            String eventId, PersonalizerRewardMultiSlotOptions body, Context context) {
        final String accept = "application/json";
        return service.reward(this.client.getEndpoint(), this.client.getApiVersion(), eventId, body, accept, context);
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> rewardAsync(String eventId, PersonalizerRewardMultiSlotOptions body) {
        return rewardWithResponseAsync(eventId, body).flatMap(ignored -> Mono.empty());
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> rewardAsync(String eventId, PersonalizerRewardMultiSlotOptions body, Context context) {
        return rewardWithResponseAsync(eventId, body, context).flatMap(ignored -> Mono.empty());
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException 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 reward(String eventId, PersonalizerRewardMultiSlotOptions body) {
        rewardAsync(eventId, body).block();
    }

    /**
     * Post multi-slot Rewards.
     *
     * <p>Report reward that resulted from using the action specified in rewardActionId for the slot.
     *
     * @param eventId The event id this reward applies to.
     * @param body List of slot id and reward values. The reward should be a floating point number, typically between 0
     *     and 1.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> rewardWithResponse(String eventId, PersonalizerRewardMultiSlotOptions body, Context context) {
        return rewardWithResponseAsync(eventId, body, context).block();
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> activateWithResponseAsync(String eventId) {
        final String accept = "application/json";
        return FluxUtil.withContext(
                context ->
                        service.activate(
                                this.client.getEndpoint(), this.client.getApiVersion(), eventId, accept, context));
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response} on successful completion of {@link Mono}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Response<Void>> activateWithResponseAsync(String eventId, Context context) {
        final String accept = "application/json";
        return service.activate(this.client.getEndpoint(), this.client.getApiVersion(), eventId, accept, context);
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> activateAsync(String eventId) {
        return activateWithResponseAsync(eventId).flatMap(ignored -> Mono.empty());
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return A {@link Mono} that completes when a successful response is received.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Mono<Void> activateAsync(String eventId, Context context) {
        return activateWithResponseAsync(eventId, context).flatMap(ignored -> Mono.empty());
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException 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 activate(String eventId) {
        activateAsync(eventId).block();
    }

    /**
     * Activate multi-slot Event.
     *
     * <p>Report that the specified event was actually used or displayed to the user and a rewards should be expected
     * for it.
     *
     * @param eventId The event ID this activation applies to.
     * @param context The context to associate with this operation.
     * @throws IllegalArgumentException thrown if parameters fail the validation.
     * @throws ErrorResponseException thrown if the request is rejected by server.
     * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
     * @return the {@link Response}.
     */
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<Void> activateWithResponse(String eventId, Context context) {
        return activateWithResponseAsync(eventId, context).block();
    }
}
