// 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.SavingsPlanOrderAliasClient;
import com.azure.resourcemanager.billingbenefits.fluent.models.SavingsPlanOrderAliasModelInner;
import com.azure.resourcemanager.billingbenefits.models.SavingsPlanOrderAlias;
import com.azure.resourcemanager.billingbenefits.models.SavingsPlanOrderAliasModel;

public final class SavingsPlanOrderAliasImpl implements SavingsPlanOrderAlias {
    private static final ClientLogger LOGGER = new ClientLogger(SavingsPlanOrderAliasImpl.class);

    private final SavingsPlanOrderAliasClient innerClient;

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

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

    public SavingsPlanOrderAliasModel create(String savingsPlanOrderAliasName, SavingsPlanOrderAliasModelInner body) {
        SavingsPlanOrderAliasModelInner inner = this.serviceClient().create(savingsPlanOrderAliasName, body);
        if (inner != null) {
            return new SavingsPlanOrderAliasModelImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public SavingsPlanOrderAliasModel create(
        String savingsPlanOrderAliasName, SavingsPlanOrderAliasModelInner body, Context context) {
        SavingsPlanOrderAliasModelInner inner = this.serviceClient().create(savingsPlanOrderAliasName, body, context);
        if (inner != null) {
            return new SavingsPlanOrderAliasModelImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<SavingsPlanOrderAliasModel> getWithResponse(String savingsPlanOrderAliasName, Context context) {
        Response<SavingsPlanOrderAliasModelInner> inner =
            this.serviceClient().getWithResponse(savingsPlanOrderAliasName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new SavingsPlanOrderAliasModelImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public SavingsPlanOrderAliasModel get(String savingsPlanOrderAliasName) {
        SavingsPlanOrderAliasModelInner inner = this.serviceClient().get(savingsPlanOrderAliasName);
        if (inner != null) {
            return new SavingsPlanOrderAliasModelImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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