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
+44 -79
View File
@@ -1,35 +1,25 @@
import axios from "axios";
import { BASE_URL } from "../core/env";
import { consoleLogger } from "../core/logger";
import { buildHashedQueryUrl } from "../clients/relayClient";
import { getJson, requestJson } from "../clients/endpointClient";
export const getPersonalAccount = (contactid) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getpersonalaccount_api?contactid=" +
contactid
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return getJson(
BASE_URL + "/api/endpoint/getpersonalaccount_api?contactid=" + contactid
).catch((error) => {
consoleLogger(error);
});
};
export const getLogin = (emailAddress, pwd) => {
return axios
.get(
"/api/endpoint/getlogin_api?emailAddress=" +
emailAddress +
"&pwd=" +
pwd
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getlogin_api?emailAddress=" +
emailAddress +
"&pwd=" +
pwd
).catch((error) => {
consoleLogger(error);
});
};
export const updatePassword = (contactId, newpassword) => {
@@ -41,13 +31,9 @@ export const updatePassword = (contactId, newpassword) => {
data: data
};
return axios(config)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return requestJson(config).catch((error) => {
consoleLogger(error);
});
};
export const updateAccount = async (contactId, updateBody, ssr) => {
@@ -61,13 +47,9 @@ export const updateAccount = async (contactId, updateBody, ssr) => {
url: queryUrl,
data: data
};
return axios(config)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return requestJson(config).catch((error) => {
consoleLogger(error);
});
};
export const createAccount = (formValues) => {
@@ -79,67 +61,50 @@ export const createAccount = (formValues) => {
data: data
};
return axios(config)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
});
return requestJson(config).catch((error) => {
consoleLogger(error);
});
};
export const getEmailAccountCheck = (emailAddress) => {
return axios
.get(
"/api/endpoint/getemailaccountcheck_api?emailAddress=" +
emailAddress
)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
});
return getJson(
"/api/endpoint/getemailaccountcheck_api?emailAddress=" + emailAddress
).catch((error) => {
consoleLogger(error);
});
};
export const getPortalLogin = async (emailAddress) => {
var queryUrl =
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
return axios
.get(BASE_URL + (await buildHashedQueryUrl(queryUrl)))
.then((res) => res.data)
.catch((error) => {
return getJson(BASE_URL + (await buildHashedQueryUrl(queryUrl))).catch(
(error) => {
consoleLogger(error);
return JSON.stringify(error);
});
}
);
};
export const getPortalLoginProxy = async (emailAddress) => {
var queryUrl =
"/api/endpoint/getportalloginproxy_api?emailAddress=" + emailAddress;
return axios
.get(queryUrl)
.then((res) => res.data)
.catch((error) => {
consoleLogger(error);
return getJson(queryUrl).catch((error) => {
consoleLogger(error);
return JSON.stringify(error);
});
return JSON.stringify(error);
});
};
export const getPreferredLanguage = async (email) => {
return axios
.get(
BASE_URL +
"/api/endpoint/getpreferredlanguage_api?emailAddress=" +
email
)
.then((res) => {
return res.data;
})
.catch((error) => {
consoleLogger(error);
return error.response;
});
return getJson(
BASE_URL +
"/api/endpoint/getpreferredlanguage_api?emailAddress=" +
email
).catch((error) => {
consoleLogger(error);
return error.response;
});
};
+31
View File
@@ -1513,3 +1513,34 @@ Validation:
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.
---
### 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.