o
    Żh  ć                   @   s8   d dl mZ d dlmZ d dlmZ dd Zdd ZdS )	é    )ŚCountryCode)ŚInvalidCountryCode)ŚServiceResponsec                 C   s8   t | ts	tdt|dkr| | j”s| j| }|S )a  Prefix country code to phone number
    Args:
        country_code: the country code to prefix of type CountryCode
        number (str): the mobile number
    Raises:
        InvalidCountryCode when supplied country code is not type of CountryCode
    Returns:
        number (str): mobile number with country code prefixed. if country_code
        is already prefixed, then the same is returned unaltered.
    z.The country code should be of type CountryCodeé
   )Ś
isinstancer   r   ŚlenŚ
startswithŚvalue)Zcountry_codeŚnumber© r   śW/var/www/html/magazine_api/magazine_env/lib/python3.10/site-packages/msg91_otp/utils.pyŚprefix_country_code   s
   

r   c                 K   s`   |   ”  d”dkr|   ”  d”}d}n|   ”  d”dkr%|   ”  d”}d}t||fi |¤}|S )a  Convert requests package response obj to our internal Response
    Args:
        response_obj: the response object returned by requests package
        kwargs : any other optional keyword parameters
    Returns:
        our internal ServiceResponse object
    ŚtypeŚerrorŚmessagei  ŚsuccesséČ   )ŚjsonŚgetr   )Zresponse_objŚkwargsr   Śstatus_codeŚ	_responser   r   r   Śconvert_response   s   r   N)Zmsg91_otp.country_coder   Zmsg91_otp.exceptionsr   Zmsg91_otp.responser   r   r   r   r   r   r   Ś<module>   s
    