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 or draft).

  • 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':

  1. The Project Factory Service validates the request schema.

  2. It also validates the uniqueness of the campaign name in the database.

  3. If the campaign name exists, an error is thrown.

If the action is 'draft':

  1. The Project Factory Service validates the request schema.

  2. It also validates the uniqueness of the campaign name in the database.

  3. If the campaign name exists, an error is thrown.

Boundary and MDMS Validation

For both 'create' and 'draft' actions:

  1. The Project Factory Service validates the request for hierarchy type and boundaries with the Boundary Service.

  2. It validates the request for project type code from MDMS.

Campaign Creation

If the action is 'create':

  1. The Project Factory Service validates the request for data resources.

  2. It enriches the CampaignDetails and sets the status to 'creating'.

  3. The CampaignDetails are persisted in the database.

  4. For each resource data, the Project Factory Service creates resources through the /project-factory/v1/data/_create API.

  5. It enriches boundaries for project creation and creates projects for each boundary with the Health Project Service.

  6. The enriched CampaignDetails are persisted in the database.

  7. The CampaignDetails object is sent to a Kafka topic for project mappings.

  8. 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'.

  9. If the campaign status is already 'created', an error is thrown, and the status is updated to 'failed'.

If the action is 'draft':

  1. The CampaignDetails are enriched, and the status is set to 'drafted;.

  2. 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 or draft).

  • 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':

  1. Validate Boundaries: Validate the request for hierarchyType and boundaries.

  2. Validate Project Type: It validates the request for project type code from MDMS.

  3. Enrich Campaign Details: Enrich the campaign details and set the status to 'updating'.

  4. Update Campaign Details: Update the campaign details in the database.

  5. Update Resource Data: Update each resource data associated with the campaign through the /project-factory/v1/data/_update API.

  6. Enrich Boundaries: Enrich the boundaries for the project update.

  7. Update Projects: Update projects associated with each boundary.

  8. Persist Changes: Persist the updated campaign details in the database.

  9. Send to Kafka Topic: Send the updated CampaignDetails object to the Kafka topic for project mappings.

  10. 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':

  1. Do project mapping through /project-factory/v1/project-type/createCampaign API.

  2. Enrich the CampaignDetails and set the status to 'created'.

  3. Update the CampaignDetail in the database.

Handle Project Mapping Error

If the campaign status is 'created':

  1. Throw an error indicating that the project is already mapped for this campaign.

  2. Enrich the CampaignDetails and set the status to 'failed'.

  3. 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

  1. Client Initiates Request

    • The client sends a request to retrieve process tracks for a specific campaign by providing the campaignId.

  2. Validation of Request

    • The Project Factory Service validates the provided campaignId to ensure it meets the expected format and constraints.

  3. 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.

  4. Response

    • The Project Factory Service formats the retrieved process tracks and packages them into the response.

    • The response includes the ResponseInfo and an array of processTrack details.

  5. 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)

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

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

All content on this page by eGov Foundation is licensed under a Creative Commons Attribution 4.0 International License.