use of com.adobe.target.delivery.v1.model.DeliveryRequest in project target-java-sdk by adobe.
the class GeoParamsCollator method collateParams.
public Map<String, Object> collateParams(TargetDeliveryRequest deliveryRequest, RequestDetails requestDetails) {
Map<String, Object> params = new HashMap<>();
Context context = deliveryRequest.getDeliveryRequest().getContext();
if (context == null || context.getGeo() == null) {
params.putAll(DEFAULT_GEO_PARAMS);
return params;
}
Geo geo = context.getGeo();
params.put(GEO_LATITUDE, geo.getLatitude());
params.put(GEO_LONGITUDE, geo.getLongitude());
params.put(GEO_CITY, StringUtils.isEmpty(geo.getCity()) ? "" : geo.getCity().toUpperCase().replace(" ", ""));
params.put(GEO_REGION, StringUtils.isEmpty(geo.getStateCode()) ? "" : geo.getStateCode().toUpperCase());
params.put(GEO_COUNTRY, StringUtils.isEmpty(geo.getCountryCode()) ? "" : geo.getCountryCode().toUpperCase());
return params;
}
use of com.adobe.target.delivery.v1.model.DeliveryRequest in project target-java-sdk by adobe.
the class UserParamsCollator method extractUserAgent.
private String extractUserAgent(TargetDeliveryRequest deliveryRequest) {
Context context = deliveryRequest.getDeliveryRequest().getContext();
if (context == null) {
return null;
}
String userAgent = context.getUserAgent();
if (StringUtils.isEmpty(userAgent)) {
return null;
}
return userAgent;
}
use of com.adobe.target.delivery.v1.model.DeliveryRequest 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.delivery.v1.model.DeliveryRequest 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.delivery.v1.model.DeliveryRequest 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());
}
Aggregations