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

package com.azure.resourcemanager.billing.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.billing.fluent.AvailableBalancesClient;
import com.azure.resourcemanager.billing.fluent.models.AvailableBalanceInner;
import com.azure.resourcemanager.billing.models.AvailableBalance;
import com.azure.resourcemanager.billing.models.AvailableBalances;

public final class AvailableBalancesImpl implements AvailableBalances {
    private static final ClientLogger LOGGER = new ClientLogger(AvailableBalancesImpl.class);

    private final AvailableBalancesClient innerClient;

    private final com.azure.resourcemanager.billing.BillingManager serviceManager;

    public AvailableBalancesImpl(
        AvailableBalancesClient innerClient, com.azure.resourcemanager.billing.BillingManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<AvailableBalance> getWithResponse(
        String billingAccountName, String billingProfileName, Context context) {
        Response<AvailableBalanceInner> inner =
            this.serviceClient().getWithResponse(billingAccountName, billingProfileName, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new AvailableBalanceImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public AvailableBalance get(String billingAccountName, String billingProfileName) {
        AvailableBalanceInner inner = this.serviceClient().get(billingAccountName, billingProfileName);
        if (inner != null) {
            return new AvailableBalanceImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.billing.BillingManager manager() {
        return this.serviceManager;
    }
}
