Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
fix(samples): removed add time from lro. (#530)
Browse files Browse the repository at this point in the history
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/java-retail/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the [samples format](
https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
dfirova authored Sep 12, 2022
1 parent 2d0dd5c commit 541e280
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import com.google.cloud.ServiceOptions;
import com.google.cloud.retail.v2.AddFulfillmentPlacesRequest;
import com.google.cloud.retail.v2.ProductServiceClient;
import com.google.protobuf.Timestamp;
import java.io.IOException;
import java.time.Instant;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

Expand All @@ -47,22 +45,17 @@ public static void main(String[] args) throws IOException, InterruptedException

public static void addFulfillmentPlaces(String productName, String placeId)
throws IOException, InterruptedException {
Timestamp currentDate =
Timestamp.newBuilder()
.setSeconds(Instant.now().getEpochSecond())
.setNanos(Instant.now().getNano())
.build();

System.out.printf("Add fulfilment places with current date: %s", currentDate);
System.out.println("Add fulfilment places");

AddFulfillmentPlacesRequest addFulfillmentPlacesRequest =
AddFulfillmentPlacesRequest.newBuilder()
.setProduct(productName)
.setType("pickup-in-store")
.addPlaceIds(placeId)
.setAddTime(currentDate)
.setAllowMissing(true)
.build();

System.out.println("Add fulfillment request " + addFulfillmentPlacesRequest);

// Initialize client that will be used to send requests. This client only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
import com.google.cloud.ServiceOptions;
import com.google.cloud.retail.v2.ProductServiceClient;
import com.google.cloud.retail.v2.RemoveFulfillmentPlacesRequest;
import com.google.protobuf.Timestamp;
import java.io.IOException;
import java.time.Instant;
import java.util.UUID;
import java.util.concurrent.TimeUnit;

Expand All @@ -48,21 +46,17 @@ public static void main(String[] args) throws IOException, InterruptedException
// remove fulfillment places to product
public static void removeFulfillmentPlaces(String productName, String storeId)
throws IOException, InterruptedException {
Timestamp currentDate =
Timestamp.newBuilder()
.setSeconds(Instant.now().getEpochSecond())
.setNanos(Instant.now().getNano())
.build();

System.out.printf("Remove fulfilment places with current date: %s", currentDate);
System.out.println("Remove fulfilment places with current date");

RemoveFulfillmentPlacesRequest removeFulfillmentRequest =
RemoveFulfillmentPlacesRequest.newBuilder()
.setProduct(productName)
.setType("pickup-in-store")
.addPlaceIds(storeId)
.setRemoveTime(currentDate)
.setAllowMissing(true)
.build();

System.out.println("Remove fulfillment request " + removeFulfillmentRequest);

// Initialize client that will be used to send requests. This client only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
import com.google.cloud.retail.v2.SetInventoryRequest;
import com.google.protobuf.FieldMask;
import com.google.protobuf.Int32Value;
import com.google.protobuf.Timestamp;
import java.io.IOException;
import java.time.Instant;
import java.util.Arrays;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
Expand All @@ -57,13 +55,6 @@ public static void setInventory(String productName) throws IOException, Interrup
float originalPrice = 20.0f;
float cost = 8.0f;

// The request timestamp
Timestamp requestTime =
Timestamp.newBuilder()
.setSeconds(Instant.now().getEpochSecond())
.setNanos(Instant.now().getNano())
.build();

FieldMask setMask =
FieldMask.newBuilder()
.addAllPaths(
Expand Down Expand Up @@ -97,7 +88,6 @@ public static void setInventory(String productName) throws IOException, Interrup
SetInventoryRequest setInventoryRequest =
SetInventoryRequest.newBuilder()
.setInventory(product)
.setSetTime(requestTime)
.setAllowMissing(true)
.setSetMask(setMask)
.build();
Expand Down

0 comments on commit 541e280

Please sign in to comment.