U
    ʼb                     @   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r4|| js4| 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   3/tmp/pip-unpacked-wheel-c1x4am86/msg91_otp/utils.pyprefix_country_code   s
    

r   c                 K   s\   |   ddkr&|   d}d}n$|   ddkrJ|   d}d}t||f|}|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   