use of software.amazon.awssdk.services.pinpoint.model.EndpointDemographic in project aws-doc-sdk-examples by awsdocs.
the class UpdateEndpoint method createEndpointRequestData.
private static EndpointRequest createEndpointRequestData() {
try {
List<String> favoriteTeams = new ArrayList<>();
favoriteTeams.add("Lakers");
favoriteTeams.add("Warriors");
HashMap<String, List<String>> customAttributes = new HashMap<>();
customAttributes.put("team", favoriteTeams);
EndpointDemographic demographic = EndpointDemographic.builder().appVersion("1.0").make("apple").model("iPhone").modelVersion("7").platform("ios").platformVersion("10.1.1").timezone("America/Los_Angeles").build();
EndpointLocation location = EndpointLocation.builder().city("Los Angeles").country("US").latitude(34.0).longitude(-118.2).postalCode("90068").region("CA").build();
Map<String, Double> metrics = new HashMap<>();
metrics.put("health", 100.00);
metrics.put("luck", 75.00);
EndpointUser user = EndpointUser.builder().userId(UUID.randomUUID().toString()).build();
// Quoted "Z" to indicate UTC, no timezone offset
DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'");
String nowAsISO = df.format(new Date());
EndpointRequest endpointRequest = EndpointRequest.builder().address(UUID.randomUUID().toString()).attributes(customAttributes).channelType("APNS").demographic(demographic).effectiveDate(nowAsISO).location(location).metrics(metrics).optOut("NONE").requestId(UUID.randomUUID().toString()).user(user).build();
return endpointRequest;
} catch (PinpointException e) {
System.err.println(e.awsErrorDetails().errorMessage());
System.exit(1);
}
return null;
}
Aggregations