import { connect } from "mongoose";
import views, {
    HomeView,
    PublicOrganizationViewParams,
    PublicOrganizationView,
    PublicOrganizationServiceViewParams,
    PublicOrganizationServiceView,
    UserAppointmentViewParams,
    UserAppointmentView,
} from "../../Models/Views/Views";
import { BotView, BotEventParams } from "../../Models/WapServer/WapServer.Interface";


export class ViewsService {
    public async homeView(): Promise<HomeView> {
        await connect(`${process.env.DATABASE_CONNECTION}`);
        const view = await views.homeView();
        return view;
    }

    public async appointmentView(data: UserAppointmentViewParams): Promise<UserAppointmentView> {
        await connect(`${process.env.DATABASE_CONNECTION}`);
        const view = await views.userAppointmentView(data);
        return view;
    }

    public async organizationView(
        data: PublicOrganizationViewParams
    ): Promise<PublicOrganizationView> {
        await connect(`${process.env.DATABASE_CONNECTION}`);
        const view = await views.organizationView(data);
        return view;
    }

    public async organizationServiceView(
        data: PublicOrganizationServiceViewParams
    ): Promise<PublicOrganizationServiceView> {
        await connect(`${process.env.DATABASE_CONNECTION}`);
        const view = await views.organizationServiceView(data);
        return view;
    }

    public async botServiceView(data: BotEventParams): Promise<BotView> {
        await connect(`${process.env.DATABASE_CONNECTION}`);
        const view = await views.wapView(data);
        return view;
    }
}
