getOffersForMultipleInteractionPoints
getOffersForMultipleInteractionPoints(String sessionID, String requestStr)
The getOffersForMultipleInteractionPoints method enables you to request offers from the runtime server for multiple IPs with deduplication.
*
sessionID - a string identifying the current session.
*
requestStr - a string providing an array of GetOfferRequest objects.
Each GetOfferRequest object specifies:
*
ipName - The interaction point (IP) name for which the object is requesting offers
*
numberRequested - The number of unique offers it needs for the specified IP
*
offerAttributes - Requirements on the attributes of the delivered offers using an instance of OfferAttributeRequirements
*
duplicationPolicy - Duplication policy ID for the offers that will be delivered
Duplication policies determine whether duplicated offers will be returned across different interaction points in a single method call. (Within an individual interaction point, duplicated offers are never returned.) Currently, two duplication policies are supported.
*
NO_DUPLICATION (ID value = 1). None of the offers that have been included in the preceding GetOfferRequest instances will be included in this GetOfferRequest instance (that is, Interact will apply de-duplication).
*
ALLOW_DUPLICATION (ID value = 2). Any of the offers satisfying the requirements specified in this GetOfferRequest instance will be included. The offers that have been included in the preceding GetOfferRequest instances will not be reconciled.
The order of requests in the array parameter is also the priority order when offers are being delivered.
For example, suppose the IPs in the request are IP1, then IP2, that no duplicated offers are allowed (a duplication policy ID = 1), and each is requesting two offers. If Interact finds offers A, B, and C for IP1 and offers A and D for IP2, the response will contain offers A and B for IP1, and only offer D for IP2.
Also note that when the duplication policy ID is 1, the offers that have been delivered via an IP with higher priority will not be delivered via this IP.
The getOffersForMultipleInteractionPoints method waits the number of milliseconds defined in the segmentationMaxWaitTimeInMS property for all re-segmentation to complete before running. Therefore, if you call a postEvent method which triggers a re-segmentation or a setAudience method immediately before a getOffers call, there may be a delay.
Return value
The runtime server responds to getOffersForMultipleInteractionPoints with a Response object with the following attributes populated:
*
*
*
*
*
Example
InteractAPI api = InteractAPI.getInstance("url");
String sessionId = "123";
String requestForIP1 = "{IP1,5,1,(5,attr1=1|numeric;attr2=value2|string,
(3,attr3=value3|string)(3,attr4=4|numeric))}";
String requestForIP2 = "{IP2,3,2,(3,attr5=value5|string)}";
String requestForIP3 = "{IP3,2,1}";
String requestStr = requestForIP1 + requestForIP2 + requestForIP3;
Response response = api.getOffersForMultipleInteractionPoints(sessionId,
requestStr);

if (response.getStatusCode() == Response.STATUS_SUCCESS) {
// Check to see if there are any offers
OfferList[] allOfferLists = response.getAllOfferLists();
if (allOfferLists != null) {
for (OfferList ol : allOfferLists) {
System.out.println("The following offers are delivered for interaction
point " + ol.getInteractionPointName() + ":");
for (Offer o : ol.getRecommendedOffers()) {
System.out.println(o.getOfferName());
}
}
}
}
else {
System.out.println("getOffersForMultipleInteractionPoints() method calls
returns an error with code: " + response.getStatusCode());
}
Note that the syntax of the requestStr is the following:
requests_for_IP[<requests_for_IP]
where
<requests_for_IP> = {ip_name,number_requested_for_this_ip,
dupe_policy[,child_requirements]]}
attribute_requirements = (number_requested_for_these_attribute_requirements
[,attribute_requirement[;individual_attribute_requirement])
[,(attribute_requirements))
individual_attribute_requirement = attribute_name=attribute_value | attribute_type
In the example shown above, requestForIP1 ({IP1,5,1,(5,attr1=1|numeric; attr2=value2|string, (3,attr3=value3|string)(3,attr4=4|numeric))}) means, for the interaction point named IP1, deliver at most 5 distinct offers that can not also be returned for any other interaction points during this same method call. All of those 5 offers must have a numeric attribute named attr1 which must have the value 1, and must have a string attribute named attr2 which must have the value value2. Out of those 5 offers, a maximum of 3 must have a string attribute named attr3 which must have the value value3, and a maximum of 3 must have a numeric attribute named attr4 which must have the value 4.
The allowed attribute types are numeric, string, and datetime, and the format of a datetime attribute value must be MM/dd/yyyy HH:mm:ss. To retrieve the returned offers, use the method Response.getAllOfferLists(). To help understand the syntax, the example in setGetOfferRequests builds the same instance of GetOfferRequests, while using Java objects, which is preferred.