import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { environment } from '../../../../environments/environment';
import { configuration } from '../../entities/configuration';

@Injectable({
    providedIn: 'root'
})
export class ConfigurationService {

    constructor(private http: HttpClient) { }

    async getConfiguration(): Promise<any> {
        return await this.http.post("/api/admin/configuration/getConfiguration", {})
            .toPromise() as any
    }

    async testConnection(configuration: configuration): Promise<any> {
        return await this.http.post("/api/admin/configuration/testConnection", configuration)
            .toPromise() as any
    }

    async databaseConfiguration(configuration: configuration): Promise<any> {
        return await this.http.post("/api/admin/configuration/databaseConfiguration", configuration)
            .toPromise() as any
    }


    async installMasterData(configuration: configuration): Promise<any> {
        return await this.http.post("/api/admin/configuration/installMasterData", configuration)
            .toPromise() as any
    }

    async installSampleData(): Promise<any> {
        return await this.http.post("/api/admin/configuration/installSampleData", {})
            .toPromise() as any
    }

    async backupDatabase(configuration: configuration): Promise<any> {

        return await this.http.post("/api/admin/configuration/backupDatabase", configuration)
            .toPromise() as any
    }
}