o
    Rh                     @   sN   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Zg i ddfddZdS )    N)platform_config)get_all_platformFc                    s<  d }| D ]}t |}z|d|d }|d}|d}	t|	  }
tj|||
d|dd}|jdkr|	 d	}|d
 |d}|d}|d}|d}t
||d|d d}tt fdd|d }|d}|d|d d|  }dddd| d} | d| | d| ||dd|sdnddddd}tj|||d}|jdkrd| d|sdnd  d!  d"|s| d| nd# d$|s| d| nd# d%|j d}||I d H  W q ty } zd&| d'  d(| d&}||I d H  W Y d }~qd }~ww d S ))NAPI_URLLOGINlogin_accountlogin_password)accountpasswordheaders)urljsonr
      tokenplatforms_dates_timee_datee_timeMAINTAIN)
auth_tokenapi_urlc                    s   | d  kS )Nr    )xmaintain_targetr   (/var/www/html/tg_maintain_bot/api/api.py<lambda>.   s    z#call_maintain_api.<locals>.<lambda>uid/zapplication/jsonTWDzBearer )zContent-TypeCurrencyExchange_codeAuthorization    r   )r   temp_maintenance_start_timetemp_maintenance_end_timemaintenance_start_timemaintenance_end_timestatus_frontstatus_backendis_under_maintenanceis_scheduledis_exclusive_brandenable_buffer_walletz%
                                    z&
                                    
u   維護流程已確認u   維護流程已取消u5   
                                    
維護平台：u;   
                                    
開始維護時間：-u;   
                                    
結束維護時間：u8   
                                    
API回應代碼：z
                        u)   
                        
維護平台：u2   
                        
API呼叫失敗原因：)r   gethashlibmd5encode	hexdigestrequestspoststatus_coder   r   nextfilterputreply	Exception)maintain_platformfmt_datacancel_maintainbot
connectionr   config	login_apir   r	   md5_password	login_resr   r   r   r   r   all_platformplatform_dataplatform_uidmaintain_apir
   dataresponseresponse_msge	error_msgr   r   r   call_maintain_api   s   




	








rO   )	ossysr5   config.platform_configr   utils.get_all_platformr   r1   rO   r   r   r   r   <module>   s    