"""Logic related to branding for notifications.""" from dataclasses import dataclass from typing import Any, Dict, Optional from notifications.config import ENVIRONMENT, PROD_ENVIRONMENT @dataclass class BrandParams: """Brand Params dataclass.""" brand: str domain: str @property def settings_app_url(self) -> Optional[str]: """Return the Settings Suite App URL for the brands that support it.""" if self.brand in {'orchard', 'awal'}: return f'https://settings.{self.domain}' return None @property def content_app_url(self) -> Optional[str]: """Return the Content Suite App URL for the brands that support it.""" if self.brand in {'orchard', 'awal'}: return f'https://content.{self.domain}' return None def get_brand_params(identity: Dict[str, Any], environment: str = ENVIRONMENT) -> BrandParams: """Given an identity, return the brand parameters. Args: identity (Dict[str, Any]): The identity dictionary containing brand information. environment (str): The environment in which the application is running, defaults to ENVIRONMENT. Returns: BrandParams: An instance of BrandParams containing the default brand and domain. """ default_brand = identity.get('default_brand', 'theorchard') if default_brand == 'awal': return BrandParams( brand=default_brand, domain=('awal.com' if environment == PROD_ENVIRONMENT else 'qaawal.com'), ) elif default_brand == 'sme': return BrandParams( brand=default_brand, domain=('sonymusic.com' if environment == PROD_ENVIRONMENT else 'qapdesuite.com'), ) else: return BrandParams( brand='orchard', domain=('theorchard.com' if environment == PROD_ENVIRONMENT else 'qaorch.com'), )