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

package com.azure.resourcemanager.reservations.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.reservations.fluent.CalculateRefundsClient;
import com.azure.resourcemanager.reservations.fluent.models.CalculateRefundResponseInner;
import com.azure.resourcemanager.reservations.models.CalculateRefundRequest;
import com.azure.resourcemanager.reservations.models.CalculateRefundResponse;
import com.azure.resourcemanager.reservations.models.CalculateRefunds;

public final class CalculateRefundsImpl implements CalculateRefunds {
    private static final ClientLogger LOGGER = new ClientLogger(CalculateRefundsImpl.class);

    private final CalculateRefundsClient innerClient;

    private final com.azure.resourcemanager.reservations.ReservationsManager serviceManager;

    public CalculateRefundsImpl(
        CalculateRefundsClient innerClient, com.azure.resourcemanager.reservations.ReservationsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<CalculateRefundResponse> postWithResponse(
        String reservationOrderId, CalculateRefundRequest body, Context context) {
        Response<CalculateRefundResponseInner> inner =
            this.serviceClient().postWithResponse(reservationOrderId, body, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new CalculateRefundResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public CalculateRefundResponse post(String reservationOrderId, CalculateRefundRequest body) {
        CalculateRefundResponseInner inner = this.serviceClient().post(reservationOrderId, body);
        if (inner != null) {
            return new CalculateRefundResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    private com.azure.resourcemanager.reservations.ReservationsManager manager() {
        return this.serviceManager;
    }
}
