MessageCampaignService

public interface MessageCampaignService

The MessageCampaignService allows the management of the message campaigns and the campaign enrollments. It is exposed as OSGi service.

Fields

MESSAGE_CAMPAIGNS_JSON_FILENAME

String MESSAGE_CAMPAIGNS_JSON_FILENAME

Methods

campaignCompleted

void campaignCompleted(String externalId, String campaignName)

See also: .unenroll(String,String)

deleteCampaign

void deleteCampaign(String campaignName)

Deletes a message campaign of the given name and stops all the enrollments to this campaign.

Parameters:
  • campaignName – the name of the campaign to delete

enroll

void enroll(CampaignRequest enrollRequest)

Enrolls the external ID into the campaign as specified in the request. The enrolled entity will have events raised against it, according to the campaign definition.

Parameters:
  • enrollRequest – the enrollment request

getAllCampaignRecords

List<CampaignRecord> getAllCampaignRecords()

Returns all CampaignRecords.

Returns:all campaign records.

getCampaignRecord

CampaignRecord getCampaignRecord(String campaignName)

Returns CampaignRecord of the provided name.

Parameters:
  • campaignName – the name of the campaign
Returns:

campaign record of the given name

getCampaignTimings

Map<String, List<DateTime>> getCampaignTimings(String externalId, String campaignName, DateTime startDate, DateTime endDate)

Gets the complete schedule of the messages to deliver for the given campaign name and the given external ID of the enrollment. The schedule contains messages sent after startDate and before endDate. It is returned as a map, indexed by message names.

Parameters:
  • externalId – external ID of the enrollment
  • campaignName – the name of the message campaign
  • startDate – the beginning of the time window, determining the included messages
  • endDate – the ending of the time window, determining the included messages

getLatestCampaignMessage

String getLatestCampaignMessage(String campaignName, String externalId)

Returns last message we attempted to send for the given campaign enrollment.

Parameters:
  • campaignName – the name of the campaign
  • externalId – the external ID of the enrollment
Returns:

the message key of the latest messsage

getNextCampaignMessage

String getNextCampaignMessage(String campaignName, String externalId)

Returns next message that will be sent for the given campaign enrollment.

Parameters:
  • campaignName – the name of the campaign
  • externalId – the external ID of the enrollment
Returns:

the message key of the next message

loadCampaigns

void loadCampaigns()

Loads message campaigns from the module settings and creates or updates necessary records, based on the loaded definition.

Throws:
  • IOException – in case of problems reading the module settings

rescheduleMessageJob

void rescheduleMessageJob(Long campaignMessageRecordId)

Reschedules all the jobs set up to send campaign messages for enrollments for the given campaign.

Parameters:
  • campaignMessageRecordId – one of the campaign’s message ID to reschedule jobs for

saveCampaign

void saveCampaign(CampaignRecord campaign)

Creates a new message campaign, provided a one with such name does not exist yet.

Parameters:
  • campaign – the campaign to create

scheduleJobsForEnrollment

void scheduleJobsForEnrollment(CampaignEnrollment enrollment)

Schedules jobs for the given campaign enrollment.

Parameters:
  • enrollment – the enrollment to schedule the jobs for

stopAll

void stopAll(CampaignEnrollmentsQuery query)

Unenrolls all campaign enrollments which match criteria provided in the CampaignEnrollmentsQuery.

Parameters:
  • query – the query containing criteria of the records to unenroll

stopAll

void stopAll(CampaignEnrollmentsQuery query, boolean deleteEnrollments)

Unenrolls and deletes all campaign enrollments which match criteria provided in the CampaignEnrollmentsQuery.

Parameters:
  • query – the query containing criteria of the records to unenroll and delete

unenroll

void unenroll(String externalId, String campaignName)

Unenrolls the external ID from the campaign as specified in the request. The entity will no longer receive events from the campaign.

Parameters:
  • externalId – a client defined ID to identify the enrollment
  • campaignName – the campaign from which the entity should be unenrolled

unscheduleJobsForEnrollment

void unscheduleJobsForEnrollment(CampaignEnrollment enrollment)

Unschedules all the jobs for the given campaign enrollment.

Parameters:
  • enrollment – the enrollment to unschedule jobs for

unscheduleMessageJob

void unscheduleMessageJob(CampaignMessageRecord campaignMessageRecord)

Unschedules all the jobs set up to send campaign messages for enrollments for the given campaign.

Parameters:
  • campaignMessageRecord – one of the campaign’s message to unschedule jobs for

updateEnrollment

void updateEnrollment(CampaignRequest enrollRequest, Long enrollmentId)

Updates existing campaign enrollment with data specified in the request.

Parameters:
  • enrollRequest – the enrollment request holding the data to update
  • enrollmentId – the ID of the enrollment

updateEnrollments

void updateEnrollments(Long campaignId)

Reschedules jobs for all active enrollments, assigned to the message campaign of the provided ID.

Parameters:
  • campaignId – the ID of the message campaign
Throws: