Skip to content

Commit

Permalink
fix: remove add_time param from LRO requests. (#336)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
  • Loading branch information
kchertenko and parthea committed Sep 6, 2022
1 parent 2237de6 commit 7c73e04
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# [START retail_add_fulfillment_places]
# Adding place IDs using Retail API.
#
import datetime
import random
import string
import time
Expand All @@ -37,13 +36,12 @@

# add fulfillment request
def get_add_fulfillment_request(
product_name: str, timestamp, place_id
product_name: str, place_id
) -> AddFulfillmentPlacesRequest:
add_fulfillment_request = AddFulfillmentPlacesRequest()
add_fulfillment_request.product = product_name
add_fulfillment_request.type_ = "pickup-in-store"
add_fulfillment_request.place_ids = [place_id]
add_fulfillment_request.add_time = timestamp
add_fulfillment_request.allow_missing = True

print("---add fulfillment request---")
Expand All @@ -53,10 +51,8 @@ def get_add_fulfillment_request(


# add fulfillment places to product
def add_fulfillment_places(product_name: str, timestamp, place_id):
add_fulfillment_request = get_add_fulfillment_request(
product_name, timestamp, place_id
)
def add_fulfillment_places(product_name: str, place_id):
add_fulfillment_request = get_add_fulfillment_request(product_name, place_id)
ProductServiceClient().add_fulfillment_places(add_fulfillment_request)

# This is a long running operation and its result is not immediately present with get operations,
Expand All @@ -70,9 +66,7 @@ def add_fulfillment_places(product_name: str, timestamp, place_id):

create_product(product_id)

# The request timestamp
current_date = datetime.datetime.now() + datetime.timedelta(seconds=30)
print(f"------add fulfilment places with current date: {current_date}-----")
add_fulfillment_places(product_name, current_date, "store2")
print("------add fulfilment places-----")
add_fulfillment_places(product_name, "store2")
get_product(product_name)
delete_product(product_name)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# [START retail_remove_fulfillment_places]
# Remove place IDs using Retail API.
#
import datetime
import random
import string
import time
Expand All @@ -29,13 +28,12 @@

# remove fulfillment request
def get_remove_fulfillment_request(
product_name: str, timestamp, store_id
product_name: str, store_id
) -> RemoveFulfillmentPlacesRequest:
remove_fulfillment_request = RemoveFulfillmentPlacesRequest()
remove_fulfillment_request.product = product_name
remove_fulfillment_request.type_ = "pickup-in-store"
remove_fulfillment_request.place_ids = [store_id]
remove_fulfillment_request.remove_time = timestamp
remove_fulfillment_request.allow_missing = True

print("---remove fulfillment request---")
Expand All @@ -45,10 +43,8 @@ def get_remove_fulfillment_request(


# remove fulfillment places to product
def remove_fulfillment_places(product_name: str, timestamp, store_id):
remove_fulfillment_request = get_remove_fulfillment_request(
product_name, timestamp, store_id
)
def remove_fulfillment_places(product_name: str, store_id):
remove_fulfillment_request = get_remove_fulfillment_request(product_name, store_id)
ProductServiceClient().remove_fulfillment_places(remove_fulfillment_request)

# This is a long running operation and its result is not immediately present with get operations,
Expand All @@ -62,10 +58,7 @@ def remove_fulfillment_places(product_name: str, timestamp, store_id):

product = create_product(product_id)

# The request timestamp
current_date = datetime.datetime.now()

print(f"------remove fulfilment places with current date: {current_date}-----")
remove_fulfillment_places(product.name, current_date, "store0")
print("------remove fulfilment places-----")
remove_fulfillment_places(product.name, "store0")
get_product(product.name)
delete_product(product.name)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# [START retail_set_inventory]
# Updating inventory information using Retail API.
#
import datetime
import random
import string
import time
Expand Down Expand Up @@ -65,15 +64,12 @@ def get_product_with_inventory_info(product_name: str) -> Product:

# set inventory request
def get_set_inventory_request(product_name: str) -> SetInventoryRequest:
# The request timestamp
request_time = datetime.datetime.now() + datetime.timedelta(seconds=30)
set_mask = FieldMask(
paths=["price_info", "availability", "fulfillment_info", "available_quantity"]
)

set_inventory_request = SetInventoryRequest()
set_inventory_request.inventory = get_product_with_inventory_info(product_name)
set_inventory_request.set_time = request_time
set_inventory_request.allow_missing = True
set_inventory_request.set_mask = set_mask

Expand Down

0 comments on commit 7c73e04

Please sign in to comment.