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

package com.azure.resourcemanager.apimanagement.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.apimanagement.fluent.NotificationRecipientUsersClient;
import com.azure.resourcemanager.apimanagement.fluent.models.RecipientUserCollectionInner;
import com.azure.resourcemanager.apimanagement.fluent.models.RecipientUserContractInner;
import com.azure.resourcemanager.apimanagement.models.NotificationName;
import com.azure.resourcemanager.apimanagement.models.NotificationRecipientUsers;
import com.azure.resourcemanager.apimanagement.models.RecipientUserCollection;
import com.azure.resourcemanager.apimanagement.models.RecipientUserContract;

public final class NotificationRecipientUsersImpl implements NotificationRecipientUsers {
    private static final ClientLogger LOGGER = new ClientLogger(NotificationRecipientUsersImpl.class);

    private final NotificationRecipientUsersClient innerClient;

    private final com.azure.resourcemanager.apimanagement.ApiManagementManager serviceManager;

    public NotificationRecipientUsersImpl(
        NotificationRecipientUsersClient innerClient,
        com.azure.resourcemanager.apimanagement.ApiManagementManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public RecipientUserCollection listByNotification(
        String resourceGroupName, String serviceName, NotificationName notificationName) {
        RecipientUserCollectionInner inner =
            this.serviceClient().listByNotification(resourceGroupName, serviceName, notificationName);
        if (inner != null) {
            return new RecipientUserCollectionImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<RecipientUserCollection> listByNotificationWithResponse(
        String resourceGroupName, String serviceName, NotificationName notificationName, Context context) {
        Response<RecipientUserCollectionInner> inner =
            this
                .serviceClient()
                .listByNotificationWithResponse(resourceGroupName, serviceName, notificationName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RecipientUserCollectionImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public boolean checkEntityExists(
        String resourceGroupName, String serviceName, NotificationName notificationName, String userId) {
        return this.serviceClient().checkEntityExists(resourceGroupName, serviceName, notificationName, userId);
    }

    public Response<Boolean> checkEntityExistsWithResponse(
        String resourceGroupName,
        String serviceName,
        NotificationName notificationName,
        String userId,
        Context context) {
        return this
            .serviceClient()
            .checkEntityExistsWithResponse(resourceGroupName, serviceName, notificationName, userId, context);
    }

    public RecipientUserContract createOrUpdate(
        String resourceGroupName, String serviceName, NotificationName notificationName, String userId) {
        RecipientUserContractInner inner =
            this.serviceClient().createOrUpdate(resourceGroupName, serviceName, notificationName, userId);
        if (inner != null) {
            return new RecipientUserContractImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<RecipientUserContract> createOrUpdateWithResponse(
        String resourceGroupName,
        String serviceName,
        NotificationName notificationName,
        String userId,
        Context context) {
        Response<RecipientUserContractInner> inner =
            this
                .serviceClient()
                .createOrUpdateWithResponse(resourceGroupName, serviceName, notificationName, userId, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new RecipientUserContractImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public void delete(String resourceGroupName, String serviceName, NotificationName notificationName, String userId) {
        this.serviceClient().delete(resourceGroupName, serviceName, notificationName, userId);
    }

    public Response<Void> deleteWithResponse(
        String resourceGroupName,
        String serviceName,
        NotificationName notificationName,
        String userId,
        Context context) {
        return this
            .serviceClient()
            .deleteWithResponse(resourceGroupName, serviceName, notificationName, userId, context);
    }

    private NotificationRecipientUsersClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.apimanagement.ApiManagementManager manager() {
        return this.serviceManager;
    }
}
