use of com.amazonaws.services.pinpoint.model.EndpointBatchRequest in project aws-doc-sdk-examples by awsdocs.
the class AddExampleEndpoints method main.
public static void main(String[] args) {
final String USAGE = "\n" + "AddExampleEndpoints - Adds example endpoints to an Amazon Pinpoint application." + "Usage: AddExampleEndpoints <applicationId>" + "Where:\n" + " applicationId - The ID of the Amazon Pinpoint application to add the example endpoints to.";
if (args.length < 1) {
System.out.println(USAGE);
System.exit(1);
}
String applicationId = args[0];
// Initializes an endpoint definition with channel type, address, and ID.
EndpointBatchItem richardRoesEmailEndpoint = new EndpointBatchItem().withChannelType(ChannelType.EMAIL).withAddress("richard_roe@example.com").withId("example_endpoint_1");
// Adds custom attributes to the endpoint.
richardRoesEmailEndpoint.addAttributesEntry("interests", Arrays.asList("music", "books"));
// Adds custom metrics to the endpoint.
richardRoesEmailEndpoint.addMetricsEntry("music_interest_level", 3.0);
richardRoesEmailEndpoint.addMetricsEntry("books_interest_level", 7.0);
// Initializes a user definition with a user ID.
EndpointUser richardRoe = new EndpointUser().withUserId("example_user_1");
// Adds custom user attributes.
richardRoe.addUserAttributesEntry("name", Arrays.asList("Richard", "Roe"));
// Adds the user definition to the endpoint.
richardRoesEmailEndpoint.setUser(richardRoe);
// Initializes an endpoint definition with channel type, address, and ID.
EndpointBatchItem maryMajorsSmsEndpoint = new EndpointBatchItem().withChannelType(ChannelType.SMS).withAddress("+16145550100").withId("example_endpoint_2");
// Adds custom attributes to the endpoint.
maryMajorsSmsEndpoint.addAttributesEntry("interests", Arrays.asList("cooking", "politics", "finance"));
// Adds custom metrics to the endpoint.
maryMajorsSmsEndpoint.addMetricsEntry("cooking_interest_level", 5.0);
maryMajorsSmsEndpoint.addMetricsEntry("politics_interest_level", 8.0);
maryMajorsSmsEndpoint.addMetricsEntry("finance_interest_level", 4.0);
// Initializes a user definition with a user ID.
EndpointUser maryMajor = new EndpointUser().withUserId("example_user_2");
// Adds custom user attributes.
maryMajor.addUserAttributesEntry("name", Arrays.asList("Mary", "Major"));
// Adds the user definition to the endpoint.
maryMajorsSmsEndpoint.setUser(maryMajor);
// Adds multiple endpoint definitions to a single request object.
EndpointBatchRequest endpointList = new EndpointBatchRequest().withItem(richardRoesEmailEndpoint).withItem(maryMajorsSmsEndpoint);
// Initializes the Amazon Pinpoint client.
AmazonPinpoint pinpointClient = AmazonPinpointClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
// Updates or creates the endpoints with Amazon Pinpoint.
UpdateEndpointsBatchResult result = pinpointClient.updateEndpointsBatch(new UpdateEndpointsBatchRequest().withApplicationId(applicationId).withEndpointBatchRequest(endpointList));
System.out.format("Update endpoints batch result: %s\n", result.getMessageBody().getMessage());
}
Aggregations