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.

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

Last updated

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