69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
/**
|
|
* Configuração centralizada de API
|
|
*
|
|
* Este arquivo contém todas as configurações relacionadas aos endpoints da API.
|
|
* Para usar como template, basta modificar o BASE_URL e os endpoints conforme necessário.
|
|
*/
|
|
|
|
// Endpoint base da API
|
|
export const API_BASE_URL = "https://apmtests.webclientes.com/pt/app";
|
|
export const API_BASE_URL_DEV = "https://apmtests.webclientes.com/pt/app";
|
|
|
|
/**
|
|
* Endpoints da aplicação
|
|
* Adicione novos endpoints aqui conforme necessário
|
|
*/
|
|
export const API_ENDPOINTS = {
|
|
// Autenticação
|
|
USER_LOGIN: "/UserLogin",
|
|
USER_LOGOUT: "/UserLogout",
|
|
UPDATE_PROFILE: "/UserEditProfile",
|
|
RECOVER_PASSWORD: "/recoverPassword",
|
|
CONFIRM_TOKEN: "/confirmToken",
|
|
RESET_PASSWORD: "/resetPassword",
|
|
|
|
// Utilizador
|
|
USER_RESERVAS: "/getUserReservas",
|
|
USER_INFO: "/UserInfo",
|
|
GET_RESERVA: "/getReserva",
|
|
|
|
// Contactos
|
|
CONTACTS: "/contacts",
|
|
|
|
// Documentos
|
|
GET_DOCUMENTOS_CHECKSUMS: "/getDocumentosChecksums",
|
|
|
|
// Conta
|
|
DELETE_ACCOUNT: "/deleteAccount",
|
|
|
|
// Adicione mais endpoints aqui conforme necessário
|
|
} as const;
|
|
|
|
/**
|
|
* Constrói uma URL completa combinando o BASE_URL com o endpoint
|
|
*
|
|
* @param endpoint - O endpoint a ser adicionado ao BASE_URL (ex: "/UserLogin")
|
|
* @returns A URL completa
|
|
*
|
|
* @example
|
|
* buildApiUrl(API_ENDPOINTS.USER_LOGIN)
|
|
* // Retorna: "https://finalguru.webclientes.com/pt/app/UserLogin"
|
|
*/
|
|
export function buildApiUrl(endpoint: string): string {
|
|
// Remove barras duplicadas e garante que há apenas uma barra entre base e endpoint
|
|
const base = API_BASE_URL.replace(/\/$/, "");
|
|
const path = endpoint.startsWith("/") ? endpoint : `/${endpoint}`;
|
|
return `${base}${path}`;
|
|
}
|
|
|
|
/**
|
|
* Configurações adicionais da API (timeout, headers padrão, etc.)
|
|
*/
|
|
export const API_CONFIG = {
|
|
TIMEOUT: 30000, // 30 segundos
|
|
DEFAULT_HEADERS: {
|
|
"Content-Type": "application/json",
|
|
"Accept": "application/json",
|
|
},
|
|
} as const;
|