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

package com.azure.resourcemanager.billingbenefits.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.billingbenefits.fluent.ReservationOrderAliasClient;
import com.azure.resourcemanager.billingbenefits.fluent.models.ReservationOrderAliasResponseInner;
import com.azure.resourcemanager.billingbenefits.models.ReservationOrderAlias;
import com.azure.resourcemanager.billingbenefits.models.ReservationOrderAliasRequest;
import com.azure.resourcemanager.billingbenefits.models.ReservationOrderAliasResponse;

public final class ReservationOrderAliasImpl implements ReservationOrderAlias {
    private static final ClientLogger LOGGER = new ClientLogger(ReservationOrderAliasImpl.class);

    private final ReservationOrderAliasClient innerClient;

    private final com.azure.resourcemanager.billingbenefits.BillingBenefitsManager serviceManager;

    public ReservationOrderAliasImpl(
        ReservationOrderAliasClient innerClient,
        com.azure.resourcemanager.billingbenefits.BillingBenefitsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public ReservationOrderAliasResponse create(String reservationOrderAliasName, ReservationOrderAliasRequest body) {
        ReservationOrderAliasResponseInner inner = this.serviceClient().create(reservationOrderAliasName, body);
        if (inner != null) {
            return new ReservationOrderAliasResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public ReservationOrderAliasResponse create(
        String reservationOrderAliasName, ReservationOrderAliasRequest body, Context context) {
        ReservationOrderAliasResponseInner inner =
            this.serviceClient().create(reservationOrderAliasName, body, context);
        if (inner != null) {
            return new ReservationOrderAliasResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<ReservationOrderAliasResponse> getWithResponse(String reservationOrderAliasName, Context context) {
        Response<ReservationOrderAliasResponseInner> inner =
            this.serviceClient().getWithResponse(reservationOrderAliasName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new ReservationOrderAliasResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public ReservationOrderAliasResponse get(String reservationOrderAliasName) {
        ReservationOrderAliasResponseInner inner = this.serviceClient().get(reservationOrderAliasName);
        if (inner != null) {
            return new ReservationOrderAliasResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.billingbenefits.BillingBenefitsManager manager() {
        return this.serviceManager;
    }
}
