Skip to content

Commit

Permalink
updated request body for campaign trigger and created api
Browse files Browse the repository at this point in the history
  • Loading branch information
srp-pawar committed Apr 30, 2024
1 parent 83aec61 commit 26033f1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
11 changes: 11 additions & 0 deletions packages/twenty-server/src/campaign/campaign.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,16 @@ export class CampaignController {
return error;
}
}
@Post('/lead/register/:id')
executeLeadRegistration(@Param() id: any,@Body() data:any){
// console.log(id.id)
try {
console.log(id.id)
this.campaignService.triggerLeadRegistrationWorkflow(id.id);
return true
} catch (error) {
return error;
}
}

}
28 changes: 28 additions & 0 deletions packages/twenty-server/src/campaign/campaign.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,41 @@ import { response } from 'express';

@Injectable()
export class CampaignService {

constructor(
private createFormResponse: CreateFormResponse,
private getCampaignTrigger: GetCampaignTrigger,
private getFormTemplate: GetFormTemplate,
private getLeadData: GetLeadData,
private getOpportunityData: GetOpportunityData,
) {}

async triggerLeadRegistrationWorkflow(id: any) {
const data={
conf:{
patient_uuid:id
}
}
try {
let response = await fetch(
`${process.env.AIRFLOW_HOST}/api/v1/dags/${process.env.DAG_CONTACTED_OPPORTUNITIES}/dagRuns`,
{
method: 'post',
body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json',
Authorization: `Basic ${process.env.AIRFLOW_AUTH_TOKEN}`,
},
},
);

response = await response.json();
console.log(response)
return response;
} catch (error) {
return error;
}
}

async triggerIdentifiedWorkflow(requestBody: any) {
const data = {
Expand Down
8 changes: 2 additions & 6 deletions packages/twenty-server/src/campaign/id-list.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,8 @@ import { IdDto } from 'src/campaign/id.dto';

export class IdList {
@IsOptional()
@ValidateNested({ each: true })
@Type(() => IdDto)
selectedID: IdDto[];
selectedID: [];

@IsOptional()
@ValidateNested({ each: true })
@Type(() => IdDto)
unselectedID: IdDto[];
unselectedID: [];
}

0 comments on commit 26033f1

Please sign in to comment.