Skip to content

Commit

Permalink
Feature/airflow trigger api (#4)
Browse files Browse the repository at this point in the history
* added identified stage trigger

* changed the name of object with standard Fields

* added return statement to  execute API

---------

Co-authored-by: Shubham Pawar <[email protected]>
  • Loading branch information
sanjana0190 and srp-pawar authored Apr 23, 2024
1 parent 32201d1 commit 3b1a0c1
Show file tree
Hide file tree
Showing 13 changed files with 398 additions and 144 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
coverage
.vercel

**/**/logs/**
**/**/logs/**
packages/twenty-server/src/campaign.zip
24 changes: 24 additions & 0 deletions packages/twenty-server/src/campaign/campaign-execution.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Type } from 'class-transformer';
import { IsISO8601, IsUUID, ValidateNested } from 'class-validator';

import { IdList } from 'src/campaign/id-list.dto';

export class CampaignExecutionDTO {
@IsUUID()
campaignId: string;

@IsISO8601({ strict: true })
queryTimestamp: string;

campaignTriggerId: string;

@IsISO8601({ strict: true })
startDate: Date;

@IsISO8601({ strict: true })
stopDate: Date;

@ValidateNested()
@Type(() => IdList)
id: IdList;
}
11 changes: 11 additions & 0 deletions packages/twenty-server/src/campaign/campaign.controller.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Body, Controller, Get, Param, Post } from '@nestjs/common';

import { CampaignExecutionDTO } from 'src/campaign/campaign-execution.dto';
import { CampaignService } from 'src/campaign/campaign.service';
import { FormDataDTO } from 'src/campaign/formdata.dto';
@Controller('/campaign')
Expand Down Expand Up @@ -27,4 +28,14 @@ export class CampaignController {
return error;
}
}

@Post('/execute')
async executeCampaign(@Body() campaignExecutionData: CampaignExecutionDTO) {
try {
return this.campaignService.triggerCampaignStartWorkflow(campaignExecutionData);
} catch (error) {
return error;
}
}

}
14 changes: 13 additions & 1 deletion packages/twenty-server/src/campaign/campaign.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ import { Module } from '@nestjs/common';

import { CampaignController } from 'src/campaign/campaign.controller';
import { CampaignService } from 'src/campaign/campaign.service';
import { CreateFormResponse } from 'src/campaign/create-form-response-query';
import { GetCampaignTrigger } from 'src/campaign/get-campaign-trigger-query';
import { GetFormTemplate } from 'src/campaign/get-form-template-query';
import { GetLeadData } from 'src/campaign/get-lead-query';
import { GetOpportunityData } from 'src/campaign/get-opportunity-query';

@Module({
imports: [],
controllers: [CampaignController],
providers: [CampaignService],
providers: [
CampaignService,
CreateFormResponse,
GetCampaignTrigger,
GetFormTemplate,
GetLeadData,
GetOpportunityData,
],
})
export class CampaignModule {}
Loading

0 comments on commit 3b1a0c1

Please sign in to comment.