+
    TŎiT                     \    ^ RI Ht ^ RIHtHtHt ^ RIHt ^ RIH	t	 ^ RI
t
 ! R R]4      tR# )    )FacebookBadObjectError)FacebookAdsApiCursorFacebookRequest)AbstractObject)ObjectParserNc                     a a ] tR t^t oRtR V 3R lltV 3R ltR tR tR t	]
R R l4       tR tR	 tR
 tR tR tR tR tR tR tR tR tR tR tR!R ltR!R ltR!R ltR"R ltR tR R lt]tR#R lt R$R lt!R R lt"R t#Rt$Vt%V ;t&# )%AbstractCrudObjectz
Extends AbstractObject and implements methods to create, read, update,
and delete.
Attributes:
    parent_id: The object's parent's id. (default None)
    api: The api instance associated with this object. (default None)
c                   < \         \        V `  4        T;'       g    \        P                  ! 4       V n        / V n        Ve   Rp\        P                  ! V4       W n	        WP                  R&   RV n        R# )aA  Initializes a CRUD object.
Args:
    fbid (optional): The id of the object ont the Graph.
    parent_id (optional): The id of the object's parent.
    api (optional): An api object which all calls will go through. If
        an api object is not specified, api calls will revert to going
        through the default api.
Nz<parent_id as a parameter of constructor is being deprecated.idT)superr
   __init__r   get_default_api_api_changesloggingwarning
_parent_id_data_include_summary)selffbid	parent_idapiwarning_message	__class__s   &&&& }/Users/ahmad/.openclaw/workspace/scripts/.venv/lib/python3.14/site-packages/facebook_business/adobjects/abstractcrudobject.pyr   AbstractCrudObject.__init__   sd     	 $02;;>99;	!&OOOO,#

4 $    c                   < WP                   9  g   V P                   V,          V8w  d   W P                  V&   \        \        V `  W4       R\        V 4      9   d   V P                  W4       V # )z?Sets an item in this CRUD object while maintaining a changelog._setitem_trigger)r   r   r   r
   __setitem__dirr!   )r   keyvaluer   s   &&&r   r"   AbstractCrudObject.__setitem__3   sY     jj DJJsOu$<!&MM# $3C?T*!!#-r   c                X    V P                   V V P                  P                  VR 4       R # N)r   r   pop)r   r$   s   &&r   __delitem__AbstractCrudObject.__delitem__>   s!    JJsO#t$r   c                    \        WP                  4      ;'       dR    V P                  4       ;'       d:    VP                  4       ;'       d"    V P                  4       VP                  4       8H  # )z4Two objects are the same if they have the same fbid.)
isinstancer   get_idr   others   &&r   __eq__AbstractCrudObject.__eq__B   s_     unn- , , KKM, , $lln, , KKMU\\^+		
r   c                .    V P                  V4      '       * # r(   )r1   r/   s   &&r   __ne__AbstractCrudObject.__ne__O   s    ;;u%%%r   c                   T;'       g    \         P                  ! 4       p\        T;'       g    / 4      pV P                  W24       R P	                  \        \        V4      4      VR&   VP                  RR.VR7      p. pVP                  4       P                  4        F0  w  rxV ! WtR7      p	V	P                  V4       VP                  V	4       K2  	  V# ),idsGET/params)r   )r   r   dict_assign_fields_to_paramsjoinmapstrcalljsonitems	_set_dataappend)
clsr8   r<   fieldsr   responseresultr   dataobjs
   &&&&&     r   
get_by_idsAbstractCrudObject.get_by_idsR   s    55^335fll#$$V4S#/u88E  

 "--///1JDd$CMM$MM# 2 r   c                    \        V R4      '       d9   \        V P                  R4      '       d   W P                  P                  ,          # V R,          # )z8Returns the object's fbid if set. Else, it returns None.Fieldr   )hasattrrP   r   r   s   &r   r.   AbstractCrudObject.get_idf   s<    &-dG&<&<U\A]A]tJJMM"mcghlcmmr   c                    R p\         P                  ! V4        V P                  ;'       g    \        P                  ! 4       # )parent_id is being deprecated.)r   r   r   r   get_default_account_idr   r   s   & r   get_parent_id AbstractCrudObject.get_parent_idk   s1    :(/II."G"G"IIr   c                    V P                   # )z-
Returns the api associated with the object.
)r   rR   s   &r   get_apiAbstractCrudObject.get_apiq   s     yyr   c                    V P                  V P                  P                  4      '       g'   \        RV P                  P
                  ,          4      hV P                  4       # )zfReturns the fbid of the object.
Raises:
    FacebookBadObjectError if the object does not have an id.
z)%s object needs an id for this operation.)getrP   r   r   r   __name__r.   rR   s   &r   get_id_assured!AbstractCrudObject.get_id_assuredw   sK    
 xx

&&(;..))* 
 {{}r   c                    Rp\         P                  ! V4       V P                  4       '       g'   \        RV P                  P
                  ,          4      hV P                  4       # )zpReturns the object's parent's fbid.
Raises:
    FacebookBadObjectError if the object does not have a parent id.
rU   z/%s object needs a parent_id for this operation.)r   r   rX   r   r   r_   rW   s   & r   get_parent_id_assured(AbstractCrudObject.get_parent_id_assured   sW    
 ;(!!##(A..))* 
 !!##r   c                    V P                  4       pV'       g'   \        RV P                  P                  ,          4      hV# )z\Returns the fbid of the object.
Raises:
    FacebookBadObjectError if get_api returns None.
z%s does not yet have an associated api object.
Did you forget to instantiate an API session with: FacebookAdsApi.init(app_id, app_secret, access_token))r[   r   r   r_   )r   r   s   & r   get_api_assured"AbstractCrudObject.get_api_assured   s@    
 lln(H ..))*  
r   c                P    / V n         R V P                  9   d   V P                  R  V # )filename)r   r   rR   s   &r   _clear_history!AbstractCrudObject._clear_history   s&    #

:&r   c                    \        \        V4       F)  pW,          W&   V P                  P                  VR4       K+  	  Wn        V # )zW
Sets object's data as if it were read from the server.
Warning: Does not log changes.
N)r@   rA   r   r)   _json)r   rK   r$   s   && r   rE   AbstractCrudObject._set_data   s?    
 sD>C	DI MMc4(	 "
 
r   c                8    V P                  V P                  4      # )zs
Returns a dictionary of property names mapped to their values for
properties modified from their original values.
)export_valuer   rR   s   &r   export_changed_data&AbstractCrudObject.export_changed_data   s    
   //r   c                "    V P                  4       # )zE
Deprecated. Use export_all_data() or export_changed_data() instead.
)rq   rR   s   &r   export_dataAbstractCrudObject.export_data   s     ''))r   c                2    W P                   P                   V # )zClears the object's fbid.)rP   r   rR   s   &r   clear_idAbstractCrudObject.clear_id   s    r   c                $    V P                  4       3# )z6Returns the node's relative path as a tuple of tokens.)r`   rR   s   &r   get_node_path AbstractCrudObject.get_node_path   s    ##%''r   c                @    RP                  V P                  4       4      # )z#Returns the node's path as a tuple.r:   )r?   rz   rR   s   &r   get_node_path_string'AbstractCrudObject.get_node_path_string   s    xx**,--r   c                  a aa Rp\         P                  ! V4       S P                  4       '       d'   \        RS P                  P
                  ,          4      hR\        S 4      9   g'   \        RS P                  P
                  ,          4      hV'       g   / MVP                  4       pVP                  S P                  4       4       Rp\        S R4      '       d#   S P                  S P                  4       RR7      pMK\        S P                  4       R	S P                  4       S P                   S P                  \#        S R
7      R7      pVP%                  V4       VP'                  V4       Ve"   V V3R lp	V3R lp
VP)                  VV	V
R7      # VP+                  4       pS P-                  VP.                  4       S P1                  4        S # )a6  Creates the object by calling the API.
Args:
    batch (optional): A FacebookAdsApiBatch object. If specified,
        the call will be added to the batch.
    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.
    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.
Returns:
    self if not a batch call.
    the return value of batch.add if a batch call.
zO`remote_create` is being deprecated, please update your code with new function.z#This %s object was already created.get_endpointz Cannot create object of type %s.N
api_createTpendingPOSTreuse_objectnode_idmethodendpointr   target_classresponse_parserc                    < SP                  V P                  4       4       SP                  4        S'       d   S! V 4       R # R # r(   )rE   rC   rj   rI   r   successs   &r   callback_success:AbstractCrudObject.remote_create.<locals>.callback_success  s1    x}}/##%H% r   c                 ,   < S'       d   S! V 4       R # R # r(    rI   failures   &r   callback_failure:AbstractCrudObject.remote_create.<locals>.callback_failure      H% r   requestr   r   )r   r   r.   r   r   r_   r#   	TypeErrorcopyupdateexport_all_datarQ   r   rc   r   r   r   r   
add_params	add_filesadd_requestexecuterE   rm   rj   )r   batchr   filesr<   r   api_versionr   r   r   r   rI   s   f&f&&f&     r   remote_create AbstractCrudObject.remote_create   s   4 l(;;==(5..))*  T*>"nn556 7 7 "v{{}d**,-4&&ood&@&@&BDoQG%224**,II!^^ ,!%!	G 	6"% && $$(( %   (HNN8>>*!Kr   c                  a aa Rp\         P                  ! V4       \        T;'       g    / 4      p\        S R4      '       d   S P	                  RR7      pM=\        S P                  4       RRS P                  S P                  \        S R7      R7      pVP                  V4       VP                  V4       Ve$   V V3R	 lp	V3R
 lp
VP                  VV	V
R7      pV# VP                  4       o S # )ae  Reads the object by calling the API.
Args:
    batch (optional): A FacebookAdsApiBatch object. If specified,
        the call will be added to the batch.
    fields (optional): A list of fields to read.
    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.
    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.
Returns:
    self if not a batch call.
    the return value of batch.add if a batch call.
zM`remote_read` is being deprecated, please update your code with new function.api_getTr   r9   r:   r   r   c                 j   < SP                  V P                  4       4       S'       d   S! V 4       R # R # r(   )rE   rC   r   s   &r   r   8AbstractCrudObject.remote_read.<locals>.callback_successZ  s%    x}}/H% r   c                 ,   < S'       d   S! V 4       R # R # r(   r   r   s   &r   r   8AbstractCrudObject.remote_read.<locals>.callback_failure`  r   r   r   )r   r   r=   rQ   r   r   r`   r   r   r   r   
add_fieldsr   r   )r   r   r   rH   r<   r   r   r   r   r   r   
batch_calls   f&f&&f&     r   remote_readAbstractCrudObject.remote_read+  s    6 j(fll#4##ll4l0G%++-II!^^ ,!%!	G 	6"6"&& **(( + J
 ??$DKr   c                f  a aa Rp\         P                  ! V4       V'       g   / MVP                  4       pVP                  S P	                  4       4       S P                  V4       \        S R4      '       d   S P                  RR7      pM=\        S P                  4       RRS P                  S P                  \        S R7      R7      pVP                  V4       VP                  V4       Ve$   V V3R	 lp	V3R
 lp
VP                  VV	V
R7      pV# VP!                  4        S P#                  4        S # )aU  Updates the object by calling the API with only the changes recorded.
Args:
    batch (optional): A FacebookAdsApiBatch object. If specified,
        the call will be added to the batch.
    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.
    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.
Returns:
    self if not a batch call.
    the return value of batch.add if a batch call.
zO`remote_update` is being deprecated, please update your code with new function.
api_updateTr   r   r:   r   r   c                 L   < SP                  4        S'       d   S! V 4       R # R # r(   )rj   r   s   &r   r   :AbstractCrudObject.remote_update.<locals>.callback_success  s    ##%H% r   c                 ,   < S'       d   S! V 4       R # R # r(   r   r   s   &r   r   :AbstractCrudObject.remote_update.<locals>.callback_failure  r   r   r   )r   r   r   r   rq   rE   rQ   r   r   r`   r   r   r   r   r   r   r   rj   )r   r   r   r   r<   r   r   r   r   r   r   r   s   f&f&&f&     r   remote_update AbstractCrudObject.remote_updatep  s
   4 l(!v{{}d..01v4&&oodo3G%++-II!^^ ,!%!	G 	6"% && **(( + J
 OO!Kr   c                  a aa Rp\         P                  ! V4       \        S R4      '       d   S P                  RR7      pM'\	        S P                  4       RRS P                  R7      pVP                  V4       Ve$   V V3R lpV3R	 lp	VP                  VVV	R
7      p
V
# VP                  4        S P                  4        S # )a  Deletes the object by calling the API with the DELETE http method.
Args:
    batch (optional): A FacebookAdsApiBatch object. If specified,
        the call will be added to the batch.
    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.
    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:
    self if not a batch call.
    the return value of batch.add if a batch call.
zO`remote_delete` is being deprecated, please update your code with new function.
api_deleteTr   DELETEr:   )r   r   r   r   c                 L   < SP                  4        S'       d   S! V 4       R # R # r(   )rw   r   s   &r   r   :AbstractCrudObject.remote_delete.<locals>.callback_success  s    H% r   c                 ,   < S'       d   S! V 4       R # R # r(   r   r   s   &r   r   :AbstractCrudObject.remote_delete.<locals>.callback_failure  r   r   r   )r   r   rQ   r   r   r`   r   r   r   r   rw   )r   r   r   r<   r   r   r   r   r   r   r   s   f&f&f&     r   remote_delete AbstractCrudObject.remote_delete  s    . l(4&&oodo3G%++-II	G 	6"&& **(( + J
 OOMMOKr   c                    Rp\         P                  ! V4       V P                  4       '       d   V P                  ! V/ VB # V P                  ! V/ VB # )zb
Calls remote_create method if object has not been created. Else, calls
the remote_update method.
zM`remote_save` is being deprecated, please update your code with new function.)r   r   r.   r   r   )r   argskwargsr   s   &*, r   remote_saveAbstractCrudObject.remote_save  sM    
 j(;;==%%t6v66%%t6v66r   c                    R \        V 4      9  g   R\        V P                  4      9  d'   \        RV P                  P                  ,          4      hV P                  RV P                  P                  /VVVR7      # )Statusarchivedz!Cannot archive object of type %s.status)r<   r   r   r   )r#   r   r   r   r_   r   r   )r   r   r   r   s   &&&&r   remote_archive!AbstractCrudObject.remote_archive  sw     3t9$
#dkk:J(J?"nn556 7 7$++..   
 	
r   c           	     \    T p\        VVVVVVR7      pV'       d   VP                  4        V# )z
Returns Cursor with argument self as source_object and
the rest as given __init__ arguments.
Note: list(iterate_edge(...)) can prefetch all the objects.
)rH   r<   include_summaryr   )r   load_next_page)	r   target_objects_classrH   r<   fetch_first_pager   r   source_objectcursors	   &&&&&&&  r   iterate_edgeAbstractCrudObject.iterate_edge  s;      +
 !!#r   c                   ^ RI Hp  V'       * pV P                  VVVVVR7      p	V'       d   V	# V'       g   / pM\        V4      pV P                  P                  W#4       Vf   VP                  4       pV P                  4       P                  RV P                  4       V3VR7      P                  4       p
V! 4       pRV
9   d   V
R,          V
R&   VP                  V
4       V# )r   )AdReportRun)r   r   r   r;   report_run_idr   )'facebook_business.adobjects.adreportrunr   r   r=   r   r>   r   rf   rB   r`   rC   rE   )r   r   rH   r<   is_asyncr   r   r   synchronoussynchronous_iteratorrI   rJ   s   &&&&&&&     r   iterate_edge_async%AbstractCrudObject.iterate_edge_async1  s     	H	  #l#00 (+  1  
 ''F&\F//?
 +88:H'')..  "H- / 
 $&	 	 h&%o6HTN"r   c                    V'       g   / MVP                  4       pRVR&   V P                  VVVVR7       F  pVu # 	  R# )z
Returns first object when iterating over Cursor with argument
self as source_object and the rest as given __init__ arguments.
1limit)rH   r<   r   N)r   r   )r   r   rH   r<   r   rL   s   &&&&& r   edge_objectAbstractCrudObject.edge_objectj  sN    
 "v{{}w$$ 	 % 
C J
 r   c                @    V P                   '       g   \        R 4      hR# )z)Api call cannot be made if api is not setN)r   r   rR   s   &r   assure_callAbstractCrudObject.assure_call|  s     yyy(;= = r   )r   r   r   rm   r   )NNN)NNNNNN)NNNNN)NNTTN)NNFTN)'r_   
__module____qualname____firstlineno____doc__r   r"   r*   r1   r4   classmethodrM   r.   rX   r[   r`   rc   rf   rj   rE   rq   rt   rw   rz   r}   r   r   r   r   r   r   saver   r   r   r   __static_attributes____classdictcell____classcell__)r   __classdict__s   @@r   r
   r
      s     %*	%
&  &n
J$$0*
(.OfAJDP8z
7
& D67r$= =r   r
   )facebook_business.exceptionsr   facebook_business.apir   r   r   *facebook_business.adobjects.abstractobjectr   (facebook_business.adobjects.objectparserr   r   r
   r   r   r   <module>r      s.     F A j	= j	=r   