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

package com.azure.resourcemanager.education.implementation;

import com.azure.core.http.rest.PagedIterable;
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.education.fluent.JoinRequestsClient;
import com.azure.resourcemanager.education.fluent.models.JoinRequestDetailsInner;
import com.azure.resourcemanager.education.models.JoinRequestDetails;
import com.azure.resourcemanager.education.models.JoinRequests;

public final class JoinRequestsImpl implements JoinRequests {
    private static final ClientLogger LOGGER = new ClientLogger(JoinRequestsImpl.class);

    private final JoinRequestsClient innerClient;

    private final com.azure.resourcemanager.education.EducationManager serviceManager;

    public JoinRequestsImpl(
        JoinRequestsClient innerClient, com.azure.resourcemanager.education.EducationManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<JoinRequestDetails> list(
        String billingAccountName, String billingProfileName, String invoiceSectionName) {
        PagedIterable<JoinRequestDetailsInner> inner =
            this.serviceClient().list(billingAccountName, billingProfileName, invoiceSectionName);
        return Utils.mapPage(inner, inner1 -> new JoinRequestDetailsImpl(inner1, this.manager()));
    }

    public PagedIterable<JoinRequestDetails> list(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        Boolean includeDenied,
        Context context) {
        PagedIterable<JoinRequestDetailsInner> inner =
            this
                .serviceClient()
                .list(billingAccountName, billingProfileName, invoiceSectionName, includeDenied, context);
        return Utils.mapPage(inner, inner1 -> new JoinRequestDetailsImpl(inner1, this.manager()));
    }

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

    public JoinRequestDetails get(
        String billingAccountName, String billingProfileName, String invoiceSectionName, String joinRequestName) {
        JoinRequestDetailsInner inner =
            this.serviceClient().get(billingAccountName, billingProfileName, invoiceSectionName, joinRequestName);
        if (inner != null) {
            return new JoinRequestDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Void> approveWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String joinRequestName,
        Context context) {
        return this
            .serviceClient()
            .approveWithResponse(billingAccountName, billingProfileName, invoiceSectionName, joinRequestName, context);
    }

    public void approve(
        String billingAccountName, String billingProfileName, String invoiceSectionName, String joinRequestName) {
        this.serviceClient().approve(billingAccountName, billingProfileName, invoiceSectionName, joinRequestName);
    }

    public Response<Void> denyWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String joinRequestName,
        Context context) {
        return this
            .serviceClient()
            .denyWithResponse(billingAccountName, billingProfileName, invoiceSectionName, joinRequestName, context);
    }

    public void deny(
        String billingAccountName, String billingProfileName, String invoiceSectionName, String joinRequestName) {
        this.serviceClient().deny(billingAccountName, billingProfileName, invoiceSectionName, joinRequestName);
    }

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

    private com.azure.resourcemanager.education.EducationManager manager() {
        return this.serviceManager;
    }
}
