import api from "@/services/api";

export class AuthService {
  async validate(email: string, password: string) {
    try {
      const response = await api.post("/Auth/validate", {
        rtemail: email,
        rtsenha: password,
      });

      return response;
    } catch (error) {
      throw error;
    }
  }

  async logout() {
    try {
      await api.post("/Auth/logout");
    } catch (error) {
      console.error("Erro ao invalidar cookie no servidor", error);
    }
  }

  // Em auth-service.ts
  async getMe() {
    try {
      const response = await api.get("/Auth/me");
      return response.data;
    } catch (error) {
      return { error: true };
    }
  }
}
