use of software.amazon.awssdk.services.personalizeevents.model.PutEventsRequest in project aws-doc-sdk-examples by awsdocs.
the class AmazonPersonalizeRecommender method putEvent.
public void putEvent(UserEvent e) {
try {
Event event = Event.builder().eventId(UUID.randomUUID().toString()).eventType(e.event).itemId(e.itemId).sentAt(Instant.ofEpochMilli(System.currentTimeMillis() + 10 * 60 * 1000)).build();
PutEventsRequest putEventsRequest = PutEventsRequest.builder().trackingId(trackingId).userId(e.getUserId()).sessionId("temp").eventList(event).build();
personalizeEventsClient.putEvents(putEventsRequest);
System.out.println("Event sent: " + e);
} catch (AwsServiceException ex) {
System.err.println(ex.awsErrorDetails().errorMessage());
System.exit(1);
}
}
use of software.amazon.awssdk.services.personalizeevents.model.PutEventsRequest in project aws-doc-sdk-examples by awsdocs.
the class PutEvents method putEvents.
// snippet-start:[personalize.java2.put_events.main]
public static int putEvents(PersonalizeEventsClient personalizeEventsClient, String trackingId, String userId, String itemId, String sessionId) {
int responseCode = 0;
try {
// Build an event and a putEvents request with only the required information for a minimal schema.
// Schema columns for this example would be itemId, userId, and timestamp.
Event event = Event.builder().sentAt(Instant.ofEpochMilli(System.currentTimeMillis() + 10 * 60 * 1000)).itemId(itemId).eventType("typePlaceholder").build();
PutEventsRequest putEventsRequest = PutEventsRequest.builder().trackingId(trackingId).userId(userId).sessionId(sessionId).eventList(event).build();
responseCode = personalizeEventsClient.putEvents(putEventsRequest).sdkHttpResponse().statusCode();
System.out.println("Response code: " + responseCode);
return responseCode;
} catch (PersonalizeEventsException e) {
System.out.println(e.awsErrorDetails().errorMessage());
}
return responseCode;
}
Aggregations