import { api } from "./api";
import type { Nullable } from "./apiTypes.ts";
import type * as responses from "./responses.ts";
import type * as tokens from "./tokens.ts";
import type * as auth from "./auth.ts";

// Typescript: TSEndpoint= path=/api/users; name=createUser; method=POST; request=users.UserCreateRequest; response=users.User

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 31
export const createUser = async (
  data: UserCreateRequest,
): Promise<{ data: User; error: Nullable<string> }> => {
  return (await api.POST("/api/users", data)) as {
    data: User;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/password/update; name=updatePassword; method=PUT; request=users.UpdatePasswordRequest; response=responses.SimpleResponse

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 61
export const updatePassword = async (
  data: UpdatePasswordRequest,
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
  return (await api.PUT("/api/auth/password/update", data)) as {
    data: responses.SimpleResponse;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/users/:uuid; name=getUser; method=GET; response=users.User

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 28
export const getUser = async (
  uuid: string,
): Promise<{ data: User; error: Nullable<string> }> => {
  return (await api.GET(`/api/users/${uuid}`)) as {
    data: User;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/users/:uuid; name=deleteUser; method=DELETE; response=responses.SimpleResponse

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 37
export const deleteUser = async (
  uuid: string,
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
  return (await api.DELETE(`/api/users/${uuid}`)) as {
    data: responses.SimpleResponse;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/login; name=login; method=POST; request=users.LoginRequest; response=tokens.TokenPair

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 43
export const login = async (
  data: LoginRequest,
): Promise<{ data: tokens.TokenPair; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/login", data)) as {
    data: tokens.TokenPair;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/password/reset; name=resetPassword; method=POST; request=users.ResetPasswordRequest; response=responses.SimpleResponse

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 55
export const resetPassword = async (
  data: ResetPasswordRequest,
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/password/reset", data)) as {
    data: responses.SimpleResponse;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/users/update; name=updateUser; method=PUT; request=users.UpdateUserRequest; response=users.User

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 34
export const updateUser = async (
  data: UpdateUserRequest,
): Promise<{ data: User; error: Nullable<string> }> => {
  return (await api.PUT("/api/users/update", data)) as {
    data: User;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/register; name=register; method=POST; request=users.UserCreateRequest; response=users.User

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 49
export const register = async (
  data: UserCreateRequest,
): Promise<{ data: User; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/register", data)) as {
    data: User;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/password/valid; name=validToken; method=POST; request=string; response=responses.SimpleResponse

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 58
export const validToken = async (
  data: string,
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/password/valid", data)) as {
    data: responses.SimpleResponse;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/me; name=me; method=GET; response=users.User

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 40
export const me = async (): Promise<{
  data: User;
  error: Nullable<string>;
}> => {
  return (await api.GET("/api/auth/me")) as {
    data: User;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/refresh; name=refresh; method=POST; request=users.RefreshRequest; response=tokens.TokenPair

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 46
export const refresh = async (
  data: RefreshRequest,
): Promise<{ data: tokens.TokenPair; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/refresh", data)) as {
    data: tokens.TokenPair;
    error: Nullable<string>;
  };
};

// Typescript: TSEndpoint= path=/api/auth/password/forgot; name=forgotPassword; method=POST; request=users.ForgotPasswordRequest; response=responses.SimpleResponse

// /Users/fabio/CODE/omnimed/go-quasar-partial-ssr/backend/internal/user/routes.go Line: 52
export const forgotPassword = async (
  data: ForgotPasswordRequest,
): Promise<{ data: responses.SimpleResponse; error: Nullable<string> }> => {
  return (await api.POST("/api/auth/password/forgot", data)) as {
    data: responses.SimpleResponse;
    error: Nullable<string>;
  };
};

export interface ResetPasswordRequest {
  token: string;
  password: string;
}

export interface UpdateUserRequest {
  uuid: string;
  name: string;
  email: string;
  password: string;
  permission: auth.Permission;
  status: UserStatus;
  types: UserTypes;
  avatar: Nullable<string>;
  details: Nullable<UserDetails>;
  preferences: Nullable<UserPreferences>;
}

export interface UpdatePasswordRequest {
  password: string;
}

export interface UserCreateRequest {
  name: string;
  email: string;
  password: string;
  permission: auth.Permission;
  status: UserStatus;
  types: UserTypes;
  avatar: Nullable<string>;
  details: Nullable<UserDetails>;
  preferences: Nullable<UserPreferences>;
}

export interface User {
  id: number;
  email: string;
  name: string;
  permission: auth.Permission;
  types: UserTypes;
  status: UserStatus;
  activatedAt: Nullable<Date>;
  uuid: string;
  details: Nullable<UserDetails>;
  preferences: Nullable<UserPreferences>;
  avatar: Nullable<string>;
  createdAt: Nullable<Date>;
  updatedAt: Nullable<Date>;
}

export interface UserDetails {
  id: number;
  userId: number;
  title: string;
  firstName: string;
  lastName: string;
  address: string;
  city: string;
  zipCode: string;
  country: string;
  phone: string;
  createdAt: Nullable<Date>;
  updatedAt: Nullable<Date>;
}

export interface UserPreferences {
  id: number;
  userId: number;
  useIdle: boolean;
  idleTimeout: number;
  useIdlePassword: boolean;
  idlePin: string;
  useDirectLogin: boolean;
  useQuadcodeLogin: boolean;
  sendNoticesMail: boolean;
  language: string;
  createdAt: Nullable<Date>;
  updatedAt: Nullable<Date>;
}

export interface ForgotPasswordRequest {
  email: string;
}

export interface LoginRequest {
  username: string;
  password: string;
}

export interface RefreshRequest {
  refresh_token: string;
}

export type UserStatus = string;

export type UserTypes = string[];

export const EnumUserStatus = {
  UserStatusPending: "pending",
  UserStatusActive: "active",
  UserStatusDisabled: "disabled",
} as const;
