Search in sources :

Example 1 with ProductDetail

use of com.google.cloud.retail.v2.ProductDetail in project java-retail by googleapis.

the class SetupCleanup method getUserEvent.

public static UserEvent getUserEvent(String visitorId) {
    int value = 3;
    Timestamp timestamp = Timestamp.newBuilder().setSeconds(Instant.now().getEpochSecond()).build();
    Product product = Product.newBuilder().setId(UUID.randomUUID().toString()).build();
    ProductDetail productDetail = ProductDetail.newBuilder().setProduct(product).setQuantity(Int32Value.newBuilder().setValue(value).build()).build();
    UserEvent userEvent = UserEvent.newBuilder().setEventType("detail-page-view").setVisitorId(visitorId).setEventTime(timestamp).addAllProductDetails(Collections.singletonList(productDetail)).build();
    System.out.println(userEvent);
    return userEvent;
}
Also used : ProductDetail(com.google.cloud.retail.v2.ProductDetail) Product(com.google.cloud.retail.v2.Product) Timestamp(com.google.protobuf.Timestamp) UserEvent(com.google.cloud.retail.v2.UserEvent)

Aggregations

Product (com.google.cloud.retail.v2.Product)1 ProductDetail (com.google.cloud.retail.v2.ProductDetail)1 UserEvent (com.google.cloud.retail.v2.UserEvent)1 Timestamp (com.google.protobuf.Timestamp)1