
    PIi
                     Z   d dl Z d dlZej                  j                  e      Zej                  j                  eej                        Ze j                  j                  de       d dl
Z
d dlmZ d dlmZ d dl d dlmZ  G d d      Zd	 Ze j(                  j*                  r e        yy)
    N   )FacebookSession)FacebookAdsApi)*)FacebookErrorc                   p    e Zd ZdZ ej
                         ZerdZndZed        Z	e
d        Ze
d        Zy)Authenticationa  
        DON'T USE THIS CLASS DIRECTLY. USE `auth()` function from this module
        Helper class to authenticate using config.json config file from this
        repository. This is useful in two cases:
            - Testing environment
            - Interactive exploration in REPL
        This class shouldn't be used in production.
        It's intended for development. Use FacebookAdsApi.init in production
    TFc                     | j                   S N)_is_authenticated)clss    i/var/www/webhook.estador.de/web/meta/bot/venv/lib/python3.12/site-packages/facebook_business/bootstrap.pyis_authenticatedzAuthentication.is_authenticated&   s    $$$    c                     t        t        j                  j                  t        d            5 }t        j                  |      }d d d        |S # 1 sw Y   S xY w)Nzconfig.json)openospathjoinrepo_dirjsonload)r   config_fileconfigs      r   load_configzAuthentication.load_config*   sC    "'',,x78 	,KYY{+F	,	,s   AAc                    | j                         }| j                  r|d   |j                  dd      fS |d   rQ|d   rL|d   rG|d   rBt        j                  |d   |d   |d   |d          d| _        |d   |j                  dd      fS t        d      }|t        |j                               z
  }t        d	j                  d
j                  |      d
j                  |                  )z
            Prepare for Ads API calls and return a tuple with act_id
            and page_id. page_id can be None but act_id is always set.
        act_idpage_idNapp_id
app_secretaccess_tokenT)r   r    r   r!   zN
	File config.json needs to have the following fields: {}
	Missing fields: {}
z, )
r   r   getr   initsetkeysr   formatr   )r   r   required_fieldsmissing_fieldss       r   authzAuthentication.auth0   s     "  (#VZZ	4%@@@(| 4hF>$:x |$~&x 	 %)C!(#VZZ	4%@@@ "BO -s6;;=/AAN))/IIo.IIn-* r   N)__name__
__module____qualname____doc__r   get_default_api_apir   propertyr   classmethodr   r)    r   r   r	   r	      sb     *>))+D !% %  
 $ $r   r	   c                  *    t         j                         S r   )r	   r)   r2   r   r   r)   r)   X   s      r   )sysr   r   dirname__file__this_dirr   pardirr   insertr   facebook_business.sessionr   facebook_business.apir   facebook_business.adobjectsfacebook_business.exceptionsr   r	   r)   flagsinteractiver2   r   r   <module>r@      s     	77??8$77<<")), 8   5 0 ) 6@ @F! 99F r   