-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e40fbf1
commit e0cf503
Showing
7 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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** | ||
<br> | ||
<br> | ||
**For reference click [here](https://razorpay.com/docs/api/documents)** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |