feat: add CW members, opportunity create/update, and integrator interceptor
This commit is contained in:
@@ -14,6 +14,7 @@ import {
|
||||
CWForecastItemCreate,
|
||||
CWOpportunity,
|
||||
CWOpportunityNote,
|
||||
CWOpportunityUpdate,
|
||||
CWProcurementProduct,
|
||||
CWProcurementProductCreate,
|
||||
} from "../modules/cw-utils/opportunities/opportunity.types";
|
||||
@@ -292,6 +293,30 @@ export class OpportunityController {
|
||||
return new OpportunityController(updated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Opportunity
|
||||
*
|
||||
* Patches the opportunity in ConnectWise with the provided fields,
|
||||
* then syncs the updated data back to the local database.
|
||||
*
|
||||
* @param data — Partial fields to update on the CW opportunity
|
||||
* @returns A fresh OpportunityController with the updated data
|
||||
*/
|
||||
public async updateOpportunity(
|
||||
data: CWOpportunityUpdate,
|
||||
): Promise<OpportunityController> {
|
||||
const cwData = await opportunityCw.update(this.cwOpportunityId, data);
|
||||
const mapped = OpportunityController.mapCwToDb(cwData);
|
||||
|
||||
const updated = await prisma.opportunity.update({
|
||||
where: { id: this.id },
|
||||
data: mapped,
|
||||
include: { company: true },
|
||||
});
|
||||
|
||||
return new OpportunityController(updated);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch raw CW data
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user