Search in sources :

Example 1 with PrefetchRequest

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;
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ArrayList(java.util.ArrayList) ViewRequest(com.adobe.target.delivery.v1.model.ViewRequest)

Example 2 with PrefetchRequest

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;
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) ArrayList(java.util.ArrayList)

Example 3 with PrefetchRequest

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());
}
Also used : TargetTestDeliveryRequestUtils.getContext(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext) Context(com.adobe.target.delivery.v1.model.Context) PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) TargetTestDeliveryRequestUtils.getMboxExecuteRequest(com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetRequestException(com.adobe.target.edge.client.exception.TargetRequestException) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) Test(org.junit.jupiter.api.Test)

Example 4 with PrefetchRequest

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;
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest)

Example 5 with PrefetchRequest

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;
}
Also used : PrefetchRequest(com.adobe.target.delivery.v1.model.PrefetchRequest) ExecuteRequest(com.adobe.target.delivery.v1.model.ExecuteRequest) TargetDeliveryRequest(com.adobe.target.edge.client.model.TargetDeliveryRequest) DeliveryRequest(com.adobe.target.delivery.v1.model.DeliveryRequest) MboxRequest(com.adobe.target.delivery.v1.model.MboxRequest) HashSet(java.util.HashSet)

Aggregations

PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)24 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)20 Test (org.junit.jupiter.api.Test)18 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)15 Context (com.adobe.target.delivery.v1.model.Context)14 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)13 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)12 TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)9 TimingTool (com.adobe.target.edge.client.utils.TimingTool)8 Property (com.adobe.target.delivery.v1.model.Property)7 ArrayList (java.util.ArrayList)7 MboxRequest (com.adobe.target.delivery.v1.model.MboxRequest)6 ViewRequest (com.adobe.target.delivery.v1.model.ViewRequest)6 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)5 OnDeviceDecisioningEvaluation (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation)5 OnDeviceDecisioningRuleSet (com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningRuleSet)5 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)5 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)5 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)4