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());
}
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;
});
}
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());
}
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());
});
}
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;
}
Aggregations