use of com.amazonaws.services.pinpoint.model.EndpointDemographic in project aws-doc-sdk-examples by awsdocs.
the class CreateEndpoint method createEndpointRequestData.
private static EndpointRequest createEndpointRequestData() {
HashMap<String, List<String>> customAttributes = new HashMap<>();
List<String> favoriteTeams = new ArrayList<>();
favoriteTeams.add("Lakers");
favoriteTeams.add("Warriors");
customAttributes.put("team", favoriteTeams);
EndpointDemographic demographic = new EndpointDemographic().withAppVersion("1.0").withMake("apple").withModel("iPhone").withModelVersion("7").withPlatform("ios").withPlatformVersion("10.1.1").withTimezone("America/Los_Angeles");
EndpointLocation location = new EndpointLocation().withCity("Los Angeles").withCountry("US").withLatitude(34.0).withLongitude(-118.2).withPostalCode("90068").withRegion("CA");
Map<String, Double> metrics = new HashMap<>();
metrics.put("health", 100.00);
metrics.put("luck", 75.00);
EndpointUser user = new EndpointUser().withUserId(UUID.randomUUID().toString());
// 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 = new EndpointRequest().withAddress(UUID.randomUUID().toString()).withAttributes(customAttributes).withChannelType("APNS").withDemographic(demographic).withEffectiveDate(nowAsISO).withLocation(location).withMetrics(metrics).withOptOut("NONE").withRequestId(UUID.randomUUID().toString()).withUser(user);
return endpointRequest;
}
use of com.amazonaws.services.pinpoint.model.EndpointDemographic in project aws-sdk-android by aws-amplify.
the class EventRecorder method buildEndpointPayload.
private void buildEndpointPayload(EndpointProfile endpointProfile, PublicEndpoint endpoint) {
final EndpointDemographic demographic = new EndpointDemographic().withAppVersion(endpointProfile.getDemographic().getAppVersion()).withLocale(endpointProfile.getDemographic().getLocale().toString()).withTimezone(endpointProfile.getDemographic().getTimezone()).withMake(endpointProfile.getDemographic().getMake()).withModel(endpointProfile.getDemographic().getModel()).withPlatform(endpointProfile.getDemographic().getPlatform()).withPlatformVersion(endpointProfile.getDemographic().getPlatformVersion());
final EndpointLocation location = new EndpointLocation().withLatitude(endpointProfile.getLocation().getLatitude()).withLongitude(endpointProfile.getLocation().getLongitude()).withPostalCode(endpointProfile.getLocation().getPostalCode()).withCity(endpointProfile.getLocation().getCity()).withRegion(endpointProfile.getLocation().getRegion()).withCountry(endpointProfile.getLocation().getCountry());
final EndpointUser user;
if (endpointProfile.getUser().getUserId() == null) {
user = null;
} else {
user = new EndpointUser().withUserId(endpointProfile.getUser().getUserId()).withUserAttributes(endpointProfile.getUser().getUserAttributes());
}
endpoint.withChannelType(endpointProfile.getChannelType()).withAddress(endpointProfile.getAddress()).withLocation(location).withDemographic(demographic).withEffectiveDate(DateUtils.formatISO8601Date(new Date(endpointProfile.getEffectiveDate()))).withOptOut(endpointProfile.getOptOut()).withAttributes(endpointProfile.getAllAttributes()).withMetrics(endpointProfile.getAllMetrics()).withUser(user);
}
use of com.amazonaws.services.pinpoint.model.EndpointDemographic in project aws-sdk-android by aws-amplify.
the class TargetingClient method executeUpdate.
@SuppressWarnings("checkstyle:hiddenfield")
private void executeUpdate(EndpointProfile endpointProfile) {
if (endpointProfile == null) {
log.error("EndpointProfile is null, failed to update profile.");
return;
}
final EndpointDemographic demographic = new EndpointDemographic().withAppVersion(endpointProfile.getDemographic().getAppVersion()).withLocale(endpointProfile.getDemographic().getLocale().toString()).withTimezone(endpointProfile.getDemographic().getTimezone()).withMake(endpointProfile.getDemographic().getMake()).withModel(endpointProfile.getDemographic().getModel()).withPlatform(endpointProfile.getDemographic().getPlatform()).withPlatformVersion(endpointProfile.getDemographic().getPlatformVersion());
final EndpointLocation location = new EndpointLocation().withLatitude(endpointProfile.getLocation().getLatitude()).withLongitude(endpointProfile.getLocation().getLongitude()).withPostalCode(endpointProfile.getLocation().getPostalCode()).withCity(endpointProfile.getLocation().getCity()).withRegion(endpointProfile.getLocation().getRegion()).withCountry(endpointProfile.getLocation().getCountry());
final EndpointUser user;
if (endpointProfile.getUser().getUserId() == null) {
user = null;
} else {
user = new EndpointUser().withUserId(endpointProfile.getUser().getUserId()).withUserAttributes(endpointProfile.getUser().getUserAttributes());
}
final EndpointRequest endpointRequest = new EndpointRequest().withChannelType(endpointProfile.getChannelType()).withAddress(endpointProfile.getAddress()).withLocation(location).withDemographic(demographic).withEffectiveDate(DateUtils.formatISO8601Date(new Date(endpointProfile.getEffectiveDate()))).withOptOut(endpointProfile.getOptOut()).withAttributes(endpointProfile.getAllAttributes()).withMetrics(endpointProfile.getAllMetrics()).withUser(user);
final UpdateEndpointRequest updateEndpointRequest = new UpdateEndpointRequest().withApplicationId(endpointProfile.getApplicationId()).withEndpointId(endpointProfile.getEndpointId()).withEndpointRequest(endpointRequest);
updateEndpointRequest.getRequestClientOptions().appendUserAgent(USER_AGENT);
endpointRunnableQueue.execute(new Runnable() {
@Override
public void run() {
try {
log.info("Updating EndpointProfile.");
context.getPinpointServiceClient().updateEndpoint(updateEndpointRequest);
log.info("EndpointProfile updated successfully.");
} catch (final AmazonServiceException e) {
log.error("AmazonServiceException occurred during endpoint update:", e);
} catch (final AmazonClientException e) {
log.info("AmazonClientException occurred during endpoint update:", e);
}
}
});
}
Aggregations