use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class ImportProductsInlineSource method getImportProductsInlineRequest.
public static ImportProductsRequest getImportProductsInlineRequest(List<Product> productsToImport, String branchName) {
ProductInlineSource inlineSource = ProductInlineSource.newBuilder().addAllProducts(productsToImport).build();
ProductInputConfig inputConfig = ProductInputConfig.newBuilder().setProductInlineSource(inlineSource).build();
ImportProductsRequest importRequest = ImportProductsRequest.newBuilder().setParent(branchName).setInputConfig(inputConfig).build();
System.out.printf("Import products from inline source request: %s%n", importRequest);
return importRequest;
}
use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class SetInventory method getProductWithInventoryInfo.
public static Product getProductWithInventoryInfo(String productName) {
float price = 15.0f;
float originalPrice = 20.0f;
float cost = 8.0f;
PriceInfo priceInfo = PriceInfo.newBuilder().setPrice(price).setOriginalPrice(originalPrice).setCost(cost).setCurrencyCode("USD").build();
FulfillmentInfo fulfillmentInfo = FulfillmentInfo.newBuilder().setType("pickup-in-store").addAllPlaceIds(Arrays.asList("store1", "store2")).build();
return Product.newBuilder().setName(productName).setPriceInfo(priceInfo).addFulfillmentInfo(fulfillmentInfo).setAvailability(Availability.IN_STOCK).setAvailableQuantity(Int32Value.newBuilder().setValue(5).build()).build();
}
use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class UpdateProduct method generateProductForUpdate.
// generate product for update
public static Product generateProductForUpdate(String productId, String branchName) {
final float price = 20.0f;
final float originalPrice = 25.5f;
PriceInfo priceInfo = PriceInfo.newBuilder().setPrice(price).setOriginalPrice(originalPrice).setCurrencyCode("EUR").build();
return Product.newBuilder().setId(productId).setName(branchName + "/products/" + productId).setTitle("Updated Nest Mini").setType(Type.PRIMARY).addCategories("Updated Speakers and displays").addBrands("Updated Google").setAvailability(Availability.OUT_OF_STOCK).setPriceInfo(priceInfo).build();
}
use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class UpdateProduct method getUpdateProductRequest.
// get update product request
public static UpdateProductRequest getUpdateProductRequest(Product productToUpdate) {
UpdateProductRequest updateProductRequest = UpdateProductRequest.newBuilder().setProduct(productToUpdate).setAllowMissing(true).build();
System.out.printf("Update product request: %s%n", updateProductRequest);
return updateProductRequest;
}
use of com.google.cloud.retail.v2.Product in project java-retail by googleapis.
the class UpdateProduct method main.
public static void main(String[] args) throws IOException {
// TODO(developer): Replace these variables before running the sample.
String projectId = ServiceOptions.getDefaultProjectId();
String branchName = String.format("projects/%s/locations/global/catalogs/default_catalog/branches/0", projectId);
String generatedProductId = UUID.randomUUID().toString();
Product createdProduct = createProduct(generatedProductId);
updateProduct(createdProduct, branchName);
deleteProduct(createdProduct.getName());
}
Aggregations