
    V
h                        S SK JrJrJrJrJrJr  S SKJrJ	r	J
r
Jr  S SKJr  S SKJrJr  S SKJr  SSKJr  SSKJrJrJr  SS	KJrJrJrJrJr  \" 5       r1 S
kr\RA                  S\S9\" \RB                  5      \" \5      4S\S\RD                  4S jj5       r#\RI                  S\	\   S9\" SSS9\" SSS9\" S S S9\" SSS9\" \RB                  5      \" \5      4S\%S\\%   S\&S\&S\RD                  4
S jj5       r'\RI                  S\S9\" SSS9\" \RB                  5      \" \5      4S\%S\RD                  4S  jj5       r(\RS                  S\S9\" \RB                  5      \" \5      4S\%S!\S\RD                  4S" jj5       r*\RW                  S\S9\" SSS9\" \RB                  5      \" \5      4S\%S\RD                  4S# jj5       r,g)$    )	APIRouterDependsHTTPExceptionQueryPathBody)OptionalListDictAny)datetime)	BaseModelField)database   )get_current_userdetails)SupportActivitySupportActivityCreateSupportActivityUpdate) create_customer_activity_service list_customer_activities_serviceget_customer_activity_service update_customer_activity_service delete_customer_activity_service>   ticketsupport_requestsubscription_request/)response_modelactivitydbc                 h  #    U R                   [        ;  a
  [        SSS9eU R                  (       d   U R	                  SUR                  S5      0S9n U R	                  SUR                  S5      0S9n  [        X5      I Sh  vN nU$  N! [         a  n[        S	S
[        U5       3S9eSnAff = f7f)z
Create a new customer support activity (e.g. a ticket or support request).
Only allowed activity types (ticket, support_request, subscription_request) can be created.
The current user's account_id is used if not provided.
i  z.Activity type not allowed for customer supportstatus_codedetail
account_id)updateuser_id_idN  z$Failed to create customer activity: )	typeALLOWED_CUSTOMER_TYPESr   r&   copygetr   	Exceptionstr)r    r!   current_usernew_activityes        QC:\Suresh\moveshuttle\MDcreated\moveengine\app\v1\routers\saas\supportcustomer.pycreate_customer_activityr5      s      }}224dee==|7G7G7U(V=W}}Y0@0@0G$H}IHe=hKK L e6Z[^_`[aZb4cddes<   A0B23B
 BB
 B2B
 

B/B**B//B2.z0Account ID to filter customer support activities)descriptionNz(Optional filter by allowed activity type)ge
      r&   activity_typeskiplimitc                    #     [        XX#U5      I Sh  vN nU$  N! [         a  n[        SS[        U5       3S9eSnAff = f7f)zs
Retrieve a paginated list of customer support activities for an account.
Only returns records with allowed types.
Nr*   z$Failed to list customer activities: r#   )r   r/   r   r0   )r&   r:   r;   r<   r!   r1   
activitiesr3   s           r4   list_customer_activitiesr?   -   sX     e;JW[dfgg
 h e6Z[^_`[aZb4cddes.   A  A 
A=AAz/{activity_id}zCustomer support activity IDactivity_idc                   #     [        X5      I Sh  vN nU(       d
  [        SSS9eUR                  S5      UR                  S5      :w  a
  [        SSS9eU$  NE! [         a  n[        SS	[	        U5       3S9eSnAff = f7f)
z:
Retrieve details for a single customer support activity.
N  Activity not foundr#   r&     z$Not authorized to view this activityr*   zFailed to retrieve activity: )r   r   r.   r/   r0   )r@   r!   r1   r    r3   s        r4   get_customer_activityrE   @   s     	^6{GGC8LMM<<%)9)9,)GGC8^__ H  ^6STWXYTZS[4\]]^9   BA AAA BA 
A?$A::A??Bactivity_updatec                 
  #     [        XU5      I Sh  vN nU(       d
  [        SSS9eUR                  S5      UR                  S5      :w  a
  [        SSS9eU$  NE! [         a  n[        SS	[	        U5       3S9eSnAff = f7f)
z
Update an existing customer support activity.
Only activities created by the customer (i.e. with allowed types) can be updated.
NrB   rC   r#   r&   rD   z&Not authorized to update this activityr*   zFailed to update activity: )r   r   r.   r/   r0   )r@   rG   r!   r1   updatedr3   s         r4   update_customer_activityrJ   T   s     	\8WYZZC8LMM;;|$(8(8(FFC8`aa [  \6QRUVWRXQY4Z[[\s9   BA AAA BA 
B %A;;B  Bc                   #     [        X5      I Sh  vN nU(       d
  [        SSS9eUR                  S5      UR                  S5      :w  a
  [        SSS9eU$  NE! [         a  n[        SS	[	        U5       3S9eSnAff = f7f)
z%
Delete a customer support activity.
NrB   rC   r#   r&   rD   z&Not authorized to delete this activityr*   zFailed to delete activity: )r   r   r.   r/   r0   )r@   r!   r1   deletedr3   s        r4   delete_customer_activityrM   j   s     	\8IIC8LMM;;|$(8(8(FFC8`aa J  \6QRUVWRXQY4Z[[\rF   )-fastapir   r   r   r   r   r   typingr	   r
   r   r   r   pydanticr   r   app.dbr   dependencies.authr   models.saas.supportmodelr   r   r   services.saas.supportcustomerr   r   r   r   r   routerr,   postget_mongo_dbMongoDBr5   r.   r0   intr?   rE   putrJ   deleterM        r4   <module>r^      sR   H H , ,  %  8 e e  
 O S1 #8#8#8923e#ee 2e. C_ 56C-_`#(;e#faAra"8#8#8923eeC=e e 	e
 	e 7e$ _=C-KL"8#8#8923^^^ >^& _= #8#8#8923	\\*\ 	\ >\* @C-KL"8#8#8923\\\ A\r]   