// 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.StudentsClient;
import com.azure.resourcemanager.education.fluent.models.StudentDetailsInner;
import com.azure.resourcemanager.education.models.StudentDetails;
import com.azure.resourcemanager.education.models.Students;

public final class StudentsImpl implements Students {
    private static final ClientLogger LOGGER = new ClientLogger(StudentsImpl.class);

    private final StudentsClient innerClient;

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

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

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

    public PagedIterable<StudentDetails> list(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        Boolean includeDeleted,
        Context context) {
        PagedIterable<StudentDetailsInner> inner =
            this
                .serviceClient()
                .list(billingAccountName, billingProfileName, invoiceSectionName, includeDeleted, context);
        return Utils.mapPage(inner, inner1 -> new StudentDetailsImpl(inner1, this.manager()));
    }

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

    public StudentDetails get(
        String billingAccountName, String billingProfileName, String invoiceSectionName, String studentAlias) {
        StudentDetailsInner inner =
            this.serviceClient().get(billingAccountName, billingProfileName, invoiceSectionName, studentAlias);
        if (inner != null) {
            return new StudentDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

    public void delete(
        String billingAccountName, String billingProfileName, String invoiceSectionName, String studentAlias) {
        this.serviceClient().delete(billingAccountName, billingProfileName, invoiceSectionName, studentAlias);
    }

    public Response<StudentDetails> createOrUpdateWithResponse(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String studentAlias,
        StudentDetailsInner parameters,
        Context context) {
        Response<StudentDetailsInner> inner =
            this
                .serviceClient()
                .createOrUpdateWithResponse(
                    billingAccountName, billingProfileName, invoiceSectionName, studentAlias, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new StudentDetailsImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public StudentDetails createOrUpdate(
        String billingAccountName,
        String billingProfileName,
        String invoiceSectionName,
        String studentAlias,
        StudentDetailsInner parameters) {
        StudentDetailsInner inner =
            this
                .serviceClient()
                .createOrUpdate(billingAccountName, billingProfileName, invoiceSectionName, studentAlias, parameters);
        if (inner != null) {
            return new StudentDetailsImpl(inner, this.manager());
        } else {
            return null;
        }
    }

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

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