Campaign Manage APIs
The documentation details the API endpoints for creating, updating, and searching project type campaigns. It includes request and response structures, validation steps, and flow diagrams.
Create Campaign
Endpoint
POST /project-type/create
Request Structure
Body Parameters
RequestInfo: Object containing RequestInfo.
CampaignDetails: Object containing the details of the campaign to be created.
tenantId: Tenant identifier.
hierarchyType: Type of hierarchy.
action: Action type (
create
ordraft
).boundaries: Array of boundaries.
resources: Array of resources.
projectType: Type of the project.
deliveryRules: Array of delivery rules.
Additional request info
Response Structure
Success Response
ResponseInfo: Object containing ResponseInfo.
CampaignDetails: The created campaign details.
Flow
Client Initiates Request
The client initiates a createCampaign request to the Project Factory Service.
Validation of Request
If the action is 'create':
The Project Factory Service validates the request schema.
It also validates the uniqueness of the campaign name in the database.
If the campaign name exists, an error is thrown.
If the action is 'draft':
The Project Factory Service validates the request schema.
It also validates the uniqueness of the campaign name in the database.
If the campaign name exists, an error is thrown.
Boundary and MDMS Validation
For both 'create' and 'draft' actions:
The Project Factory Service validates the request for hierarchy type and boundaries with the Boundary Service.
It validates the request for project type code from MDMS.
Campaign Creation
If the action is 'create':
The Project Factory Service validates the request for data resources.
It enriches the CampaignDetails and sets the status to 'creating'.
The CampaignDetails are persisted in the database.
For each resource data, the Project Factory Service creates resources through the
/project-factory/v1/data/_create
API.It enriches boundaries for project creation and creates projects for each boundary with the Health Project Service.
The enriched CampaignDetails are persisted in the database.
The CampaignDetails object is sent to a Kafka topic for project mappings.
If the campaign status is not "created", project mappings are performed through the
/project-factory/v1/project-type/createCampaign
API and the status is updated to 'created'.If the campaign status is already 'created', an error is thrown, and the status is updated to 'failed'.
If the action is 'draft':
The CampaignDetails are enriched, and the status is set to 'drafted;.
The enriched CampaignDetails are persisted in the database.
Response
The Project Factory Service sends the response back to the client.
Flow Diagram
Update Project Type Campaign
Endpoint
POST /project-type/update
Request Structure
Body Parameters
RequestInfo: Object containing RequestInfo.
CampaignDetails: Object containing the details of the campaign to be updated.
id: Unique identifier of the campaign.
tenantId: Tenant identifier.
hierarchyType: Type of hierarchy.
action: Action type (
create
ordraft
).boundaries: Array of boundaries.
resources: Array of resources.
projectType: Type of the project.
deliveryRules: Array of delivery rules.
Response Structure
Success Response
ResponseInfo: Object containing ResponseInfo.
CampaignDetails: The updated campaign details.
Flow
Receive Request
The ProjectFactoryService receives an updateCampaign request from the Client.
Validate Request Schema
The received request schema is validated to ensure it matches the expected format.
Check Campaign Existence
The system checks if the campaign specified in the request exists in the database.
Check Campaign Status
If the campaign exists, the system checks its status in the database.
Handle Drafted Status
If the campaign status is 'drafted':
Validate Boundaries: Validate the request for hierarchyType and boundaries.
Validate Project Type: It validates the request for project type code from MDMS.
Enrich Campaign Details: Enrich the campaign details and set the status to 'updating'.
Update Campaign Details: Update the campaign details in the database.
Update Resource Data: Update each resource data associated with the campaign through the
/project-factory/v1/data/_update
API.Enrich Boundaries: Enrich the boundaries for the project update.
Update Projects: Update projects associated with each boundary.
Persist Changes: Persist the updated campaign details in the database.
Send to Kafka Topic: Send the updated CampaignDetails object to the Kafka topic for project mappings.
Listen to Kafka: Listen for updates from the Kafka topic to get the updated CampaignDetails object for project mappings.
Handle Campaign Status
If the campaign status is not 'created':
Do project mapping through
/project-factory/v1/project-type/createCampaign
API.Enrich the CampaignDetails and set the status to 'created'.
Update the CampaignDetail in the database.
Handle Project Mapping Error
If the campaign status is 'created':
Throw an error indicating that the project is already mapped for this campaign.
Enrich the CampaignDetails and set the status to 'failed'.
Update the CampaignDetail in the database.
Handle Non-Drafted Status
If the campaign status is not 'drafted', the system throws an error indicating that only drafted campaigns can be updated.
Send Response
The ProjectFactoryService sends a response to the Client based on the outcome of the update operation.
Flow Diagram
Search Project Type Campaign
Endpoint
POST /project-type/search
Request Structure
Body Parameters
RequestInfo: Object containing RequestInfo.
CampaignDetails: Object containing the search criteria for campaigns.
tenantId: Tenant identifier.
ids: Array of campaign IDs to search for.
startDate: The start date for the search.
endDate: End date for the search.
projectType: Type of the project.
campaignName: Name of the campaign.
status: Status of the campaign.
createdBy: Creator of the campaign.
campaignNumber: Number of the campaign.
campaignsIncludeDates: Flag to include campaigns based on dates.
pagination: Object containing pagination settings.
limit: Maximum number of results to return.
offset: Offset for paginated results.
sortOrder: Sort order for results (asc/desc).
sortBy: Field to sort results by.
Response Structure
Success Response
ResponseInfo: Object containing ResponseInfo details.
CampaignDetails: Array containing details of matching campaigns.
totalCount: Total number of matching campaigns.
Flow
Client Initiates Request
The client sends a searchCampaign request to the Project Factory Service.
Validation of Request
The Project Factory Service validates the request schema and search criteria.
Search Campaigns
The Project Factory Service constructs a search query based on the provided criteria.
It checks if there are specific search fields like start date, end date, campaign name, etc.
Depending on the
campaignsIncludeDates
flag, the service adjusts the search conditions accordingly.If
campaignsIncludeDates
is true:It shows only those campaigns whose start date is on or before the provided start date and whose end date is on or after the provided end date.
If
campaignsIncludeDates
is false:It shows only those campaigns whose start date is on or after the provided start date and whose end date is on or before the provided end date.
The service executes the constructed query to retrieve matching campaign details from the database.
Response
The Project Factory Service sends the response back to the client.
The response contains the matching campaign details along with the total count, if applicable.
Flow Diagram
Last updated