o
    tBhv                     @   s   d dl Z d dlZd dlmZmZ d dlmZ d dlmZm	Z	 d dl
mZ e eZG dd dZG dd	 d	ZG d
d deZG dd deZdS )    N)AsyncServiceProxyServiceProxy)Settings)AsyncTransport	Transport)Documentc                   @   s$   e Zd Zdd Zdd Zdd ZdS )Factoryc                 C   s4   t |d| | _||jv r|| _d S ||| _d S )Nzget_%s)getattr_method
namespaces_nsget_ns_prefix)selftypeskind	namespace r   b/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/zeep/client.py__init__   s   

zFactory.__init__c                 C   s   | | S )Return the complexType or simpleType for the given localname.

        :rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType

        r   r   keyr   r   r   __getattr__   s   zFactory.__getattr__c                 C   s   |  d| j|f S )r   z{%s}%s)r
   r   r   r   r   r   __getitem__   s   zFactory.__getitem__N)__name__
__module____qualname__r   r   r   r   r   r   r   r      s    r   c                   @   s   e Zd ZdZeZ						d!ddZedd Zedd Z			d"d	e
je d
e
je fddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zde
je defdd ZdS )#Clienta  The zeep Client.

    :param wsdl:
    :param wsse:
    :param transport: Custom transport class.
    :param service_name: The service name for the service binding. Defaults to
                         the first service in the WSDL document.
    :param port_name: The port name for the default binding. Defaults to the
                      first port defined in the service element in the WSDL
                      document.
    :param plugins: a list of Plugin instances
    :param settings: a zeep.Settings() object

    Nc                 C   sv   |st d|p
t | _|d ur|n|  | _t|| j| jd| _|| _|d ur*|ng | _d | _	|| _
|| _d | _d S )NzNo URL given for the wsdl)settings)
ValueErrorr   r   _default_transport	transportr   wsdlwsseplugins_default_service_default_service_name_default_port_name_default_soapheaders)r   r"   r#   r!   service_name	port_namer$   r   r   r   r   r   8   s   

zClient.__init__c                 C   s
   | j jjS N)r"   r   
prefix_mapr   r   r   r   r   R   s   
zClient.namespacesc                 C   s4   | j r| j S | j| j| jd| _ | j std| j S )zIThe default ServiceProxy instance

        :rtype: ServiceProxy

        )r)   r*   zhThere is no default service defined. This is usually due to missing wsdl:service definitions in the WSDL)r%   bindr&   r'   r   r-   r   r   r   serviceV   s   zClient.servicer)   r*   c                 C   8   | j jsdS | |}| ||}t| |jfi |jS a  Create a new ServiceProxy for the given service_name and port_name.

        The default ServiceProxy instance (`self.service`) always referes to
        the first service/port in the wsdl Document.  Use this when a specific
        port is required.

        N)r"   services_get_service	_get_portr   bindingbinding_optionsr   r)   r*   r/   portr   r   r   r.   j   
   
zClient.bindc              	   C   sH   z| j j| }W n ty   tdd| j j  w t| ||dS )zCreate a new ServiceProxy for the given binding name and address.

        :param binding_name: The QName of the binding
        :param address: The address of the endpoint

        zANo binding found with the given QName. Available bindings are: %sz, )address)r"   bindingsKeyErrorr   joinkeysr   )r   binding_namer:   r5   r   r   r   create_service}   s   zClient.create_servicec                 O   s   |j j|||| d\}}|S )zZCreate the payload for the given operation.

        :rtype: lxml.etree._Element

        )client)_binding_create)r   r/   operation_nameargskwargsenvelopehttp_headersr   r   r   create_message   s   
zClient.create_messagec                 C   s   t | jjd|S )zReturn a type factory for the given namespace.

        Example::

            factory = client.type_factory('ns0')
            user = factory.User(name='John')

        :rtype: Factory

        type)r   r"   r   )r   r   r   r   r   type_factory   s   zClient.type_factoryc                 C      | j j|S )zwReturn the type for the given qualified name.

        :rtype: zeep.xsd.ComplexType or zeep.xsd.AnySimpleType

        )r"   r   get_typer   namer   r   r   rM         zClient.get_typec                 C   rL   )z\Return the element for the given qualified name.

        :rtype: zeep.xsd.Element

        )r"   r   get_elementrN   r   r   r   rQ      rP   zClient.get_elementc                 C   s   | j j|| dS )z'Set a shortcut for the given namespace.N)r"   r   set_ns_prefix)r   prefixr   r   r   r   rR      s   zClient.set_ns_prefixc                 C   s
   || _ dS )a  Set the default soap headers which will be automatically used on
        all calls.

        Note that if you pass custom soapheaders using a list then you will
        also need to use that during the operations. Since mixing these use
        cases isn't supported (yet).

        N)r(   )r   headersr   r   r   set_default_soapheaders   s   
	zClient.set_default_soapheadersc                 C   s6   |r|j |}|std|S t|j  d }|S )NzPort not foundr   )portsgetr   listvalues)r   r/   rO   r8   r   r   r   r4      s   zClient._get_portrO   returnc                 C   s<   |r| j j|}|std|S tt| j j d }|S )NzService not found)r"   r2   rW   r   nextiterrY   )r   rO   r/   r   r   r   r3      s   zClient._get_service)NNNNNNNN)r   r   r   __doc__r   r    r   propertyr   r/   typingOptionalstrr.   r@   rI   rK   rM   rQ   rR   rU   r4   r3   r   r   r   r   r   &   s<    



	r   c                   @   sH   e Zd ZeZ		ddeje deje fddZdd Z	ddd	d
Z
dS )AsyncClientNr)   r*   c                 C   r0   r1   )r"   r2   r3   r4   r   r5   r6   r7   r   r   r   r.      r9   zAsyncClient.bindc                    s   | S r+   r   r-   r   r   r   
__aenter__   s   zAsyncClient.__aenter__rZ   c                    s   | j  I d H  d S r+   )r!   aclose)r   exc_type	exc_value	tracebackr   r   r   	__aexit__   s   zAsyncClient.__aexit__r]   )NNN)rZ   N)r   r   r   r   r    r`   ra   rb   r.   rd   ri   r   r   r   r   rc      s    
rc   c                       s    e Zd ZdZ fddZ  ZS )CachingClientzShortcut to create a caching client, for the lazy people.

    This enables the SqliteCache by default in the transport as was the default
    in earlier versions of zeep.

    c                    s<   ddl m} |dpt| d|d< t j|i | d S )Nr   )SqliteCacher!   )cache)
zeep.cacherk   rW   r   superr   )r   rE   rF   rk   	__class__r   r   r      s   zCachingClient.__init__)r   r   r   r^   r   __classcell__r   r   ro   r   rj      s    rj   )loggingr`   
zeep.proxyr   r   zeep.settingsr   zeep.transportsr   r   	zeep.wsdlr   	getLoggerr   loggerr   r   rc   rj   r   r   r   r   <module>   s    
 2