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

package com.azure.resourcemanager.voiceservices.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.voiceservices.fluent.NameAvailabilitiesClient;
import com.azure.resourcemanager.voiceservices.fluent.models.CheckNameAvailabilityResponseInner;
import com.azure.resourcemanager.voiceservices.models.CheckNameAvailabilityRequest;
import com.azure.resourcemanager.voiceservices.models.CheckNameAvailabilityResponse;
import com.azure.resourcemanager.voiceservices.models.NameAvailabilities;

public final class NameAvailabilitiesImpl implements NameAvailabilities {
    private static final ClientLogger LOGGER = new ClientLogger(NameAvailabilitiesImpl.class);

    private final NameAvailabilitiesClient innerClient;

    private final com.azure.resourcemanager.voiceservices.VoiceServicesManager serviceManager;

    public NameAvailabilitiesImpl(
        NameAvailabilitiesClient innerClient,
        com.azure.resourcemanager.voiceservices.VoiceServicesManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<CheckNameAvailabilityResponse> checkLocalWithResponse(
        String location, CheckNameAvailabilityRequest body, Context context) {
        Response<CheckNameAvailabilityResponseInner> inner =
            this.serviceClient().checkLocalWithResponse(location, body, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CheckNameAvailabilityResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CheckNameAvailabilityResponse checkLocal(String location, CheckNameAvailabilityRequest body) {
        CheckNameAvailabilityResponseInner inner = this.serviceClient().checkLocal(location, body);
        if (inner != null) {
            return new CheckNameAvailabilityResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.voiceservices.VoiceServicesManager manager() {
        return this.serviceManager;
    }
}
