U
    ޣ5h                     @   s`   d dl Z d dlmZmZmZ d dlmZmZmZ de	eee	e	f  eee	ef  dddZ
dS )    N)OptionalDictAny)JIRA_URL	JIRA_USERJIRA_API_TOKEN)	issue_keyjira_configreturnc           	   
   C   s0  | st d dS |r |dtnt}|r4|dtnt}|rH|dtnt}|s\t d dS |dsnd| }|d	}| d
|  }ddi}z(tj|||f|dd}|  |	 W S  tj
jk
r } zt d|  W Y dS d}~X Y n< tj
jk
r* } zt d|  W Y dS d}~X Y nX dS )a  Fetch issue details from Jira.

    Args:
        issue_key (str): The Jira issue key
        jira_config (Optional[Dict[str, str]]): Optional Jira configuration override

    Returns:
        Optional[Dict[str, Any]]: Issue details or None if fetch fails
    u   ❌ Issue key cannot be emptyNurlusertokenu   ❌ Jira URL cannot be empty)zhttp://https://r   /z/rest/api/3/issue/Acceptzapplication/json   )authheaderstimeoutu   ❌ Failed to fetch issue: u   ❌ Error decoding JSON: )printgetr   r   r   
startswithrstriprequestsZraise_for_statusjson
exceptionsZRequestExceptionJSONDecodeError)	r   r	   Zjira_urlZ	jira_userZ
jira_tokenr   r   responsee r   =/var/www/html/testcasegenerator.evdpl.com/jira/jira_client.pyfetch_issue   s:    



r!   )N)r   typingr   r   r   config.settingsr   r   r   strr!   r   r   r   r    <module>   s   