From e6fdcef5e3644a576dfd363aab183998b75c9ee1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Garc=C3=ADa=20M=C3=A9ndez?= Date: Tue, 17 Feb 2026 10:22:27 -0500 Subject: [PATCH] Switch public app client to v1 API paths. Update public API service endpoints and related tests to use `/api/public/v1` routes. --- src/services/api.js | 17 +++++++++-------- src/services/api.test.js | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/services/api.js b/src/services/api.js index 65b6af0..227c166 100644 --- a/src/services/api.js +++ b/src/services/api.js @@ -12,6 +12,7 @@ const getApiUrl = () => { }; const API_BASE_URL = getApiUrl(); +const PUBLIC_API_PREFIX = '/api/public/v1'; /** * Fetch wrapper que silencia errores 404 en la consola @@ -34,7 +35,7 @@ export const getInvestorData = async (email) => { } const encodedEmail = encodeURIComponent(email); - const url = `${API_BASE_URL}/api/public/investor/${encodedEmail}`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/investor/${encodedEmail}`; const response = await fetch(url); @@ -125,7 +126,7 @@ export const getInvestorHistory = async (email) => { } const encodedEmail = encodeURIComponent(email); - const url = `${API_BASE_URL}/api/public/investor/${encodedEmail}/history`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/investor/${encodedEmail}/history`; const response = await silentFetch(url); @@ -167,7 +168,7 @@ export const getInvestorHistory = async (email) => { */ export const getWallets = async () => { try { - const url = `${API_BASE_URL}/api/public/wallets`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/wallets`; const response = await silentFetch(url); if (!response.ok) { @@ -187,7 +188,7 @@ export const getWallets = async () => { */ export const getDepositOptions = async () => { try { - const url = `${API_BASE_URL}/api/public/deposit_options`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/deposit_options`; const response = await silentFetch(url); if (!response.ok) { @@ -213,7 +214,7 @@ export const getDepositOptions = async () => { */ export const createInvestorRequest = async (requestData) => { try { - const url = `${API_BASE_URL}/api/public/requests`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/requests`; const response = await silentFetch(url, { method: 'POST', @@ -243,7 +244,7 @@ export const createInvestorRequest = async (requestData) => { */ export const loginWithEmailPassword = async (email, password) => { try { - const url = `${API_BASE_URL}/api/public/auth/login`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/auth/login`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -271,7 +272,7 @@ export const loginWithEmailPassword = async (email, password) => { */ export const changeInvestorPassword = async (email, currentPassword, newPassword) => { try { - const url = `${API_BASE_URL}/api/public/auth/change_password`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/auth/change_password`; const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -305,7 +306,7 @@ export const validateInvestor = async (email) => { } const encodedEmail = encodeURIComponent(email); - const url = `${API_BASE_URL}/api/public/investor/${encodedEmail}`; + const url = `${API_BASE_URL}${PUBLIC_API_PREFIX}/investor/${encodedEmail}`; const response = await silentFetch(url); diff --git a/src/services/api.test.js b/src/services/api.test.js index 412bf6d..35da8eb 100644 --- a/src/services/api.test.js +++ b/src/services/api.test.js @@ -236,7 +236,7 @@ describe('api service', () => { expect(result.data).toBeDefined(); expect(result.error).toBeNull(); expect(mockFetch).toHaveBeenCalledWith( - expect.stringContaining('/api/public/requests'), + expect.stringContaining('/api/public/v1/requests'), expect.objectContaining({ method: 'POST', headers: expect.objectContaining({