diff --git a/documents/document.md b/documents/document.md
new file mode 100644
index 0000000..47ef8a9
--- /dev/null
+++ b/documents/document.md
@@ -0,0 +1,68 @@
+## Document
+
+### Create a Document
+
+```py
+
+file = open('/Users/your_name/Downloads/sample_uploaded.jpeg', 'rb')
+
+x = client.document.create({
+ 'file': file,
+ 'purpose': 'dispute_evidence'
+})
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|-------|-----------|--------------------------------------------------|
+| file* | string | The URL generated once the business proof document is uploaded. |
+| purpose | string | Possible value is `dispute_evidence` |
+
+**Response:**
+```json
+{
+ "id": "doc_EsyWjHrfzb59Re",
+ "entity": "document",
+ "purpose": "dispute_evidence",
+ "name": "doc_19_12_2020.jpg",
+ "mime_type": "image/png",
+ "size": 2863,
+ "created_at": 1590604200
+}
+```
+-------------------------------------------------------------------------------------------------------
+
+### Fetch Document Information
+
+```py
+documentId = "doc_NiyXWXXXXXXXXX"
+
+client.document.fetch(documentId)
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|-------|-----------|--------------------------------------------------|
+| documentId | string | The unique identifier of the document. |
+
+**Response:**
+```json
+{
+ "entity": "document",
+ "id": "doc_00000000000000",
+ "purpose": "dispute_evidence",
+ "created_at": 1701701378,
+ "mime_type": "application/pdf",
+ "display_name": "ppm_00000000000000",
+ "size": 404678,
+ "url": ""
+}
+```
+-------------------------------------------------------------------------------------------------------
+
+**PN: * indicates mandatory fields**
+
+
+**For reference click [here](https://razorpay.com/docs/api/documents)**
\ No newline at end of file
diff --git a/razorpay/__init__.py b/razorpay/__init__.py
index 7f601b9..95da8cb 100644
--- a/razorpay/__init__.py
+++ b/razorpay/__init__.py
@@ -25,6 +25,7 @@
from .resources import Product
from .resources import Iin
from .resources import Webhook
+from .resources import Document
from .resources import Dispute
__all__ = [
@@ -55,5 +56,6 @@
'Product',
'Iin',
'Webhook',
+ 'Document',
'Dispute',
]
diff --git a/razorpay/constants/url.py b/razorpay/constants/url.py
index 6e3811e..9f3fcfc 100644
--- a/razorpay/constants/url.py
+++ b/razorpay/constants/url.py
@@ -26,4 +26,6 @@ class URL(object):
TOKEN = "/tokens"
IIN = "/iins"
WEBHOOK = "/webhooks"
+ DOCUMENT= "/documents"
DISPUTE= "/disputes"
+
diff --git a/razorpay/resources/__init__.py b/razorpay/resources/__init__.py
index 2733829..f1ec4e6 100644
--- a/razorpay/resources/__init__.py
+++ b/razorpay/resources/__init__.py
@@ -21,6 +21,7 @@
from .product import Product
from .iin import Iin
from .webhook import Webhook
+from .document import Document
from .dispute import Dispute
__all__ = [
@@ -47,5 +48,6 @@
'Product',
'Iin',
'Webhook',
+ 'Document',
'Dispute',
]
diff --git a/razorpay/resources/document.py b/razorpay/resources/document.py
new file mode 100644
index 0000000..0f095a1
--- /dev/null
+++ b/razorpay/resources/document.py
@@ -0,0 +1,27 @@
+from .base import Resource
+from ..constants.url import URL
+
+
+class Document(Resource):
+ def __init__(self, client=None):
+ super(Document, self).__init__(client)
+ self.base_url = URL.V1 + URL.DOCUMENT
+
+ def create(self, data={}, **kwargs):
+ """
+ Create a Document
+
+ Returns:
+ Dictionary of document
+ """
+ url = self.base_url
+ return self.file_url(url, data, **kwargs)
+
+ def fetch(self, dispute_id, data={}, **kwargs):
+ """
+ Fetch Document
+
+ Returns:
+ Dictionary of document
+ """
+ return super(Document, self).fetch(dispute_id, data, **kwargs)
diff --git a/tests/mocks/document.json b/tests/mocks/document.json
new file mode 100644
index 0000000..4c9c696
--- /dev/null
+++ b/tests/mocks/document.json
@@ -0,0 +1,9 @@
+{
+ "id": "doc_EsyWjHrfzb59Re",
+ "entity": "document",
+ "purpose": "dispute_evidence",
+ "name": "doc_19_12_2020.jpg",
+ "mime_type": "image/png",
+ "size": 2863,
+ "created_at": 1590604200
+}
diff --git a/tests/test_client_document.py b/tests/test_client_document.py
new file mode 100644
index 0000000..4ef6fd8
--- /dev/null
+++ b/tests/test_client_document.py
@@ -0,0 +1,32 @@
+import responses
+import json
+
+from .helpers import mock_file, ClientTestCase
+
+
+class TestClientDocument(ClientTestCase):
+
+ def setUp(self):
+ super(TestClientDocument, self).setUp()
+ self.base_url = f"{self.base_url}/documents"
+
+ @responses.activate
+ def test_document_fetch(self):
+ result = mock_file('document')
+ id = 'fake_document_id'
+ url = f"{self.base_url}/{id}"
+ responses.add(responses.GET, url, status=200, body=json.dumps(result),
+ match_querystring=True)
+ self.assertEqual(self.client.document.fetch(id), result)
+
+ @responses.activate
+ def test_document_create(self):
+ request = {
+ 'file': '',
+ 'purpose': 'dispute_evidence'
+ }
+ result = mock_file('document')
+ url = self.base_url
+ responses.add(responses.POST, url, status=200, body=json.dumps(result),
+ match_querystring=True)
+ self.assertEqual(self.client.document.create(request), result)