import type { Iwebsite } from "../../interface/websites";
import { ApiError } from "../../middleware/ApiError";
import { prisma } from "../../utils/prisma";

export class WebsiteReportService {

    static async getWebsiteReport(url: string, token: string, todate: string, fromdate: string) {



        const modify = `${url}/?token=${token}&from=${fromdate}&to=${todate}`
        const response = await fetch(modify, {
            method: "GET",
            headers: {
                contentType: "application/json",
            },
        })




        if (!response.ok) {
            throw new ApiError("Api Not Responding", 400)
        }
        return await response.json();

    }



    static async getBramikalpreport(to?: string, from?: string) {

        const modify = `${process.env.BRAHMIKALP_URL}/?token=${process.env.BRAHMIKALP_TOKEN}&from=${from}&to=${to}`

        const response = await fetch(modify, {
            method: "GET",
            headers: {
                contentType: "application/json",
            },
        })


        return await response.json()


    }




}