Package com.swrve.sdk.messaging
Class SwrveBaseCampaign
- java.lang.Object
-
- com.swrve.sdk.messaging.SwrveBaseCampaign
-
- Direct Known Subclasses:
SwrveConversationCampaign
,SwrveEmbeddedCampaign
,SwrveInAppCampaign
public abstract class SwrveBaseCampaign extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected SwrveCampaignDisplayer
campaignDisplayer
protected ISwrveCampaignManager
campaignManager
protected static int
DEFAULT_DELAY_FIRST_MESSAGE
protected static int
DEFAULT_MAX_IMPRESSIONS
protected static int
DEFAULT_MIN_DELAY_BETWEEN_MSGS
protected java.util.Date
endDate
protected int
id
protected int
maxImpressions
protected boolean
messageCenter
protected int
minDelayBetweenMessage
protected java.lang.String
name
protected SwrveCampaignState
saveableState
protected java.util.Date
showMessagesAfterLaunch
protected java.util.Date
startDate
protected java.lang.String
subject
protected java.util.List<Trigger>
triggers
-
Constructor Summary
Constructors Constructor Description SwrveBaseCampaign(ISwrveCampaignManager campaignManager, SwrveCampaignDisplayer campaignDisplayer, org.json.JSONObject campaignData)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract boolean
areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
Determine if the assets for this campaign have been downloaded.abstract com.swrve.sdk.QaCampaignInfo.CAMPAIGN_TYPE
getCampaignType()
Used by QAUser to determine what kind of campaign we are reportingjava.util.Date
getEndDate()
int
getId()
int
getImpressions()
int
getMaxImpressions()
java.lang.String
getName()
SwrveCampaignState
getSaveableState()
Obtain the serializable state of the campaign.java.util.Date
getShowMessagesAfterLaunch()
java.util.Date
getStartDate()
SwrveCampaignState.Status
getStatus()
Get the status of the campaign.java.lang.String
getSubject()
java.util.List<Trigger>
getTriggers()
void
incrementImpressions()
Increment impressions by one.boolean
isActive(java.util.Date date)
boolean
isMessageCenter()
Used internally to identify campaigns that have been marked as MessageCenter campaigns on the dashboard.void
messageWasShownToUser()
Used by sublcasses to inform that the campaign was displayed.void
setImpressions(int impressions)
protected void
setMessageMinDelayThrottle()
Ensures a new message cannot be shown until now + minDelayBetweenMessagevoid
setSaveableState(SwrveCampaignState saveableState)
Set the previous state of this campaign.void
setStatus(SwrveCampaignState.Status status)
Used internally to set the status of the campaign.abstract boolean
supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
-
-
-
Field Detail
-
DEFAULT_DELAY_FIRST_MESSAGE
protected static int DEFAULT_DELAY_FIRST_MESSAGE
-
DEFAULT_MAX_IMPRESSIONS
protected static int DEFAULT_MAX_IMPRESSIONS
-
DEFAULT_MIN_DELAY_BETWEEN_MSGS
protected static int DEFAULT_MIN_DELAY_BETWEEN_MSGS
-
campaignManager
protected ISwrveCampaignManager campaignManager
-
campaignDisplayer
protected SwrveCampaignDisplayer campaignDisplayer
-
id
protected int id
-
saveableState
protected SwrveCampaignState saveableState
-
startDate
protected java.util.Date startDate
-
endDate
protected java.util.Date endDate
-
triggers
protected java.util.List<Trigger> triggers
-
messageCenter
protected boolean messageCenter
-
subject
protected java.lang.String subject
-
maxImpressions
protected int maxImpressions
-
minDelayBetweenMessage
protected int minDelayBetweenMessage
-
showMessagesAfterLaunch
protected java.util.Date showMessagesAfterLaunch
-
name
protected java.lang.String name
-
-
Constructor Detail
-
SwrveBaseCampaign
public SwrveBaseCampaign(ISwrveCampaignManager campaignManager, SwrveCampaignDisplayer campaignDisplayer, org.json.JSONObject campaignData) throws org.json.JSONException
- Throws:
org.json.JSONException
-
-
Method Detail
-
getId
public int getId()
- Returns:
- the campaign id.
-
isMessageCenter
public boolean isMessageCenter()
Used internally to identify campaigns that have been marked as MessageCenter campaigns on the dashboard.- Returns:
- true if the campaign is an MessageCenter campaign.
-
getSubject
public java.lang.String getSubject()
- Returns:
- the name of the campaign.
-
isActive
public boolean isActive(java.util.Date date)
- Parameters:
date
- Current date- Returns:
- true if the campaign is active at the given time.
-
getTriggers
public java.util.List<Trigger> getTriggers()
- Returns:
- the triggers for this campaign.
-
getImpressions
public int getImpressions()
- Returns:
- current impressions
-
setImpressions
public void setImpressions(int impressions)
-
getMaxImpressions
public int getMaxImpressions()
- Returns:
- maximum impressions
-
getStartDate
public java.util.Date getStartDate()
- Returns:
- the campaign start date.
-
getEndDate
public java.util.Date getEndDate()
- Returns:
- the campaign end date.
-
incrementImpressions
public void incrementImpressions()
Increment impressions by one.
-
setMessageMinDelayThrottle
protected void setMessageMinDelayThrottle()
Ensures a new message cannot be shown until now + minDelayBetweenMessage
-
setStatus
public void setStatus(SwrveCampaignState.Status status)
Used internally to set the status of the campaign.- Parameters:
status
- new status of the campaign
-
getStatus
public SwrveCampaignState.Status getStatus()
Get the status of the campaign.- Returns:
- status of the campaign
-
messageWasShownToUser
public void messageWasShownToUser()
Used by sublcasses to inform that the campaign was displayed.
-
supportsOrientation
public abstract boolean supportsOrientation(com.swrve.sdk.messaging.SwrveOrientation orientation)
-
getCampaignType
public abstract com.swrve.sdk.QaCampaignInfo.CAMPAIGN_TYPE getCampaignType()
Used by QAUser to determine what kind of campaign we are reporting- Returns:
- CAMPAIGN_TYPE enum
-
areAssetsReady
public abstract boolean areAssetsReady(java.util.Set<java.lang.String> assetsOnDisk, java.util.Map<java.lang.String,java.lang.String> properties)
Determine if the assets for this campaign have been downloaded.- Parameters:
assetsOnDisk
- All assets that are already downloaded.properties
- String map of personalized properties.- Returns:
- if the assets are ready
-
getSaveableState
public SwrveCampaignState getSaveableState()
Obtain the serializable state of the campaign.- Returns:
- the serializable state of the campaign.
-
setSaveableState
public void setSaveableState(SwrveCampaignState saveableState)
Set the previous state of this campaign.- Parameters:
saveableState
- The state to save
-
getShowMessagesAfterLaunch
public java.util.Date getShowMessagesAfterLaunch()
-
getName
public java.lang.String getName()
- Returns:
- the campaign name
-
-