(20250825) -Added debug print statement for google places api testing.
This commit is contained in:
@@ -678,17 +678,23 @@ class AsyncPlacesClient(AsyncGoogleBase):
|
||||
https://developers.google.com/maps/documentation/places/web-service/text-search
|
||||
"""
|
||||
|
||||
# Ensure that the tokens are valid:
|
||||
await tokens.arefresh(
|
||||
http_client=self._http_client,
|
||||
client_id=self._client_id,
|
||||
client_secret=self._client_secret,
|
||||
force_refresh=False
|
||||
)
|
||||
print("IN TOKEN", tokens)
|
||||
print("IN TOKEN", tokens.model_dump())
|
||||
print("IN TOKEN", tokens.token["accessToken"])
|
||||
|
||||
# Ensure that the tokens are valid:
|
||||
# await tokens.arefresh(
|
||||
# http_client=self._http_client,
|
||||
# client_id=self._client_id,
|
||||
# client_secret=self._client_secret,
|
||||
# force_refresh=False
|
||||
# )
|
||||
print("RH --")
|
||||
# Create the headers:
|
||||
request_headers = {"Authorization": f"Bearer {tokens.accessToken}"}
|
||||
if field_mask: request_headers["X-Goog-FieldMask"] = ",".join(field_mask)
|
||||
request_headers = {"Authorization": f"Bearer {tokens.token["accessToken"]}"}
|
||||
# if field_mask: request_headers["X-Goog-FieldMask"] = ",".join(field_mask)
|
||||
print("RH",request_headers)
|
||||
if field_mask: request_headers["X-Goog-FieldMask"] = "places.displayName,places.formattedAddress,places.priceLevel"
|
||||
|
||||
# Start creating the JSON payload based on the inputs:
|
||||
# request_json = {
|
||||
@@ -710,19 +716,21 @@ class AsyncPlacesClient(AsyncGoogleBase):
|
||||
"textQuery": text_query
|
||||
}
|
||||
|
||||
if included_primary_types: request_json["includedPrimaryTypes"] = included_primary_types
|
||||
if included_types: request_json["includedTypes"] = included_types
|
||||
if excluded_primary_types: request_json["excludedPrimaryTypes"] = excluded_primary_types
|
||||
if excluded_types: request_json["excludedTypes"] = excluded_types
|
||||
|
||||
# if included_primary_types: request_json["includedPrimaryTypes"] = included_primary_types
|
||||
# if included_types: request_json["includedTypes"] = included_types
|
||||
# if excluded_primary_types: request_json["excludedPrimaryTypes"] = excluded_primary_types
|
||||
# if excluded_types: request_json["excludedTypes"] = excluded_types
|
||||
print(request_json)
|
||||
# Make the API call:
|
||||
if not self._debug_only_errors: self._printer("Listing Nearby (Radius) Places.")
|
||||
if not self._debug_only_errors: self._printer("Listing text Search Places.")
|
||||
api_response = await self.post(
|
||||
url=f"https://places.googleapis.com/v1/places:searchText",
|
||||
headers=request_headers,
|
||||
json=request_json
|
||||
)
|
||||
|
||||
print(api_response)
|
||||
|
||||
# If the call was successful:
|
||||
if api_response.httpCode in [200]:
|
||||
api_response.success = True
|
||||
|
||||
Reference in New Issue
Block a user