Search in sources :

Example 46 with Product

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;
}
Also used : ImportProductsRequest(com.google.cloud.retail.v2.ImportProductsRequest) ProductInputConfig(com.google.cloud.retail.v2.ProductInputConfig) ProductInlineSource(com.google.cloud.retail.v2.ProductInlineSource)

Example 47 with Product

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();
}
Also used : FulfillmentInfo(com.google.cloud.retail.v2.FulfillmentInfo) PriceInfo(com.google.cloud.retail.v2.PriceInfo)

Example 48 with Product

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();
}
Also used : PriceInfo(com.google.cloud.retail.v2.PriceInfo)

Example 49 with Product

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;
}
Also used : UpdateProductRequest(com.google.cloud.retail.v2.UpdateProductRequest)

Example 50 with Product

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());
}
Also used : SetupCleanup.deleteProduct(setup.SetupCleanup.deleteProduct) Product(com.google.cloud.retail.v2.Product) SetupCleanup.createProduct(setup.SetupCleanup.createProduct)

Aggregations

Product (com.google.cloud.retail.v2.Product)20 ProductServiceClient (com.google.cloud.retail.v2.ProductServiceClient)12 Product (com.google.cloud.vision.v1.Product)10 SetupCleanup.deleteProduct (setup.SetupCleanup.deleteProduct)9 PriceInfo (com.google.cloud.retail.v2.PriceInfo)7 Test (org.junit.Test)6 SetupCleanup.createProduct (setup.SetupCleanup.createProduct)6 DeleteProductRequest (com.google.cloud.retail.v2.DeleteProductRequest)5 ImportProductsRequest (com.google.cloud.retail.v2.ImportProductsRequest)5 ProductSearchClient (com.google.cloud.vision.v1.ProductSearchClient)5 Product (com.haulmont.cuba.testmodel.sales_1.Product)5 ListProductsPagedResponse (com.google.cloud.retail.v2.ProductServiceClient.ListProductsPagedResponse)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 PrintStream (java.io.PrintStream)4 Before (org.junit.Before)4 Test (org.junit.jupiter.api.Test)4 NotFoundException (com.google.api.gax.rpc.NotFoundException)3 CreateProductRequest (com.google.cloud.retail.v2.CreateProductRequest)3 FulfillmentInfo (com.google.cloud.retail.v2.FulfillmentInfo)3 GetProductRequest (com.google.cloud.retail.v2.GetProductRequest)3