U
    ^g%iŸ
  ã                   @   s,   d dl mZ ddlmZ G dd„ deƒZdS )é   )ÚResourceé   )ÚURLc                       s^   e Zd Zd‡ fdd„	Zi dfdd„Zi fdd„Zi dfdd	„Zi fd
d„Zi fdd„Z‡  Z	S )ÚWebhookNc                    s"   t t| ƒ |¡ tjtj | _d S )N)Úsuperr   Ú__init__r   ZV2ZACCOUNTÚbase_url)ÚselfÚclient©Ú	__class__© úY/var/www/html/api-medvista/venv/lib/python3.8/site-packages/razorpay/resources/webhook.pyr      s    zWebhook.__init__c                 K   s<   |dkrd  tjtj¡}nd  | j|tj¡}| j||f|ŽS )zm
        Create webhook from given dict

        Returns:
            Webhook Dict which was created
        Nú{}{}ú{}/{}{})Úformatr   ÚV1ÚWEBHOOKr   Zpost_url©r	   ÚdataÚ
account_idÚkwargsÚurlr   r   r   Úcreate
   s    zWebhook.createc                 K   s<   |rd  | j|tj|¡}nd  tjtj|¡}| j||f|ŽS )a  
        Fetch webhook for given webhook id

        Args:
            account_id : Id for which webhook object has to be retrieved
            webhook_id : Id for which account object has to be retrieved

        Returns:
            webhook dict for given webhook_id
        ú
{}/{}{}/{}ú{}{}/{})r   r   r   r   r   Úget_url©r	   Z
webhook_idr   r   r   r   r   r   r   Úfetch   s    zWebhook.fetchc                 K   s<   |dkrd  tjtj¡}nd  | j|tj¡}| j||f|ŽS )z¼
        Fetch all webhooks

        Args:
            account_id : Id for which webhook object has to be retrieved

        Returns:
            webhook dict for given account_id
        Nr   r   )r   r   r   r   r   r   r   r   r   r   Úall*   s    
zWebhook.allc                 K   sN   |r(d  | j|tj|¡}| j||f|ŽS d  tjtj|¡}| j||f|ŽS dS )zj
        Edit webhook from given dict

        Returns:
            Webhook Dict which was edited
        r   r   N)r   r   r   r   Z	patch_urlr   Zput_urlr   r   r   r   Úedit;   s
    zWebhook.editc                 K   s$   d  | j|tj|¡}| j||f|ŽS )a,  
        delete webhook for given webhook id

        Args:
            account_id : Id for which webhook object has to be retrieved
            webhook_id : Id for which account object has to be retrieved

        Returns:
            The response is always be an empty array like this - []
        r   )r   r   r   r   Z
delete_urlr   r   r   r   ÚdeleteJ   s    zWebhook.delete)N)
Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r    r!   Ú__classcell__r   r   r   r   r      s   r   N)Úbaser   Zconstants.urlr   r   r   r   r   r   Ú<module>   s   