Manage Campaign 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.
Conditional template generation call
If boundaries are different from campaign in db, call:
Facility template generate
User template generate
Target template generate
If delivery conditions are different, call:
Target template generate
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
Search Process Tracks
Endpoint
POST /project-type/getProcessTrack
Request Structure
Query Parameters:
campaignId: Unique ID of the campaign.
Response Structure
Success Response:
ResponseInfo: Object containing ResponseInfo details.
processTrack: Array containing process tracks of the matching campaign.
Flow
Client Initiates Request
The client sends a request to retrieve process tracks for a specific campaign by providing the
campaignId
.
Validation of Request
The Project Factory Service validates the provided
campaignId
to ensure it meets the expected format and constraints.
Fetch Process Tracks
The Project Factory Service constructs a query to fetch process tracks associated with the provided
campaignId
.The service executes the query against the database to retrieve the process tracks.
Response
The Project Factory Service formats the retrieved process tracks and packages them into the response.
The response includes the
ResponseInfo
and an array ofprocessTrack
details.
Send Response to Client
The Project Factory Service sends the response back to the client containing the process track details for the specified campaign.
Steps and Statuses in Campaign Creation
processTrackTypes
(Steps)
processTrackTypes
(Steps)This defines various types of process tracks, each representing a specific stage or action in the campaign creation process. These types can be used to categorize and identify different steps or activities within the campaign workflow. Here's what each type represents:
validation: Represents the validation stage of the campaign creation process, where data or conditions are checked for correctness.
triggerResourceCreation: Indicates the step where resources are created based on triggers or conditions.
facilityCreation: Refers to the creation of facilities or resources required for the campaign.
staffCreation: Involves the creation of staff members necessary for the campaign.
targetAndDeliveryRulesCreation: Represents the creation of rules related to targets and delivery mechanisms (project creation step).
confirmingResourceCreation: Involves confirming that resources have been successfully created.
prepareResourceForMapping: The stage where resources are prepared for mapping to projects.
validateMappingResource: Represents the validation of resources after they have been mapped.
staffMapping: Involves mapping staff to projects.
resourceMapping: Represents the mapping of various resources to projects.
facilityMapping: Refers to mapping facilities to projects.
campaignCreation: Represents the creation of the campaign itself (final step).
error: Indicates that an error occurred during the campaign creation process.
processTrackStatuses
processTrackStatuses
This object defines different statuses that a process track can have, reflecting the state or progress of a particular step in the campaign creation process. Here are the statuses and their meanings:
inprogress: Indicates that the process or task within the campaign creation process is currently ongoing and has not yet been completed.
completed: Represents that the process or task within the campaign creation process has been successfully finished.
toBeCompleted: Refers to processes or tasks within the campaign creation process that are scheduled or pending completion in the future.
failed: Signifies that the process or task within the campaign creation process encountered an error or failed to execute as intended.
Flow Diagram
Last updated