(20250825) -Added new google places API Integration system, no more oauth system for places api integration,

added multiple files for and correction and changes as well.
This commit is contained in:
yatmesh
2025-08-25 14:43:14 +05:30
parent ddc29a7fe1
commit 7f7a16d4d2
8 changed files with 221 additions and 102 deletions
@@ -71,11 +71,10 @@ from utils_v2.goog.models.auth_tokens import GoogleAuthTokens
from shared import constants
# Data Models:
# from models.api.message.mail.send import MailSendRequestHeaders, MailSendRequestData
from models.api.message.mail.send import MailSendRequestHeaders, MailSendRequestData
from models.api.software.places.places import PlacesRequestHeaders, PlacesTextSearchRequestData, PlacesNearbyRequestData
from models.message.mail.send import MailSendOneResult
from models.core.user import CoreUserInfoModel
from models.core.auth_token import CoreAuthTokenModel
# To work with datatypes:
from typing import Literal
@@ -129,7 +128,7 @@ def init(blueprint_setup_state):
# ---------------------------------------------------------------------------------------------------------------------
@google_places_bp.route("/<search_type>", methods = ["POST"])
@google_places_bp.route("/nearby", methods = ["POST"])
@set_api_version(api_version = "1.0.0")
@read_input(sanitize_headers = False, sanitize_data = False)
@get_session_info(key = "X-Session-Token", session_coro = "get_session")
@@ -145,13 +144,13 @@ def init(blueprint_setup_state):
@log_chain_to_mongo(attr_name = "logs_mongo")
@should_not_be_under_maintenance(attr_name = "is_under_maintenance")
@validate_input(
header_validator = lambda x: MailSendRequestHeaders(**x).model_dump(),
data_validator = lambda x: MailSendRequestData(**x)
header_validator = lambda x: PlacesRequestHeaders(**x).model_dump(),
data_validator = lambda x: PlacesNearbyRequestData(**x)
)
@handle_cancelled_request()
async def find_nearby(
inbound_headers: dict | MailSendRequestHeaders = None,
inbound_data: dict | MailSendRequestData = None,
inbound_headers: dict | PlacesRequestHeaders = None,
inbound_data: dict | PlacesNearbyRequestData = None,
inbound_files: dict = None,
**kwargs
):
@@ -267,13 +266,13 @@ async def find_nearby(
@log_chain_to_mongo(attr_name = "logs_mongo")
@should_not_be_under_maintenance(attr_name = "is_under_maintenance")
@validate_input(
header_validator = lambda x: MailSendRequestHeaders(**x).model_dump(),
data_validator = lambda x: MailSendRequestData(**x)
header_validator = lambda x: PlacesRequestHeaders(**x).model_dump(),
data_validator = lambda x: PlacesTextSearchRequestData(**x)
)
@handle_cancelled_request()
async def text_search(
inbound_headers: dict = None,
inbound_data: dict = None,
inbound_headers: dict | PlacesRequestHeaders = None,
inbound_data: dict | PlacesTextSearchRequestData = None,
inbound_files: dict = None,
**kwargs
):
@@ -303,11 +302,11 @@ async def text_search(
# ┃┃┓┏┏┏┓┏┓┏┓┏┣┓┓┏┓ ┃ ┣┓┏┓┏┃┏
# ┗┛┗┻┛┛┗┗ ┛ ┛┛┗┗┣┛ ┗┛┛┗┗ ┗┛┗
# ┛
print(inbound_data)
# Get the token based on the key:
auth_token = await current_app.places_controller.get_token_from_key(
mongo_data_conn = current_app.data_mongo,
token_key = inbound_data["tokenKey"],
token_key = inbound_data.tokenKey,
must_be_active = True
)
print("AUTH:", auth_token)
@@ -334,10 +333,10 @@ async def text_search(
# If the controller and connector were matched:
if client_controller is not None and client_connector is not None:
send_result = await client_controller.text_query_search(
send_result = await client_connector.text_query_search(
tokens=auth_token,
text_query=inbound_data["textQuery"],
max_count=inbound_data["maxCount"]
text_query=inbound_data.textQuery,
max_count=inbound_data.maxCount
)
# ┳┓