
    V
h                        S SK Jr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JrJrJrJr  \" 5       r " S	 S
\5      r " S S\5      r " S S\5      r  " S S\5      r!\RE                  S\!S9\" \RF                  5      \" \5      4S\S\RH                  4S jj5       r%\RM                  S\
\!   S9\" SSS9\" SSS9\" S S S9\" SSS9\" \RF                  5      \" \5      4S\'S\	\'   S \(S!\(S\RH                  4
S" jj5       r)\RM                  S#\!S9\" SS$S9\" \RF                  5      \" \5      4S%\'S\RH                  4S& jj5       r*\RW                  S#\!S9\" \RF                  5      \" \5      4S%\'S'\ S\RH                  4S( jj5       r,\R[                  S#\!S9\" SS$S9\" \RF                  5      \" \5      4S%\'S\RH                  4S) jj5       r.\RM                  S*\\'\4   S9\" SS+S9\" \RF                  5      \" \5      4S\'S\RH                  4S, jj5       r/\RE                  S-\!S9\" SS.S/S09\" SS.S1S09\" \RF                  5      \" \5      4S\'S2\'S\RH                  4S3 jj5       r0g)4    )	APIRouterDependsHTTPExceptionQueryPathBodyRequest)OptionalListDictAny)datetime)	BaseModelField)database   )get_current_userdetails)create_activity_servicelist_activities_serviceget_activity_serviceupdate_activity_servicedelete_activity_serviceget_support_dashboard_serviceupdate_pipeline_status_servicec                       \ rS rSr% \" SSS9r\\S'   \" SSS9r\\S'   \" SS	S9r	\
\   \S
'   \" SSS9r\
\   \S'   \" SSS9r\
\\\4      \S'   Srg)SupportActivityBase   .zFType of activity, e.g. 'comment', 'meeting', 'note', 'pipeline_update'descriptiontypez(Account ID associated with this activity
account_idNz&ID of the user performing the activityuser_idz0Main content (comment text, meeting notes, etc.)contentz\Extra details (for meetings: scheduled_date, for pipeline updates: old and new status, etc.)additional_data )__name__
__module____qualname____firstlineno__r   r    str__annotations__r!   r"   r
   r#   r$   r   r   __static_attributes__r%       IC:\Suresh\moveshuttle\MDcreated\moveengine\app\v1\routers\saas\support.pyr   r      sv    c'opD#pC-WXJX"45]^GXc]^"45ghGXc]h05x1OXd38n- r-   r   c                       \ rS rSrSrg)SupportActivityCreate    r%   N)r&   r'   r(   r)   r,   r%   r-   r.   r0   r0       s    r-   r0   c                   \    \ rS rSr% \" SSS9r\\   \S'   \" SSS9r	\\
\\4      \S'   Srg)	SupportActivityUpdate#   NzUpdated contentr   r#   zUpdated extra detailsr$   r%   )r&   r'   r(   r)   r   r#   r
   r*   r+   r$   r   r   r,   r%   r-   r.   r3   r3   #   s7    "45FGGXc]G05dH_0`OXd38n-`r-   r3   c                   8    \ rS rSr% \" SSS9r\\S'   \\S'   Sr	g)	SupportActivity'   ._id)aliasactivity_idcreated_dater%   N)
r&   r'   r(   r)   r   r:   r*   r+   r   r,   r%   r-   r.   r6   r6   '   s    S.K.r-   r6   /)response_modelactivitydbc                    #    U R                   (       d   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)zm
Create a new support activity record.
If account_id is not provided, the current user's account_id is used.
r!   )updateN  zFailed to create activity: status_codedetail)r!   copygetr   	Exceptionr   r*   )r>   r?   current_usernew_activityes        r.   create_activityrL   /   s}      ==|7G7G7U(V=W\4XBB C \6QRUVWRXQY4Z[[\s:   2A4A A
A 	A4
A 
A1A,,A11A4.zAccount ID to filter activitiesr   Nz'Filter by activity type, e.g. 'comment')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)ze
Retrieve a paginated list of support activities for an account.
You may filter by the 'type' field.
NrB   zFailed to list activities: rC   )r   rH   r   r*   )r!   rP   rQ   rR   r?   rI   
activitiesrK   s           r.   list_activitiesrU   A   sW     \2:d[]^^
 _ \6QRUVWRXQY4Z[[\s.   A  A 
A=AAz/{activity_id}zSupport activity IDr:   c                    #     [        X5      I Sh  vN nU(       d
  [        SSS9eU$  N! [         a  n[        SS[        U5       3S9eSnAff = f7f)z6
Retrieve a single support activity record by its ID.
N  Activity not foundrC   rB   zFailed to retrieve activity: )r   r   rH   r*   )r:   r?   rI   r>   rK   s        r.   get_activityrY   T   sc     ^-k>>C8LMM ?  ^6STWXYTZS[4\]]^0   A, *, A, 
AAAAactivity_updatec                    #     [        XU5      I Sh  vN nU(       d
  [        SSS9eU$  N! [         a  n[        SS[        U5       3S9eSnAff = f7f)z&
Update an existing support activity.
NrW   rX   rC   rB   zFailed to update activity: )r   r   rH   r*   )r:   r[   r?   rI   updatedrK   s         r.   update_activityr^   e   sf     \/bQQC8LMM R  \6QRUVWRXQY4Z[[\s0   A- +- A- 
AAAAc                    #     [        X5      I Sh  vN nU(       d
  [        SSS9eU$  N! [         a  n[        SS[        U5       3S9eSnAff = f7f)z#
Delete a support activity record.
NrW   rX   rC   rB   zFailed to delete activity: )r   r   rH   r*   )r:   r?   rI   deletedrK   s        r.   delete_activityra   w   sd     \/@@C8LMM A  \6QRUVWRXQY4Z[[\rZ   z/dashboard/{account_id}z(Account ID for support dashboard metricsc                    #     [        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
Return aggregated support metrics for the account:
  - Count of support comments/notes
  - Count of upcoming meetings
  - (Trial info is handled in subscriptions)
NrB   zDashboard error: rC   )r   rH   r   r*   )r!   r?   rI   	dashboardrK   s        r.   support_dashboardrd      sN     R7
GG	 H R6GAx4PQQRs.   A  A 
A ;A  Az	/pipelineTzAccount ID for pipeline update)embedr   z5New sales pipeline status (e.g. 'trial', 'live paid')
new_statusc                    #     [        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)z
Update the sales pipeline status for an account.
This endpoint updates the account record and logs the change as a support activity.
NrB   zPipeline update failed: rC   )r   rH   r   r*   )r!   rf   r?   rI   r>   rK   s         r.   update_pipeline_statusrh      sQ     Y7
PRSS T Y6NsSTvh4WXXYs.   A  A 
A<AA)1fastapir   r   r   r   r   r   r	   typingr
   r   r   r   r   pydanticr   r   app.dbr   dependencies.authr   services.saas.supportr   r   r   r   r   r   r   routerr   r0   r3   r6   postget_mongo_dbMongoDBrL   rG   r*   intrU   rY   putr^   deletera   rd   rh   r%   r-   r.   <module>rv      s_   Q Q Q , ,  %  8   
) 	/ 	aI a)  S1 #8#8#8923\#\\ 2\" C_ 56C-NO#(;d#eaAra"8#8#8923\\C=\ \ 	\
 	\ 7\$ _=C-BC"8#8#8923^^^ >^  _= #8#8#8923	\\*\ 	\ >\" @C-BC"8#8#8923\\\ A\  %d38nE3,VW"8#8#8923RRR FR" [93d8XY3d8op"8#8#8923	YYY 	Y :Yr-   