import type { GetCurrentUserResponse, RefreshTokenResponse, SignInResponse } from "@/types/proto/api/v1/auth_service_pb";
import { fetchJson } from "./apiClient";

export const authServiceClient = {
  async getCurrentUser(_request?: unknown): Promise<GetCurrentUserResponse> {
    void _request;
    const data = await fetchJson<GetCurrentUserResponse>("/auth/me", { method: "GET" });
    return data;
  },
  async signIn(request: unknown): Promise<SignInResponse> {
    const body = typeof request === "object" && request ? request : {};
    const data = await fetchJson<{ accessToken?: string }>("/auth/signin", { method: "POST", body });
    return {
      accessToken: data.accessToken || "",
    };
  },
  async signOut(_request?: unknown): Promise<Record<string, never>> {
    void _request;
    return {};
  },
  async refreshToken(_request?: unknown): Promise<RefreshTokenResponse> {
    void _request;
    return { accessToken: "" };
  },
};

