import { getSysAdminNonce } from "../helpers/GetSysAdminNonce";
import { getApiHost } from "../helpers/GetApiHost";
import axios from "axios";
import { getPayload } from "../helpers/GetPayload";
import { PaginateWapServerParams, PaginateWapServerResults } from "../models/WapServers.Model";

export class WapService {
    public async getWapServers(filters: PaginateWapServerParams): Promise<PaginateWapServerResults> {
        const nonce = await getSysAdminNonce();
        const postData = { ...filters, ...{ payload: getPayload(nonce) } };

        const response = await axios.post(`${getApiHost()}/sysadmin/wapserver/get`, postData, {
            headers: {
                "Content-Type": "application/json",
            },
            timeout: 5000,
        });

        const resultado: PaginateWapServerResults = response.data;

        return resultado;
    }
}
