U
    I9hy                     @   s  d dl Z ed dZdZdZeeg ddZede  ed	 ze jeed
ddZedej  ejdkrej	
ddZed ede  ed ede d nejdkrej	
ddZedej d ede  nZejdkred edejdd  d n*edej  edejdd  d W n e jjk
r   ed ed d!ZzHe jeed
ddZed"ej  ejdkred#ej	
d  W n2 ek
r Z zed$e  W 5 dZ[X Y nX Y n2 ek
r Z zed%e  W 5 dZ[X Y nX ed& ed' d(d)d*dgZeD ]Zze jeed
d+dZejdkr~ed,e d-ej d. nJejd/kred0e d1ej	
d d2ej d. ned0e d3ej  W n   ed0e d4 Y nX q@dS )5    Nz+=== Testing Sync Endpoint 308 Redirect ===
z/https://api-timesheet.firsteconomy.com/api/synczankita gholapz3AWToken_B-Jqoh8k_GHinje1yh8sMa70R80xiLxwpMOtKgD2IaYz2024-01-01T00:00:00.000Z)nametokendataZ	timestampz	Testing: z<------------------------------------------------------------F
   )ZjsonZallow_redirectstimeoutzStatus Code: 4  ZLocationzNot specifiedu$   ❌ 308 PERMANENT REDIRECT detected!z   Redirects to: z*
SOLUTION: Update your sync script to use:z   $SERVER_URL = "")-  .  3  u   ⚠️  z Redirect detected   u*   ✅ Endpoint is working correctly (200 OK)z
Response: d   z...zBody: u(   ❌ SSL Error - trying with HTTP insteadzhttps://zhttp://z
HTTP Status: zHTTP also redirects to: zHTTP also failed: u   ❌ Error: z=
============================================================zTesting alternative endpoints:z0https://api-timesheet.firsteconomy.com/api/sync/z.http://api-timesheet.firsteconomy.com/api/syncz/https://timesheet-api.firsteconomy.com/api/sync   u   ✅ WORKING: z
 (Status: ))r	   r
   r   r   z   u    → z (u    → Status u    → Connection failed)ZrequestsprintZsync_urlZdeveloper_nameZ	api_tokenZtest_payloadZpostZresponseZstatus_codeZheadersgetZredirect_locationtext
exceptionsZSSLErrorreplaceZhttp_url	ExceptioneZalternative_endpointsZendpoint r   r   ./test_sync_endpoint.py<module>   s~   

$ (