Moved some stuff around and fixed circular import
This commit is contained in:
@@ -44,7 +44,7 @@ from .alpinebits_server import (
|
||||
)
|
||||
from .auth import validate_api_key
|
||||
from .config_loader import load_config, get_username_for_hotel
|
||||
from .const import CONF_GOOGLE_ACCOUNT, CONF_HOTEL_ID, CONF_META_ACCOUNT, HttpStatusCode, WebhookStatus
|
||||
from .const import HttpStatusCode, WebhookStatus
|
||||
from .conversion_service import ConversionService
|
||||
from .csv_import import CSVImporter
|
||||
from .db import Customer as DBCustomer
|
||||
@@ -79,45 +79,6 @@ security_bearer = HTTPBearer()
|
||||
TOKEN_LOG_LENGTH = 10
|
||||
|
||||
|
||||
def get_advertising_account_ids(
|
||||
config: dict[str, Any], hotel_code: str, fbclid: str | None, gclid: str | None
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""Get advertising account IDs based on hotel config and click IDs.
|
||||
|
||||
Args:
|
||||
config: Application configuration dict
|
||||
hotel_code: Hotel identifier to look up in config
|
||||
fbclid: Facebook click ID (if present, meta_account_id will be returned)
|
||||
gclid: Google click ID (if present, google_account_id will be returned)
|
||||
|
||||
Returns:
|
||||
Tuple of (meta_account_id, google_account_id) based on conditional logic:
|
||||
- meta_account_id is set only if fbclid is present AND hotel has
|
||||
meta_account configured
|
||||
- google_account_id is set only if gclid is present AND hotel has
|
||||
google_account configured
|
||||
|
||||
"""
|
||||
meta_account_id = None
|
||||
google_account_id = None
|
||||
|
||||
# Look up hotel in config
|
||||
alpine_bits_auth = config.get("alpine_bits_auth", [])
|
||||
for hotel in alpine_bits_auth:
|
||||
if hotel.get(CONF_HOTEL_ID) == hotel_code:
|
||||
# Conditionally set meta_account_id if fbclid is present
|
||||
if fbclid:
|
||||
meta_account_id = hotel.get(CONF_META_ACCOUNT)
|
||||
|
||||
# Conditionally set google_account_id if gclid is present
|
||||
if gclid:
|
||||
google_account_id = hotel.get(CONF_GOOGLE_ACCOUNT)
|
||||
|
||||
break
|
||||
|
||||
return meta_account_id, google_account_id
|
||||
|
||||
|
||||
# Pydantic models for language detection
|
||||
class LanguageDetectionRequest(BaseModel):
|
||||
text: str
|
||||
|
||||
Reference in New Issue
Block a user