
    {i                         d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ ded	efd
Zded	efdZded	efdZdefdZd ZdedefdZy)    )DictUnion)Session)get_setting_record)settings)APIException)status)SiteSettingsmerchant_idreturnc                     t        dd|       }|r0|j                  r$t        |j                        dkD  r|j                  S t        j                  S )z-
    Fetch the primary color of merchant
    branding_colors_primarybranding
field_namekeyr   r   )r   valuelenr   APP_PRIMARY_COLORr   settings     W/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/src/apps/merchants/helper.pyget_brand_primary_colorr      sP     !,G w}}W]]);a)? 	 ''    c                     t        dd|       }|r0|j                  r$t        |j                        dkD  r|j                  S t        j                  S )z/
    Fetch the secondary color of merchant
    branding_colors_secondaryr   r   r   )r   r   r   r   APP_SECONDARY_COLORr   s     r   get_brand_secondary_colorr      sP     !.G w}}W]]);a)? 	 ))r   c                     t        dd|       }|r0|j                  r$t        |j                        dkD  r|j                  S t        j                  S )z(
    Fetch the timezone of merchant
    info_timezoneinfor   r   )r   r   r   r   APP_TIMEZONEr   s     r   get_timezoner#   /   sP     !"G w}}W]]);a)? 	 ""r   c                     t         j                  t         j                  t         j                  t         j                  dS )N)privacy_policy_urltnc_urlsupport_phonesupport_email)r   APP_PRIVACY_POLICY_URLAPP_TNC_URLAPP_SUPPORT_PHONEAPP_SUPPORT_EMAIL)r   s    r   get_whitelabelr-   A   s0    &==''!33!33	 r   c                 L    | D ]  }|j                   |k(  s|j                  c S  y )N)r   r   )data
target_keyitems      r   #get_value_by_key_from_saas_settingsr2   I   s,     88z!:: r   dbc                 j   | j                  t              j                  t        j                  |k(  t        j                  j                  d             j                         }|r|j                  !t        t        i t        j                  d      | j                  t        j                        j                  t        j                  dk(  t        j                  dk(        j                         }|rA|j                  dk(  r1|j                  dk(  r!t        t        i t        j                  d      y y y y )NzYour subscription is canceled)moduleerrorstatus_codemessage'suspend_account_when_subscription_failsTtrueexpiredzYour subscription has failed)querySubscriptionfilterr   
deleted_atis_firstcancelled_atr   __name__r	   HTTP_400_BAD_REQUESTr
   r   r   
is_visible)r3   r   merchant_subscription-suspend_account_when_subscription_fails_values       r   cancel_subscription_guardrH   P   s   
	$$3##''-

 
   --9"777	  HH\''(V  $MM''4/ UW 	6 :=CCvM$++y8"# & ; ;:	  9 N :' r   N)typingr   r   sqlalchemy.ormr   src.apps.settings.helperr   src.core.configr   src.middleware.errorsr   	starletter	   +src.apps.site_settings.models.site_settingsr
   intstrr   r   r#   r-   r2   rH    r   r   <module>rS      s}     " 7 $ .  D$$$ &7 & &r   