use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluator method allViewNames.
private List<String> allViewNames(TargetDeliveryRequest request) {
if (request == null) {
return Collections.emptyList();
}
List<String> viewNames = new ArrayList<>();
PrefetchRequest prefetch = request.getDeliveryRequest().getPrefetch();
if (prefetch != null) {
List<ViewRequest> views = prefetch.getViews();
if (views != null) {
for (ViewRequest viewRequest : views) {
viewNames.add(viewRequest.getName());
}
}
}
return viewNames;
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class OnDeviceDecisioningEvaluator method allMboxNames.
private List<String> allMboxNames(TargetDeliveryRequest request, OnDeviceDecisioningRuleSet ruleSet) {
if (request == null || ruleSet == null) {
return Collections.emptyList();
}
List<String> mboxNames = new ArrayList<>();
String globalMbox = ruleSet.getGlobalMbox();
PrefetchRequest prefetch = request.getDeliveryRequest().getPrefetch();
if (prefetch != null) {
if (prefetch.getPageLoad() != null) {
mboxNames.add(globalMbox);
}
mboxNames.addAll(prefetch.getMboxes().stream().map(MboxRequest::getName).collect(Collectors.toList()));
}
ExecuteRequest execute = request.getDeliveryRequest().getExecute();
if (execute != null) {
if (execute.getPageLoad() != null) {
mboxNames.add(globalMbox);
}
mboxNames.addAll(execute.getMboxes().stream().map(MboxRequest::getName).collect(Collectors.toList()));
}
return mboxNames;
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class TargetDeliveryExceptionTest method testTargetDeliveryRequest.
@Test
void testTargetDeliveryRequest() {
Context context = getContext();
PrefetchRequest prefetchRequest = getPrefetchViewsRequest();
ExecuteRequest executeRequest = getMboxExecuteRequest();
TargetDeliveryRequest targetDeliveryRequest = TargetDeliveryRequest.builder().context(context).prefetch(prefetchRequest).execute(executeRequest).build();
TargetRequestException exception = assertThrows(TargetRequestException.class, () -> {
TargetDeliveryResponse targetDeliveryResponse = targetJavaClient.getOffers(targetDeliveryRequest);
});
assertNotNull(exception);
assertNotNull(exception.getRequest());
assertNotNull(exception.getRequest().getSessionId());
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class TelemetryService method prefetchMboxCount.
private Integer prefetchMboxCount(TargetDeliveryRequest request) {
int prefetchMboxCount = 0;
PrefetchRequest prefetchRequest = request.getDeliveryRequest().getPrefetch();
if (prefetchRequest != null) {
prefetchMboxCount = prefetchRequest.getMboxes().size();
}
return prefetchMboxCount;
}
use of com.adobe.target.delivery.v1.model.PrefetchRequest in project target-java-sdk by adobe.
the class DefaultTargetClient method addMBoxesToRequest.
private static TargetDeliveryRequest addMBoxesToRequest(TargetDeliveryRequest targetRequest, String... mboxes) {
if (targetRequest == null || targetRequest.getDeliveryRequest() == null) {
targetRequest = TargetDeliveryRequest.builder().decisioningMethod(DecisioningMethod.HYBRID).build();
}
int idx = 0;
Set<String> existingMBoxNames = new HashSet<>();
DeliveryRequest deliveryRequest = targetRequest.getDeliveryRequest();
PrefetchRequest prefetchRequest = deliveryRequest.getPrefetch();
if (prefetchRequest != null && prefetchRequest.getMboxes() != null) {
for (MboxRequest mb : prefetchRequest.getMboxes()) {
existingMBoxNames.add(mb.getName());
}
}
ExecuteRequest executeRequest = deliveryRequest.getExecute();
if (executeRequest != null) {
List<MboxRequest> executeMboxes = executeRequest.getMboxes();
if (executeMboxes != null) {
for (MboxRequest mb : executeMboxes) {
if (mb.getIndex() >= idx) {
idx = mb.getIndex() + 1;
}
existingMBoxNames.add(mb.getName());
}
}
}
for (String mbox : mboxes) {
if (!existingMBoxNames.contains(mbox)) {
if (executeRequest == null) {
executeRequest = new ExecuteRequest();
targetRequest.getDeliveryRequest().setExecute(executeRequest);
}
executeRequest.addMboxesItem(new MboxRequest().index(idx++).name(mbox));
}
}
return targetRequest;
}
Aggregations