refactor: extract server-side CRM contact update

This commit is contained in:
2026-11-06 09:58:02 +00:00
parent ea5e90943d
commit 71de8a2d14
7 changed files with 190 additions and 147 deletions
@@ -1,4 +1,4 @@
import { updateAccount } from "../../../actions/services/accountService";
import { updateCrmContact } from "../../../lib/server/updateCrmContact";
import { hashAPIPath } from "../../../actions/core/hash";
import { consoleLogger } from "../../../actions/core/logger";
import {
@@ -59,10 +59,7 @@ ApiProxy.get(async (req, res) => {
});
}
if (
!isValidContainer(containerName) ||
!isValidTempCaseRef(tempCaseRef)
) {
if (!isValidContainer(containerName) || !isValidTempCaseRef(tempCaseRef)) {
return respondError(res, {
status: 400,
code: "INVALID_REQUEST",
@@ -158,13 +155,9 @@ ApiProxy.get(async (req, res) => {
if (typeofinvolvement != 846040000) {
void (async () => {
try {
await updateAccount(
contactId[1],
{
pinswg_typeofinvolvement: 846040001
},
true
);
await updateCrmContact(contactId[1], {
pinswg_typeofinvolvement: 846040001
});
} catch (error) {
consoleLogger(error);
}