Search in sources :

Example 1 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class DefaultTargetService method executeNotification.

@Override
public ResponseStatus executeNotification(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
    TargetDeliveryResponse targetDeliveryResponse;
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    ResponseWrapper response = callDeliveryApi(deliveryRequest);
    targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
    telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
    return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 2 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class DefaultTargetService method executeRequestAsync.

@Override
public CompletableFuture<TargetDeliveryResponse> executeRequestAsync(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
    return responseCompletableFuture.thenApply(response -> {
        TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
        telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
        return targetDeliveryResponse;
    });
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 3 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class DefaultTargetService method getTargetDeliveryResponse.

private TargetDeliveryResponse getTargetDeliveryResponse(TargetDeliveryRequest deliveryRequest, HttpResponse<DeliveryResponse> response) {
    DeliveryResponse deliveryResponse = retrieveDeliveryResponse(response);
    updateStickyLocationHint(deliveryResponse);
    return new TargetDeliveryResponse(deliveryRequest, deliveryResponse, response.getStatus(), response.getStatusText());
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse)

Example 4 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class DefaultTargetService method executeNotificationAsync.

@Override
public CompletableFuture<ResponseStatus> executeNotificationAsync(TargetDeliveryRequest deliveryRequest) {
    TimingTool timer = new TimingTool();
    timer.timeStart(TIMING_EXECUTE_REQUEST);
    NotificationService.setBeaconToFalse(deliveryRequest.getDeliveryRequest());
    Telemetry telemetry = telemetryService.getTelemetry();
    if (!telemetry.getEntries().isEmpty()) {
        deliveryRequest.getDeliveryRequest().setTelemetry(telemetry);
    }
    CompletableFuture<ResponseWrapper<DeliveryResponse>> responseCompletableFuture = callDeliveryApiAsync(deliveryRequest);
    return responseCompletableFuture.thenApply(response -> {
        TargetDeliveryResponse targetDeliveryResponse = getTargetDeliveryResponse(deliveryRequest, response.getHttpResponse());
        telemetryService.addTelemetry(deliveryRequest, timer, targetDeliveryResponse, response.getParsingTime(), response.getResponseSize());
        return new ResponseStatus(response.getHttpResponse().getStatus(), response.getHttpResponse().getStatusText());
    });
}
Also used : TimingTool(com.adobe.target.edge.client.utils.TimingTool) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ResponseWrapper(com.adobe.target.edge.client.http.ResponseWrapper) Telemetry(com.adobe.target.delivery.v1.model.Telemetry)

Example 5 with TargetDeliveryResponse

use of com.adobe.target.edge.client.model.TargetDeliveryResponse in project target-java-sdk by adobe.

the class OnDeviceDecisioningService method buildDeliveryResponse.

private TargetDeliveryResponse buildDeliveryResponse(TargetDeliveryRequest deliveryRequest, String requestId) {
    OnDeviceDecisioningEvaluation localEvaluation = evaluateLocalExecution(deliveryRequest);
    int status = localEvaluation.isAllLocal() ? HttpStatus.SC_OK : HttpStatus.SC_PARTIAL_CONTENT;
    DeliveryResponse deliveryResponse = new DeliveryResponse().client(clientConfig.getClient()).requestId(requestId).id(deliveryRequest.getDeliveryRequest().getId()).status(status);
    PrefetchResponse prefetchResponse = new PrefetchResponse();
    ExecuteResponse executeResponse = new ExecuteResponse();
    deliveryResponse.setPrefetch(prefetchResponse);
    deliveryResponse.setExecute(executeResponse);
    TargetDeliveryResponse targetResponse = new TargetDeliveryResponse(deliveryRequest, deliveryResponse, status, localEvaluation.isAllLocal() ? "Local-decisioning response" : localEvaluation.getReason());
    ResponseStatus responseStatus = targetResponse.getResponseStatus();
    responseStatus.setGlobalMbox(localEvaluation.getGlobalMbox());
    responseStatus.setRemoteMboxes(localEvaluation.getRemoteMBoxes());
    responseStatus.setRemoteViews(localEvaluation.getRemoteViews());
    return targetResponse;
}
Also used : TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) PrefetchResponse(com.adobe.target.delivery.v1.model.PrefetchResponse) ResponseStatus(com.adobe.target.edge.client.http.ResponseStatus) ExecuteResponse(com.adobe.target.delivery.v1.model.ExecuteResponse) TargetDeliveryResponse(com.adobe.target.edge.client.model.TargetDeliveryResponse) DeliveryResponse(com.adobe.target.delivery.v1.model.DeliveryResponse) OnDeviceDecisioningEvaluation(com.adobe.target.edge.client.model.ondevice.OnDeviceDecisioningEvaluation)

Aggregations

TargetDeliveryResponse (com.adobe.target.edge.client.model.TargetDeliveryResponse)66 TargetDeliveryRequest (com.adobe.target.edge.client.model.TargetDeliveryRequest)58 Test (org.junit.jupiter.api.Test)53 TimingTool (com.adobe.target.edge.client.utils.TimingTool)13 DeliveryResponse (com.adobe.target.delivery.v1.model.DeliveryResponse)10 Context (com.adobe.target.delivery.v1.model.Context)9 ExecuteRequest (com.adobe.target.delivery.v1.model.ExecuteRequest)9 TargetTestDeliveryRequestUtils.getContext (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getContext)9 TargetTestDeliveryRequestUtils.getMboxExecuteRequest (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getMboxExecuteRequest)9 TargetTestDeliveryRequestUtils.getTestDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getTestDeliveryResponse)9 PrefetchRequest (com.adobe.target.delivery.v1.model.PrefetchRequest)8 Property (com.adobe.target.delivery.v1.model.Property)7 TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse (com.adobe.target.edge.client.utils.TargetTestDeliveryRequestUtils.getNoContentDeliveryResponse)6 Telemetry (com.adobe.target.delivery.v1.model.Telemetry)5 TelemetryEntry (com.adobe.target.delivery.v1.model.TelemetryEntry)4 ParamsCollator (com.adobe.target.edge.client.ondevice.collator.ParamsCollator)4 CustomerState (com.adobe.experiencecloud.ecid.visitor.CustomerState)3 TargetRequestException (com.adobe.target.edge.client.exception.TargetRequestException)3 ResponseStatus (com.adobe.target.edge.client.http.ResponseStatus)3 ResponseWrapper (com.adobe.target.edge.client.http.ResponseWrapper)3