
    PIit                     T   d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
 d dl	mZ d dlmZ d dlZd dlmZ d dlZd dlZd dlZd dlZ	 d d	lmZ d d
lmZ d dlmZ 	  G d de      Z G d de      Z G d de      Z G d d      Z  G d de      Z!ed        Z"d Z#y# e$ r d dlZY Zw xY w)    )FacebookSession)	apiconfig)FacebookRequestErrorFacebookBadObjectError$FacebookUnavailablePropertyExceptionFacebookBadParameterError)	api_utils)urls)contextmanagerN)http_client)collections_abc)ObjectParser)TypeCheckerc                   H    e Zd ZdZddZd Zd Zd Zd Zd Z	d	 Z
d
 Zd Zy)FacebookResponsez8Encapsulates an http response from Facebook's Graph API.Nc                 D    || _         || _        |xs i | _        || _        y)a   Initializes the object's internal data.
        Args:
            body (optional): The response body as text.
            http_status (optional): The http status code.
            headers (optional): The http headers.
            call (optional): The original call that was made.
        N)_body_http_status_headers_call)selfbodyhttp_statusheaderscalls        c/var/www/webhook.estador.de/web/meta/bot/venv/lib/python3.12/site-packages/facebook_business/api.py__init__zFacebookResponse.__init__/   s%     
'2
    c                     | j                   S )zReturns the response body.)r   r   s    r   r   zFacebookResponse.body<   s    zzr   c                     	 t        j                  | j                        S # t        t        f$ r | j                  cY S w xY w)z1Returns the response body -- in json if possible.)jsonloadsr   	TypeError
ValueErrorr    s    r   r"   zFacebookResponse.json@   s8    	::djj)):& 	::	s   ! ??c                     | j                   S )zReturn the response headers.r   r    s    r   r   zFacebookResponse.headersG   s    }}r   c                 8    | j                   j                  d      S )z+Returns the ETag header value if it exists.ETag)r   getr    s    r   etagzFacebookResponse.etagK   s    }}  ((r   c                     | j                   S )z-Returns the http status code of the response.)r   r    s    r   statuszFacebookResponse.statusO   s       r   c                 
   | j                         }t        |t        j                        rd|v ryt	        |      rd|v r|d   S d|vS | j
                  t        j                  k(  ry| j
                  t        j                  k(  ryy)z6Returns boolean indicating if the call was successful.errorFsuccesszService UnavailableT)	r"   
isinstancer   Mappingboolr   r   NOT_MODIFIEDOK)r   	json_bodys     r   
is_successzFacebookResponse.is_successS   s     IIK	i!8!89g>R)_I% ++(	99+":"::+..0 r   c                 $    | j                          S )z.Returns boolean indicating if the call failed.)r7   r    s    r   
is_failurezFacebookResponse.is_failurek   s    ??$$$r   c                     | j                         rCt        d| j                  | j                         | j	                         | j                               S y)z~
        Returns a FacebookRequestError (located in the exceptions module) with
        an appropriate debug message.
        zCall was not successfulN)r9   r   r   r-   r   r   r    s    r   r/   zFacebookResponse.erroro   sE    
 ??')

		  r   )NNNN)__name__
__module____qualname____doc__r   r   r"   r   r+   r-   r7   r9   r/    r   r   r   r   +   s2    B)!0%r   r   c                       e Zd ZdZej
                  d   Zej
                  d   ZdZdZ	dZ
ddez  iZd	Zd	Zdd
Zd Zd Ze	 	 	 	 	 	 	 	 	 dd       Zed        Zed        Zed        Zed        Z	 	 	 	 	 ddZd Zy	)FacebookAdsApia  Encapsulates session attributes and methods to make API calls.
    Attributes:
        SDK_VERSION (class): indicating sdk version.
        HTTP_METHOD_GET (class): HTTP GET method name.
        HTTP_METHOD_POST (class): HTTP POST method name
        HTTP_METHOD_DELETE (class): HTTP DELETE method name
        HTTP_DEFAULT_HEADERS (class): Default HTTP headers for requests made by
            this sdk.
    SDK_VERSIONAPI_VERSIONGETPOSTDELETEz
User-Agentzfbbizsdk-python-%sNc                 f    || _         d| _        d| _        |xs | j                  | _        || _        y)zInitializes the api instance.
        Args:
            session: FacebookSession object that contains a requests interface
                and attribute GRAPH (the Facebook GRAPH API URL).
            api_version: API version
        r   N)_session_num_requests_succeeded_num_requests_attemptedrC   _api_version_enable_debug_logger)r   sessionapi_versionenable_debug_loggers       r   r   zFacebookAdsApi.__init__   s6      '($'($';4+;+;$7!r   c                     | j                   S )z&Returns the number of calls attempted.)rJ   r    s    r   get_num_requests_attemptedz)FacebookAdsApi.get_num_requests_attempted       +++r   c                     | j                   S )z+Returns the number of calls that succeeded.)rI   r    s    r   get_num_requests_succeededz)FacebookAdsApi.get_num_requests_succeeded   rR   r   c
                     t        |||||      }
 | |
||      }| j                  |       |r| j                  |       |	r(ddlm} |r|j                          |j                          |S )N)rO   r   )CrashReporter)r   set_default_apiset_default_account_idfacebook_business.crashreporterrV   enableLoggingenable)clsapp_id
app_secretaccess_token
account_idrN   proxiestimeoutdebug	crash_logrM   apirV   s                r   initzFacebookAdsApi.init   sl     "&*lG")+';EBC &&z2E++-  "
r   c                     || _         y)a  Sets the default api instance.
        When making calls to the api, objects will revert to using the default
        api if one is not specified when initializing the objects.
        Args:
            api_instance: The instance which to set as default.
        N_default_api)r\   api_instances     r   rW   zFacebookAdsApi.set_default_api   s     (r   c                     | j                   S )z!Returns the default api instance.rh   r\   s    r   get_default_apizFacebookAdsApi.get_default_api   s     r   c                 f    t        |      }|j                  d      dk(  rt        d      || _        y )Nact_zeAccount ID provided in FacebookAdsApi.set_default_account_id expects a string that begins with 'act_')strfindr%   _default_account_id)r\   r`   s     r   rX   z%FacebookAdsApi.set_default_account_id   s8    _
??6"b(;  #-r   c                     | j                   S N)rs   rl   s    r   get_default_account_idz%FacebookAdsApi.get_default_account_id   s    &&&r   c                 D   |si }|si }|si }|xs | j                   }|r.t        j                  d|      st        d| j                  z        | xj
                  dz  c_        t        |t        j                        sIdj                  |xs | j                  j                  |dj                  t        t        |            f      }|j                         }|j                  t         j"                         |rt%        |      }|dv r@| j                  j&                  j)                  |||||| j                  j*                        }n?| j                  j&                  j)                  |||||| j                  j*                        }| j,                  r(dd	l}	t1        |	j3                  |j(                               t5        |j6                  |j8                  |j:                  |||||d
      }
|
j=                         r|
j?                         | xj@                  dz  c_         |
S )aN  Makes an API call.
        Args:
            method: The HTTP method name (e.g. 'GET').
            path: A tuple of path tokens or a full URL string. A tuple will
                be translated to a url as follows:
                graph_url/tuple[0]/tuple[1]...
                It will be assumed that if the path is not a string, it will be
                iterable.
            params (optional): A mapping of request parameters where a key
                is the parameter name and its value is a string or an object
                which can be JSON-encoded.
            headers (optional): A mapping of request headers where a key is the
                header name and its value is the header value.
            files (optional): An optional mapping of file names to binary open
                file objects. These files will be attached to the request.
        Returns:
            A FacebookResponse object containing the response body, headers,
            http status, and summary of the call that was made.
        Raises:
            FacebookResponse.error() if the request failed.
        zv[0-9]+\.[0-9]+z:Please provide the API version in the following format: %s   /)rD   rF   )paramsr   filesrb   )datar   r{   rb   r   N)methodpathrz   r   r{   r   r   r   r   )!rK   researchr   rC   rJ   r1   sixstring_typesjoinrH   GRAPHmaprq   copyupdaterA   HTTP_DEFAULT_HEADERS_top_level_param_json_encoderequestsrequestrb   rL   curlifyprintto_curlr   textr   status_coder9   r/   rI   )r   r}   r~   rz   r   r{   url_overriderN   responser   fb_responses              r   r   zFacebookAdsApi.call   s   > FGE!6T%6%6ryy);[I(L""# 
 	$$)$$ 0 01883 3 3S$( D ,,.~::;1&9F &&}}--55-- 6 H }}--55-- 6 H $$'//("2"234&$$ ,,  "	
 !!###%%$$)$r   c                     t        |       S )zj
        Returns a new FacebookAdsApiBatch, which when executed will go through
        this api.
        )re   )FacebookAdsApiBatchr    s    r   	new_batchzFacebookAdsApi.new_batchU  s    
 #t,,r   )NF)	NNNNNNNFT)NNNNN)r;   r<   r=   r>   r   ads_api_configrB   rC   HTTP_METHOD_GETHTTP_METHOD_POSTHTTP_METHOD_DELETEr   ri   rs   r   rQ   rT   classmethodrf   rW   rm   rX   rv   r   r   r?   r   r   rA   rA      s	    **=9K**=9KO! 	*[8 L8,,   8 ( (     - - ' ' gR-r   rA   c                   D    e Zd ZdZddZd Z	 	 	 	 	 	 d	dZ	 	 ddZd Zy)
r   a/  
    Exposes methods to build a sequence of calls which can be executed with
    a single http request.
    Note: Individual exceptions won't be thrown for each call that fails.
        The success and failure callback functions corresponding to a call
        should handle its success or failure.
    Nc                     || _         g | _        g | _        g | _        g | _        || j                  j                  |       || j                  j                  |       g | _        y ru   )_api_files_batch_success_callbacks_failure_callbacksappend	_requests)r   re   r0   failures       r   r   zFacebookAdsApiBatch.__init__g  sb    	"$"$##**73##**73r   c                 ,    t        | j                        S ru   )lenr   r    s    r   __len__zFacebookAdsApiBatch.__len__s      4;;r   c	           	      0   t        |t        j                        sdj                  |      }	n|}	||	d}
|r~t	        |      }|j                         D cg c]  \  }}|dt        j                  |      ! }}}|dk(  r |
dxx   ddj                  |      z   z  cc<   ndj                  |      |
d<   |r"d	j                  |j                               |
d
<   |r/g |
d<   |D ]%  }i }||d<   ||   |d<   |
d   j                  |       ' | j                  j                  |
       | j                  j                  |       | j                  j                  |       | j                  j                  |       | j                  j                  |       |
S c c}}w )a"  Adds a call to the batch.
        Args:
            method: The HTTP method name (e.g. 'GET').
            relative_path: A tuple of path tokens or a relative URL string.
                A tuple will be translated to a url as follows:
                    <graph url>/<tuple[0]>/<tuple[1]>...
                It will be assumed that if the path is not a string, it will be
                iterable.
            params (optional): A mapping of request parameters where a key
                is the parameter name and its value is a string or an object
                which can be JSON-encoded.
            headers (optional): A mapping of request headers where a key is the
                header name and its value is the header value.
            files (optional): An optional mapping of file names to binary open
                file objects. These files will be attached to the request.
            success (optional): A callback function which will be called with
                the FacebookResponse of this call if the call succeeded.
            failure (optional): A callback function which will be called with
                the FacebookResponse of this call if the call failed.
            request (optional): The APIRequest object
        Returns:
            A dictionary describing the call.
        ry   )r}   relative_url=rD   r   ?&r   ,attached_filesr   namevalue)r1   r   r   r   r   itemsr
   quote_with_encodingkeysr   r   r   r   r   r   )r   r}   relative_pathrz   r   r{   r0   r   r   r   r   keyr   keyvalsheaderbatch_formatted_headers                   r   addzFacebookAdsApiBatch.addv  s   D -)9)9:88M2L(L (

 1&9F)/9%3 #&t'?'?'FG 9G 9^$chhw.?(??$"xx0V%(XXejjl%;D!" DO! ?)+&17&v.29&/&w/Y&&'=>	? 	4 5!&&w/&&w/g&19s   $Fc           	          t        j                  |j                        }|j                  rdj	                  |j                        |d<   | j                  |j                  |j                  ||j                  |||      S )a  Interface to add a APIRequest to the batch.
        Args:
            request: The APIRequest object to add
            success (optional): A callback function which will be called with
                the FacebookResponse of this call if the call succeeded.
            failure (optional): A callback function which will be called with
                the FacebookResponse of this call if the call failed.
            Returns:
                A dictionary describing the call.
        r   fields)r}   r   rz   r{   r0   r   r   )	r   deepcopy_params_fieldsr   r   _method_path_file_params)r   r   r0   r   updated_paramss        r   add_requestzFacebookAdsApiBatch.add_request  sm      w7??'*xx'@N8$xx??!--!&&  
 	
r   c                    | j                   syd}t               }d| j                   i}i }| j                  D ]  }|s|j                  |        | j                  j                  ||||      }|j                         }g }t        |      D ]  \  }	}
|
r|
j                  d      }|
j                  d      }|
j                  d      }t        |||| j                   |	         }|j                         r&| j                  |	   sw | j                  |	   |       | j                  |	   s | j                  |	   |       |j                  |	        |r| j                  | j                        }|D 	cg c]  }	| j                  |	    c}	|_        |D 	cg c]  }	| j                   |	    c}	|_         |D 	cg c]  }	| j                  |	    c}	|_        |D 	cg c]  }	| j                  |	    c}	|_        |S yc c}	w c c}	w c c}	w c c}	w )	aJ  Makes a batch call to the api associated with this object.
        For each individual call response, calls the success or failure callback
        function if they were specified.
        Note: Does not explicitly raise exceptions. Individual exceptions won't
        be thrown for each call that fails. The success and failure callback
        functions corresponding to a call should handle its success or failure.
        Returns:
            If some of the calls have failed, returns  a new FacebookAdsApiBatch
            object with those calls. Otherwise, returns None.
        NrE   batch)rz   r{   r   coder   r   )r   tupler   r   r   r   r"   	enumerater*   r   r7   r   r   r   	__class__)r   r}   r~   rz   r{   
call_filesr   	responsesretry_indicesindexr   r   r   r   inner_fb_responser   s                   r   executezFacebookAdsApiBatch.execute  s    {{w4;;'++ 	)JZ(	) iinn	 % 
  $$&	(3 	,OE8||F+||F+",,y1$4# $U+	%! %//1..u56//67HI,,U32D++E23DE$$U+'	,* tyy1I@MNuE 2NI@MNuE 2NI9F,H05 -1,C,CE,J ,HI( :G,H05 -1,C,CE,J ,HI(  ON,H,Hs   2G9G>6HHNN)NNNNNN)	r;   r<   r=   r>   r   r   r   r   r   r?   r   r   r   r   ]  s>    
  FV 	
:>r   r   c                   z    e Zd ZdZd ei i       ddddddfdZd Zd Zd Zd	 Z	d
 Z
d Zd Zd Zd ZddZd Zy)FacebookRequestz#
    Represents an API request
    NFTc                    |xs t         j                         | _        || _        || _        |j                  dd      | _        ||j                  dd      f| _        || _        || _	        || _
        || _        |	| _        |
| _        || _        i | _        g | _        i | _        d| _        g | _        |*|j(                  j*                  j-                         | _        yy)a  
        Args:
            node_id: The node id to perform the api call.
            method: The HTTP method of the call.
            endpoint: The edge of the api call.
            api (optional): The FacebookAdsApi object.
            param_checker (optional): Parameter checker.
            target_class (optional): The return class of the api call.
            api_type (optional): NODE or EDGE type of the call.
            allow_file_upload (optional): Whether the call allows upload.
            response_parser (optional): An ObjectParser to parse response.
            include_summary (optional): Include "summary".
            api_version (optional): API version.
        ry    r   N)rA   rm   r   _node_idr   replace	_endpointr   _param_checker_target_class	_api_type_allow_file_upload_response_parser_include_summaryrK   r   r   r   _file_counter_accepted_fieldsField__dict__values)r   node_idr}   endpointre   param_checkertarget_classapi_typeallow_file_uploadresponse_parserinclude_summaryrN   s               r   r   zFacebookRequest.__init__!  s    8 ;>99;	!))#r2x//R89
+)!"3 / /' "#$0$6$6$?$?$F$F$HD! $r   c                 @   | j                   s%t        j                  d| j                  z   dz          dt	        | j
                        z   }t        j                  j                  |      r&|| j                  |<   | xj
                  dz  c_        | S t        d|z   dz         )Nz	Endpoint z cannot upload filessourcerx   zCannot find file !)r   r	   warningr   rq   r   osr~   isfiler   r   )r   	file_pathfile_keys      r   add_filezFacebookRequest.add_fileQ  s    &&kDNN:=SSTc$"4"45577>>)$*3Dh'!#
  ,#i/#5 r   c                 >    || S |D ]  }| j                  |        | S ru   )r   )r   r{   r   s      r   	add_fileszFacebookRequest.add_files^  s,    =K 	%IMM)$	%r   c                     || j                   vr| j                   j                  |       || j                  vr%t        j                  | j
                  dz   |z          | S )Nz does not allow field )r   r   r   r	   r   r   )r   fields     r   	add_fieldzFacebookRequest.add_fielde  sP    $LL&---dnn/GG%OPr   c                 >    || S |D ]  }| j                  |        | S ru   )r   )r   r   r   s      r   
add_fieldszFacebookRequest.add_fieldsl  s,    >K 	"ENN5!	"r   c                 |   | j                   j                  ||      sUt        j                  d|z   dz   dz   | j                   j	                  |      z   dz   dz   t        t        |            z          | j                   j                  |      r|| j                  |<   | S | j                  |      | j                  |<   | S )Nz	value of z might not be compatible. z Expect z; z got )r   is_valid_pairr	   r   get_typerq   typeis_file_paramr   _extract_valuer   )r   r   r   s      r   	add_paramzFacebookRequest.add_params  s    ""00e<kC/2NN!0099#>?AEFd5k*+ , ,,S1%*Dc"  !% 3 3E :DLLr   c                 b    || S |j                         D ]  }| j                  |||           | S ru   )r   r  )r   rz   r   s      r   
add_paramszFacebookRequest.add_params~  s8    >K;;= 	-CNN3s,	-r   c                 ,    t        | j                        S ru   )listr   r    s    r   
get_fieldszFacebookRequest.get_fields  s    DLL!!r   c                 @    t        j                  | j                        S ru   )r   r   r   r    s    r   
get_paramszFacebookRequest.get_params  s    }}T\\**r   c           
      8   t        j                  | j                        }| j                  dk(  rz| j                  dk(  rkt        | j                  || j                  | j                  | j                  | j                  | j                  | j                        }|j                          |S | j                  rdj                  | j                        |d<   t        | j                         5 }| j                  j#                  | j                  | j$                  ||| j&                        }|j)                         r|j)                         | j                  r2| j                  j+                  |j-                               cd d d        S |cd d d        S # 1 sw Y   y xY w)NEDGErD   )target_objects_classrz   r   r   re   r   r   object_parserr   r   )r}   r~   rz   r{   rN   )r   r   r   r   r   Cursorr   r   r   r   r   r   r   load_next_pager   
open_filesr   r   r   rK   r/   parse_singler"   )r   rz   cursorr{   r   s        r   r   zFacebookRequest.execute  sD   t||,>>V#(=%)%7%7|| $ 5 5II"33	F !!#M<<"xx5F8))* 	 eyy~~||jj -- & H ~~nn&&$$,,99(--/J	  	   	  	  	 s   (BFFFc                 *    |j                  | ||       y ru   )r   )r   r   r0   r   s       r   add_to_batchzFacebookRequest.add_to_batch  s    $1r   c                     t        |d      r|j                         S t        |t              r|D cg c]  } j	                  |       c}S t        |t
              r"t         fd|j                         D              S |S c c}w )Nexport_all_datac              3   h   K   | ])  \  }}j                  |      j                  |      f + y wru   )r  ).0kvr   s      r   	<genexpr>z1FacebookRequest._extract_value.<locals>.<genexpr>  s8      -Q ,,Q/1D1DQ1GH -s   /2)hasattrr  r1   r  r  dictr   )r   r   items   `  r   r  zFacebookRequest._extract_value  sz    5+,((**t$:?@$D''-@@t$ -#kkm- - - L As   Br   )r;   r<   r=   r>   r   r   r   r   r   r   r  r  r	  r  r   r  r  r?   r   r   r   r     sg     !"b).I`	"+ @2	r   r   c                   p    e Zd ZdZ	 	 	 	 	 	 	 	 	 ddZd Zd Zd Zd ZeZ	d Z
d	 Zd
 Zd Zd Zd Zd Zy)r  a  Cursor is an cursor over an object's connections.
        Previously called EdgeIterator.
    Examples:
        >>> me = AdAccountUser('me')
        >>> my_accounts = [act for act in Cursor(me, AdAccount)]
        >>> my_accounts
        [<AdAccount act_abc>, <AdAccount act_xyz>]
    Nc
                    t        |xs i       | _        |j                  || j                         || _        || _        |xs |j                         | _        |xs |j                         | _        |xs |j                         | _
        | j                  | j                  f| _        g | _        g | _        d| _        d| _        d| _        |xs d| j                  v | _        |	xs! t%        | j                  | j                        | _        y)ae  
        Initializes an cursor over the objects to which there is an edge from
        source_object.
        To initialize, you'll need to provide either (source_object and
        target_objects_class) or (api, node_id, endpoint, and object_parser)
        Args:
            source_object: An AbstractObject instance from which to inspect an
                edge. This object should have an id.
            target_objects_class: Objects traversed over will be initialized
                with this AbstractObject class.
            fields (optional): A list of fields of target_objects_class to
                automatically read in.
            params (optional): A mapping of request parameters where a key
                is the parameter name and its value is a string or an object
                which can be JSON-encoded.
            include_summary (optional): Include summary.
            api (optional): FacebookAdsApi object.
            node_id (optional): The ID of calling node.
            endpoint (optional): The edge name.
            object_parser (optional): The ObjectParser to parse response.
        FNdefault_summary)re   r   )r  rz   _assign_fields_to_params_source_object_target_objects_classget_id_assuredr   get_endpointr   get_apir   r   _queuer   _finished_iteration_total_count_summaryr   r   _object_parser)
r   source_objectr  r   rz   r   re   r   r   r  s
             r   r   zCursor.__init__  s    B 6<R(55fdkkJ+%9"A=#?#?#A!H%9%F%F%H2=002	MMNN

 #(   / S3D3S+ 
|		330
r   c                 ,    t        | j                        S ru   )rq   r*  r    s    r   __repr__zCursor.__repr__  r   r   c                 ,    t        | j                        S ru   )r   r*  r    s    r   r   zCursor.__len__  r   r   c                     | S ru   r?   r    s    r   __iter__zCursor.__iter__  s    r   c                     | j                   s| j                         s
t               | j                   j                  d      S )Nr   )r*  r  StopIterationpopr    s    r   __next__zCursor.__next__  s1     {{4#6#6#8/!{{q!!r   c                      | j                   |   S ru   )r*  )r   r   s     r   __getitem__zCursor.__getitem__  s    {{5!!r   c                     | j                   S ru   r'   r    s    r   r   zCursor.headers  s    }}r   c                 H    | j                   t        d      | j                   S )NzBCouldn't retrieve the object total count for that type of request.)r,  r   r    s    r   totalzCursor.total  s.    $6     r   c                     | j                   t        | j                   t              st        d      dt	        j
                  | j                   ddd      S )Nz>Couldn't retrieve the object summary for that type of request.z
<Summary> T   )r   z: )	sort_keysindent
separators)r-  r1   r  r   r"   dumpsr    s    r   summaryzCursor.summary  sY    == 
4==$(G6  )H JJ&	
 	
r   c                    | j                   ry| j                  r+d| j                  vrd| j                  vrd| j                  d<   | j                  j	                  d| j
                  | j                        }|j                         }|j                         | _        d|v r1d|d   v r*d	|d   d   v r d
|d   v r|d   d   d	   | j                  d	<   nd| _         | j                  rd|v rd|d   v r|d   d   | _	        | j                  rd|v r
|d   | _
        | j                  |      | _        t        | j                        dkD  S )zQueries server for more nodes and loads them into the internal queue.
        Returns:
            True if successful, else False.
        Fr#  rD  TrD   )rz   pagingcursorsafternexttotal_countr   )r+  r   rz   r   r   r   r"   r   r   r,  r-  build_objects_from_responser*  r   )r   response_objr   s      r   r  zCursor.load_next_page-  sZ   
 ## !!T[[0T[[(%)DKK	"yy~~JJ;; & 

  $$&$,,.  (++x))44hx((#+H#5i#@#IDKK  (,D$ !!!Xi00 ( 3M BD  Y(%:$Y/DM66x@4;;!##r   c                     | D ]  }|c S  y ru   r?   )r   objs     r   get_onezCursor.get_one]  s     	CJ	r   c                 8    | j                   j                  |      S ru   )r.  parse_multiple)r   r   s     r   rK  z"Cursor.build_objects_from_responseb  s    ""11(;;r   )	NNNNTNNNN)r;   r<   r=   r>   r   r1  r   r4  r8  rI  r:  r   r=  rD  r  rO  rK  r?   r   r   r  r    si     !5
n  " D"!
.$`
<r   r  c              #      K   i }| j                         D ]"  \  }}|j                  |t        |d      i       $ | |j                         D ]  }|j	                           y w)Nrb)r   r   openr   close)r{   opened_filesr   r~   files        r   r  r  f  se     L[[] 5	TS$tT"2345
##% 

s   A"A$c                 *   | j                         } | j                         D ]o  \  }}t        |t        j                  t        j
                  t        f      r6t        |t        j                        st        j                  |dd      | |<   k|| |<   q | S )NT)r   :)r@  rB  )r   r   r1   r   r2   Sequencer3   r   r   r"   rC  )rz   paramr   s      r   r   r   p  s    [[]F "uu668P8PRVWXuc&6&67 JJ%F5M "F5M" Mr   )$facebook_business.sessionr   facebook_businessr   facebook_business.exceptionsr   r   r   r   facebook_business.utilsr	   r
   
contextlibr   r   	six.movesr   r   r"   r   r   r   ImportErrorcollections(facebook_business.adobjects.objectparserr   facebook_business.typecheckerr   objectr   rA   r   r   r  r  r   r?   r   r   <module>rg     s    6 '  . ( %  ! 	  
 	('
 B 5
Rv RjZ-V Z-z|& |~[ [|i<V i<X  e  ('(s   B 	B'&B'