refactor(actions): adopt endpoint client in account direct service

This commit is contained in:
2026-03-25 06:23:12 +00:00
parent eb3b6013b3
commit a74f59394e
2 changed files with 75 additions and 79 deletions
+19 -54
View File
@@ -1,33 +1,23 @@
import axios from "axios";
import { BASE_URL } from "../core/env"; import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger"; import { consoleLogger } from "../core/logger";
import { buildHashedQueryUrl } from "../clients/relayClient"; import { buildHashedQueryUrl } from "../clients/relayClient";
import { getJson, requestJson } from "../clients/endpointClient";
export const getPersonalAccount = (contactid) => { export const getPersonalAccount = (contactid) => {
return axios return getJson(
.get( BASE_URL + "/api/endpoint/getpersonalaccount_api?contactid=" + contactid
BASE_URL + ).catch((error) => {
"/api/endpoint/getpersonalaccount_api?contactid=" +
contactid
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
export const getLogin = (emailAddress, pwd) => { export const getLogin = (emailAddress, pwd) => {
return axios return getJson(
.get(
"/api/endpoint/getlogin_api?emailAddress=" + "/api/endpoint/getlogin_api?emailAddress=" +
emailAddress + emailAddress +
"&pwd=" + "&pwd=" +
pwd pwd
) ).catch((error) => {
.then((res) => res.data)
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
@@ -41,11 +31,7 @@ export const updatePassword = (contactId, newpassword) => {
data: data data: data
}; };
return axios(config) return requestJson(config).catch((error) => {
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
@@ -61,11 +47,7 @@ export const updateAccount = async (contactId, updateBody, ssr) => {
url: queryUrl, url: queryUrl,
data: data data: data
}; };
return axios(config) return requestJson(config).catch((error) => {
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
@@ -79,23 +61,15 @@ export const createAccount = (formValues) => {
data: data data: data
}; };
return axios(config) return requestJson(config).catch((error) => {
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
export const getEmailAccountCheck = (emailAddress) => { export const getEmailAccountCheck = (emailAddress) => {
return axios return getJson(
.get( "/api/endpoint/getemailaccountcheck_api?emailAddress=" + emailAddress
"/api/endpoint/getemailaccountcheck_api?emailAddress=" + ).catch((error) => {
emailAddress
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error); consoleLogger(error);
}); });
}; };
@@ -104,24 +78,20 @@ export const getPortalLogin = async (emailAddress) => {
var queryUrl = var queryUrl =
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress; "/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
return axios return getJson(BASE_URL + (await buildHashedQueryUrl(queryUrl))).catch(
.get(BASE_URL + (await buildHashedQueryUrl(queryUrl))) (error) => {
.then((res) => res.data)
.catch((error) => {
consoleLogger(error); consoleLogger(error);
return JSON.stringify(error); return JSON.stringify(error);
}); }
);
}; };
export const getPortalLoginProxy = async (emailAddress) => { export const getPortalLoginProxy = async (emailAddress) => {
var queryUrl = var queryUrl =
"/api/endpoint/getportalloginproxy_api?emailAddress=" + emailAddress; "/api/endpoint/getportalloginproxy_api?emailAddress=" + emailAddress;
return axios return getJson(queryUrl).catch((error) => {
.get(queryUrl)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error); consoleLogger(error);
return JSON.stringify(error); return JSON.stringify(error);
@@ -129,16 +99,11 @@ export const getPortalLoginProxy = async (emailAddress) => {
}; };
export const getPreferredLanguage = async (email) => { export const getPreferredLanguage = async (email) => {
return axios return getJson(
.get(
BASE_URL + BASE_URL +
"/api/endpoint/getpreferredlanguage_api?emailAddress=" + "/api/endpoint/getpreferredlanguage_api?emailAddress=" +
email email
) ).catch((error) => {
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error); consoleLogger(error);
return error.response; return error.response;
}); });
+31
View File
@@ -1513,3 +1513,34 @@ Validation:
Follow-ups: Follow-ups:
- Next optional bounded slice: adopt `getJson`/`requestJson` for selected low-risk read paths in `searchDirectService` or `caseDirectService` while preserving per-function error semantics. - Next optional bounded slice: adopt `getJson`/`requestJson` for selected low-risk read paths in `searchDirectService` or `caseDirectService` while preserving per-function error semantics.
---
### CL-041: TASK22260 next slice — account direct service endpointClient adoption
date: 2026-03-25
author: Cline
scope: `actions/services/accountDirectService.js`
type: change
rationale: Continue incremental façade migration by moving account direct-service request plumbing onto shared endpoint client helpers while preserving existing error-return behavior contracts.
impact: Reduces duplicated axios response extraction boilerplate and aligns account service request handling with the emerging client-layer pattern.
status: completed
Summary:
- Refactored `actions/services/accountDirectService.js` to consume shared endpoint client helpers:
- `getJson(...)` for GET requests
- `requestJson(...)` for config-based POST requests
- Kept existing relay hash-signing behavior unchanged via `buildHashedQueryUrl` from `relayClient`.
- Preserved existing catch-path semantics, including:
- logging with `consoleLogger`
- returning `JSON.stringify(error)` in portal login functions
- returning `error.response` in preferred-language failure path
Validation:
- `npm run lint` -> warnings only (pre-existing `react-hooks/exhaustive-deps`; no new lint errors)
Follow-ups:
- Optional next bounded slice: adopt endpoint client helpers in selected `portalDirectService` GET/POST helper paths while preserving delete/hash flow semantics.