dubidoc 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dubidoc-0.1.0/LICENSE +21 -0
- dubidoc-0.1.0/PKG-INFO +72 -0
- dubidoc-0.1.0/README.md +43 -0
- dubidoc-0.1.0/dubidoc/__init__.py +7 -0
- dubidoc-0.1.0/dubidoc/_modules/__init__.py +7 -0
- dubidoc-0.1.0/dubidoc/_modules/access_token.py +31 -0
- dubidoc-0.1.0/dubidoc/_modules/authentication.py +41 -0
- dubidoc-0.1.0/dubidoc/_modules/device.py +24 -0
- dubidoc-0.1.0/dubidoc/_modules/document.py +51 -0
- dubidoc-0.1.0/dubidoc/_modules/document_link.py +16 -0
- dubidoc-0.1.0/dubidoc/_modules/download.py +21 -0
- dubidoc-0.1.0/dubidoc/_modules/organization.py +1 -0
- dubidoc-0.1.0/dubidoc/_modules/organization_user.py +1 -0
- dubidoc-0.1.0/dubidoc/_modules/participant.py +20 -0
- dubidoc-0.1.0/dubidoc/_modules/storecode.py +1 -0
- dubidoc-0.1.0/dubidoc/client.py +75 -0
- dubidoc-0.1.0/dubidoc/enum.py +8 -0
- dubidoc-0.1.0/dubidoc.egg-info/PKG-INFO +72 -0
- dubidoc-0.1.0/dubidoc.egg-info/SOURCES.txt +22 -0
- dubidoc-0.1.0/dubidoc.egg-info/dependency_links.txt +1 -0
- dubidoc-0.1.0/dubidoc.egg-info/requires.txt +1 -0
- dubidoc-0.1.0/dubidoc.egg-info/top_level.txt +1 -0
- dubidoc-0.1.0/pyproject.toml +72 -0
- dubidoc-0.1.0/setup.cfg +4 -0
dubidoc-0.1.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Dmytro Litvinov
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
dubidoc-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: dubidoc
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Python SDK for dubidoc.com.ua API
|
5
|
+
Maintainer-email: Dmytro Litvinov <me@dmytrolitvinov.com>
|
6
|
+
License: MIT License
|
7
|
+
Project-URL: Homepage, https://github.com/DmytroLitvinov/python-dubidoc
|
8
|
+
Project-URL: Issues, https://github.com/DmytroLitvinov/python-dubidoc/issues
|
9
|
+
Project-URL: Changelog, https://github.com/DmytroLitvinov/python-dubidoc/CHANGELOG.md
|
10
|
+
Keywords: dubidoc,Ukraine,πΊπ¦,api,dubidoc.com.ua
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
12
|
+
Classifier: Environment :: Web Environment
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
15
|
+
Classifier: Natural Language :: English
|
16
|
+
Classifier: Operating System :: OS Independent
|
17
|
+
Classifier: Programming Language :: Python
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
25
|
+
Requires-Python: >=3.8
|
26
|
+
Description-Content-Type: text/markdown
|
27
|
+
License-File: LICENSE
|
28
|
+
Requires-Dist: requests
|
29
|
+
|
30
|
+
# Dubidoc API client β
|
31
|
+
|
32
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
33
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
34
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
35
|
+
|
36
|
+
---
|
37
|
+
**Documentation**: [https://my.dubidoc.com.ua/api/api/v1/docs](https://my.dubidoc.com.ua/api/api/v1/docs)
|
38
|
+
|
39
|
+
**Source Code**: [https://github.com/DmytroLitvinov/python-dubidoc](https://github.com/DmytroLitvinov/python-dubidoc)
|
40
|
+
|
41
|
+
**PyPI**: [https://pypi.org/project/dubidoc/](https://pypi.org/project/dubidoc/)
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
Python API wrapper around Dubidoc API. Feel free to contribute and make it better! π
|
46
|
+
|
47
|
+
## Installation
|
48
|
+
|
49
|
+
```sh
|
50
|
+
pip install dubidoc
|
51
|
+
```
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
1) Request your token at [Dubidoc team](https://t.me/dmytro_dubilet/814)
|
56
|
+
|
57
|
+
2) Use that token to initialize client:
|
58
|
+
|
59
|
+
```python
|
60
|
+
from dubidoc import DubidocAPIClient
|
61
|
+
|
62
|
+
api_token = 'xxxxxxxxxxxxxxx'
|
63
|
+
|
64
|
+
dubidoc = DubidocAPIClient(api_token)
|
65
|
+
|
66
|
+
documents = dubidoc.document_api.list()
|
67
|
+
print(documents)
|
68
|
+
```
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
This project is licensed under the terms of the [MIT license](https://github.com/DmytroLitvinov/python-dubidoc/blob/master/LICENSE).
|
dubidoc-0.1.0/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Dubidoc API client β
|
2
|
+
|
3
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
4
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
5
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
6
|
+
|
7
|
+
---
|
8
|
+
**Documentation**: [https://my.dubidoc.com.ua/api/api/v1/docs](https://my.dubidoc.com.ua/api/api/v1/docs)
|
9
|
+
|
10
|
+
**Source Code**: [https://github.com/DmytroLitvinov/python-dubidoc](https://github.com/DmytroLitvinov/python-dubidoc)
|
11
|
+
|
12
|
+
**PyPI**: [https://pypi.org/project/dubidoc/](https://pypi.org/project/dubidoc/)
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
Python API wrapper around Dubidoc API. Feel free to contribute and make it better! π
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
```sh
|
21
|
+
pip install dubidoc
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
1) Request your token at [Dubidoc team](https://t.me/dmytro_dubilet/814)
|
27
|
+
|
28
|
+
2) Use that token to initialize client:
|
29
|
+
|
30
|
+
```python
|
31
|
+
from dubidoc import DubidocAPIClient
|
32
|
+
|
33
|
+
api_token = 'xxxxxxxxxxxxxxx'
|
34
|
+
|
35
|
+
dubidoc = DubidocAPIClient(api_token)
|
36
|
+
|
37
|
+
documents = dubidoc.document_api.list()
|
38
|
+
print(documents)
|
39
|
+
```
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
This project is licensed under the terms of the [MIT license](https://github.com/DmytroLitvinov/python-dubidoc/blob/master/LICENSE).
|
@@ -0,0 +1,7 @@
|
|
1
|
+
from .access_token import AccessTokenAPI
|
2
|
+
from .authentication import AuthenticationAPI
|
3
|
+
from .device import DeviceAPI
|
4
|
+
from .document import DocumentAPI
|
5
|
+
from .document_link import DocumentLinkAPI
|
6
|
+
from .download import DownloadAPI
|
7
|
+
from .participant import ParticipantAPI
|
@@ -0,0 +1,31 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class AccessTokenAPI:
|
5
|
+
PATH = 'access-tokens'
|
6
|
+
|
7
|
+
def __init__(self, client):
|
8
|
+
self.client = client
|
9
|
+
|
10
|
+
def get_tokens(self):
|
11
|
+
"""
|
12
|
+
ΠΡΡΠΈΠΌΠ°ΡΠΈ ΡΠΏΠΈΡΠΎΠΊ Π²ΡΡΡ
Π·Π³Π΅Π½Π΅ΡΠΎΠ²Π°Π½ΠΈΡ
ΠΠ°ΠΌΠΈ API-ΠΊΠ»ΡΡΡΠ² (ΡΠΎΠΊΠ΅Π½ΡΠ²)
|
13
|
+
"""
|
14
|
+
path = self.PATH
|
15
|
+
return self.client.make_request(HttpMethod.GET, path)
|
16
|
+
|
17
|
+
def generate_token(self, title):
|
18
|
+
"""
|
19
|
+
ΠΠ΅Π½Π΅ΡΡΠ²Π°Π½Π½Ρ ΡΡΠ°ΡΠΈΡΠ½ΠΎΠ³ΠΎ API-ΠΊΠ»ΡΡΠ° (ΡΠΎΠΊΠ΅Π½Ρ) Π΄Π»Ρ Π΄ΠΎΡΡΡΠΏΡ Π΄ΠΎ API
|
20
|
+
:param title:
|
21
|
+
"""
|
22
|
+
path = self.PATH
|
23
|
+
return self.client.make_request(HttpMethod.POST, path, body={"title": title})
|
24
|
+
|
25
|
+
def revoke_token(self, token_id):
|
26
|
+
"""
|
27
|
+
ΠΡΠΎΠ±ΠΈΡΠΈ ΠΎΠ±ΡΠ°Π½ΠΈΠΉ API-ΠΊΠ»ΡΡ (ΡΠΎΠΊΠ΅Π½) Π½Π΅Π΄ΡΠΉΡΠ½ΠΈΠΌ
|
28
|
+
:param token_id:
|
29
|
+
"""
|
30
|
+
path = f'{self.PATH}/{token_id}'
|
31
|
+
return self.client.make_request(HttpMethod.DELETE, path)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class AuthenticationAPI:
|
5
|
+
|
6
|
+
def __init__(self, client):
|
7
|
+
self.client = client
|
8
|
+
|
9
|
+
def get_code(self, login):
|
10
|
+
"""
|
11
|
+
Title: ΠΡΡΠΈΠΌΠ°ΡΠΈ ΠΊΠΎΠ΄ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΡ
|
12
|
+
Description: ΠΠ΅ΡΠΎΠ΄ Π²ΡΠ΄ΠΏΡΠ°Π²ΠΊΠΈ ΡΠΈΠΌΡΠ°ΡΠΎΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Ρ Π΄Π»Ρ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΡ ΡΠ΅ΡΠ΅Π· email
|
13
|
+
"""
|
14
|
+
path = self.PATH
|
15
|
+
body = {"login": login}
|
16
|
+
return self.client.make_request(HttpMethod.POST, path, body)
|
17
|
+
|
18
|
+
def get_token(self, login, code):
|
19
|
+
"""
|
20
|
+
Title: ΠΡΡΠΈΠΌΠ°ΡΠΈ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΠΉΠ½ΠΈΠΉ ΡΠΎΠΊΠ΅Π½
|
21
|
+
Description: ΠΠ΅ΡΠΎΠ΄ Π΄Π»Ρ ΠΎΡΡΠΈΠΌΠ°Π½Π½Ρ ΡΠΎΠΊΠ΅Π½Ρ ΠΊΠΎΡΠΈΡΡΡΠ²Π°ΡΠ° Π½Π° ΠΎΡΠ½ΠΎΠ²Ρ email ΡΠ° ΡΠΈΠΌΡΠ°ΡΠΎΠ²ΠΎΠ³ΠΎ ΠΊΠΎΠ΄Ρ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΡ
|
22
|
+
"""
|
23
|
+
path = 'auth/get-token'
|
24
|
+
body = {
|
25
|
+
"login": login,
|
26
|
+
"code": code
|
27
|
+
}
|
28
|
+
return self.client.make_request(HttpMethod.POST, path, body)
|
29
|
+
|
30
|
+
def refresh(self, refresh_token):
|
31
|
+
"""
|
32
|
+
Title: ΠΠ½ΠΎΠ²ΠΈΡΠΈ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΠΉΠ½ΠΈΠΉ ΡΠΎΠΊΠ΅Π½
|
33
|
+
Description: ΠΡΠΎΠ΄ΠΎΠ²ΠΆΠΈΡΠΈ Π΄ΡΡ Π°Π²ΡΠΎΡΠΈΠ·Π°ΡΡΠΉΠ½ΠΎΠ³ΠΎ ΡΠΎΠΊΠ΅Π½Ρ ΠΊΠΎΡΠΈΡΡΡΠ²Π°ΡΠ° Π½Π° ΠΎΡΠ½ΠΎΠ²Ρ refresh ΡΠΎΠΊΠ΅Π½Ρ
|
34
|
+
:param token_id:
|
35
|
+
:return:
|
36
|
+
"""
|
37
|
+
path = f'token/refresh'
|
38
|
+
body = {
|
39
|
+
"refresh_token": refresh_token
|
40
|
+
}
|
41
|
+
return self.client.delete(HttpMethod.POST, path, body)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class DeviceAPI:
|
5
|
+
|
6
|
+
def __init__(self, client):
|
7
|
+
self.client = client
|
8
|
+
|
9
|
+
def register(self, token):
|
10
|
+
"""
|
11
|
+
Title: ΠΠ°ΡΠ΅ΡΡΡΡΡΠ²Π°ΡΠΈ ΠΏΡΠΈΡΡΡΡΠΉ Π΄Π»Ρ Π²ΡΠ΄ΠΏΡΠ°Π²ΠΊΠΈ ΡΠΏΠΎΠ²ΡΡΠ΅Π½Ρ
|
12
|
+
Description: ΠΠ°ΡΠ΅ΡΡΡΡΡΠ²Π°ΡΠΈ device token ΡΠΊΠΈΠΉ ΠΎΡΡΠΈΠΌΠ°Π½ΠΈΠΉ ΡΠ΅ΡΠ΅Π· Firebase Cloud Messaging Π΄Π»Ρ Π²ΡΠ΄ΠΏΡΠ°Π²ΠΊΠΈ Π½ΠΎΡΠΈΡΡΠΊΠ°ΡΡΠΉ ΠΊΠΎΡΠΈΡΡΡΠ²Π°ΡΡ
|
13
|
+
"""
|
14
|
+
path = 'devices'
|
15
|
+
body = {"token": token}
|
16
|
+
return self.client.make_request(HttpMethod.POST, path, body)
|
17
|
+
|
18
|
+
def unregister(self, token):
|
19
|
+
"""
|
20
|
+
Title: ΠΡΠ΄ΠΏΠΈΡΠ°ΡΠΈ ΠΏΡΠΈΡΡΡΡΠΉ Π²ΡΠ΄ ΠΎΡΡΠΈΠΌΠ°Π½Π½Ρ ΡΠΏΠΎΠ²ΡΡΠ΅Π½Ρ
|
21
|
+
Description: Π‘ΠΊΠ°ΡΡΠ²Π°ΡΠΈ Π²ΡΠ΄ΠΏΡΠ°Π²ΠΊΡ ΡΠΏΠΎΠ²ΡΡΠ΅Π½Ρ Π΄Π»Ρ device token
|
22
|
+
"""
|
23
|
+
path = f'devices/{token}'
|
24
|
+
return self.client.make_request(HttpMethod.DELETE, path)
|
@@ -0,0 +1,51 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class DocumentAPI:
|
5
|
+
PATH = 'documents'
|
6
|
+
|
7
|
+
def __init__(self, client):
|
8
|
+
self.client = client
|
9
|
+
|
10
|
+
def list(self):
|
11
|
+
return self.client.make_request(HttpMethod.GET, self.PATH)
|
12
|
+
|
13
|
+
def create(self, body, organization_id=None):
|
14
|
+
return self.client.make_request(HttpMethod.POST, self.PATH, body)
|
15
|
+
|
16
|
+
def get(self, document_id):
|
17
|
+
path = f'{self.PATH}/{document_id}'
|
18
|
+
return self.client.make_request(HttpMethod.GET, path)
|
19
|
+
|
20
|
+
def edit(self, document_id, title):
|
21
|
+
path = f'{self.PATH}/{document_id}'
|
22
|
+
body = {
|
23
|
+
"title": title,
|
24
|
+
}
|
25
|
+
return self.client.make_request(HttpMethod.PUT, path, body)
|
26
|
+
|
27
|
+
def delete(self, document_id):
|
28
|
+
"""
|
29
|
+
Title: ΠΠΈΠ΄Π°Π»Π΅Π½Π½Ρ Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°
|
30
|
+
Description: Π£Π²Π°Π³Π°, Π²ΠΈΠ΄Π°Π»ΠΈΡΠΈ Π΄ΠΎΠΊΡΠΌΠ΅Π½Ρ ΠΌΠΎΠΆΠ»ΠΈΠ²ΠΎ Π»ΠΈΡΠ΅ Π·Π° ΡΠΌΠΎΠ²ΠΈ, ΡΠΎ Π²ΡΠ½ Π½Π΅ Π±ΡΠ² ΠΏΡΠ΄ΠΏΠΈΡΠ°Π½ΠΈΠΉ Π°Π±ΠΎ Π½Π°Π΄ΡΡΠ»Π°Π½ΠΈΠΉ ΠΎΡΡΠΈΠΌΡΠ²Π°ΡΡ
|
31
|
+
"""
|
32
|
+
path = f'{self.PATH}/{document_id}'
|
33
|
+
return self.client.make_request(HttpMethod.DELETE, path)
|
34
|
+
|
35
|
+
def download(self):
|
36
|
+
raise NotImplementedError
|
37
|
+
|
38
|
+
def unarchive(self):
|
39
|
+
raise NotImplementedError
|
40
|
+
|
41
|
+
def participants(self):
|
42
|
+
raise NotImplementedError
|
43
|
+
|
44
|
+
def sign(self):
|
45
|
+
raise NotImplementedError
|
46
|
+
|
47
|
+
def signatures(self):
|
48
|
+
raise NotImplementedError
|
49
|
+
|
50
|
+
def archive(self):
|
51
|
+
raise NotImplementedError
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class DocumentLinkAPI:
|
5
|
+
PATH = 'documents/{}/links'
|
6
|
+
|
7
|
+
def __init__(self, client):
|
8
|
+
self.client = client
|
9
|
+
|
10
|
+
def generate_public_link(self, document_id):
|
11
|
+
path = self.PATH.format(document_id)
|
12
|
+
return self.client.make_request(HttpMethod.POST, path)
|
13
|
+
|
14
|
+
def revoke_public_link(self, document_id):
|
15
|
+
path = self.PATH.format(document_id)
|
16
|
+
return self.client.make_request(HttpMethod.DELETE, path)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class DownloadAPI:
|
5
|
+
PATH = 'downloads'
|
6
|
+
|
7
|
+
def __init__(self, client):
|
8
|
+
self.client = client
|
9
|
+
|
10
|
+
def bulk_uploads(self, body):
|
11
|
+
path = self.PATH
|
12
|
+
return self.client.make_request(HttpMethod.POST, path, body)
|
13
|
+
|
14
|
+
def download(self, download_id):
|
15
|
+
path = f'{self.PATH}/{download_id}/download'
|
16
|
+
return self.client.make_request(HttpMethod.GET, path)
|
17
|
+
|
18
|
+
def check_status(self, download_id):
|
19
|
+
path = f'{self.PATH}/{download_id}/status'
|
20
|
+
return self.client.make_request(HttpMethod.GET, path)
|
21
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# TODO
|
@@ -0,0 +1 @@
|
|
1
|
+
# TODO
|
@@ -0,0 +1,20 @@
|
|
1
|
+
from dubidoc.enum import HttpMethod
|
2
|
+
|
3
|
+
|
4
|
+
class ParticipantAPI:
|
5
|
+
|
6
|
+
def __init__(self, client):
|
7
|
+
self.client = client
|
8
|
+
|
9
|
+
def add_participant(self, document_id, body):
|
10
|
+
path = 'documents/{}/participants'.format(document_id)
|
11
|
+
return self.client.make_request(HttpMethod.POST, path, body)
|
12
|
+
|
13
|
+
def remove_participant(self, participant_id):
|
14
|
+
"""
|
15
|
+
It sounds like it should be DELETE 'documents/{}/participants/{}', but
|
16
|
+
each participant has own unique id, so it should be 'participants/{}'.
|
17
|
+
You can retrieve participant_id from the response of 'add_participant' method.
|
18
|
+
"""
|
19
|
+
path = 'participants/{}'.format(participant_id)
|
20
|
+
return self.client.make_request(HttpMethod.DELETE, path, )
|
@@ -0,0 +1 @@
|
|
1
|
+
# TODO
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import logging
|
2
|
+
from urllib.parse import urljoin
|
3
|
+
|
4
|
+
import requests
|
5
|
+
|
6
|
+
from dubidoc import __version__
|
7
|
+
from dubidoc._modules import AccessTokenAPI, AuthenticationAPI, DeviceAPI, DocumentAPI, DocumentLinkAPI, ParticipantAPI, \
|
8
|
+
DownloadAPI
|
9
|
+
from dubidoc.enum import HttpMethod
|
10
|
+
|
11
|
+
|
12
|
+
logger = logging.getLogger('dubidoc')
|
13
|
+
|
14
|
+
|
15
|
+
class DubidocAPIClient:
|
16
|
+
"""
|
17
|
+
- https://my.dubidoc.com.ua/auth - production URL
|
18
|
+
- https://docs-stage.navkolo.one/auth - staging URL
|
19
|
+
"""
|
20
|
+
|
21
|
+
API_VERSION = "v1"
|
22
|
+
DEFAULT_HEADERS = {
|
23
|
+
"accept": "application/json",
|
24
|
+
"content-type": "application/json",
|
25
|
+
"user-agent": f"python-dubidoc/{__version__} | (https://github.com/DmytroLitvinov/python-dubidoc)",
|
26
|
+
}
|
27
|
+
|
28
|
+
def __init__(self, api_token: str, environment: str = "stage"):
|
29
|
+
self.api_token = api_token
|
30
|
+
if environment == "stage":
|
31
|
+
self.base_url = "https://docs-stage.navkolo.one"
|
32
|
+
else:
|
33
|
+
self.base_url = "https://my.dubidoc.com.ua"
|
34
|
+
# FIXME: The prefix should be "api/v1" instead of "api/api/v1"
|
35
|
+
# Dubidoc will notify when it will be fixed
|
36
|
+
self.prefix = f"api/api/{self.API_VERSION}/"
|
37
|
+
self.endpoint = urljoin(self.base_url, self.prefix)
|
38
|
+
|
39
|
+
# Modules
|
40
|
+
self.document_api = DocumentAPI(self)
|
41
|
+
self.document_link_api = DocumentLinkAPI(self)
|
42
|
+
self.participant_api = ParticipantAPI(self)
|
43
|
+
self.download_api = DownloadAPI(self)
|
44
|
+
|
45
|
+
if environment == "stage":
|
46
|
+
self.access_token_api = AccessTokenAPI(self)
|
47
|
+
self.authentication_api = AuthenticationAPI(self)
|
48
|
+
self.device_api = DeviceAPI(self)
|
49
|
+
# Not yet implemented anot probably not needed
|
50
|
+
# self.organization_user_api = OrganizationUserAPI(self)
|
51
|
+
# self.organization_api = OrganizationAPI(self)
|
52
|
+
# self.shortcode_api = ShortcodeAPI(self)
|
53
|
+
|
54
|
+
def _get_headers(self):
|
55
|
+
headers = self.DEFAULT_HEADERS.copy()
|
56
|
+
headers.update({"X-Access-Token": f"{self.api_token}"})
|
57
|
+
return headers
|
58
|
+
|
59
|
+
def make_request(self, method: HttpMethod, path: str, body: dict = {}):
|
60
|
+
"""
|
61
|
+
Fetches the given path in the Dubidoc API.
|
62
|
+
:param method: HTTP method
|
63
|
+
:param path: Api path
|
64
|
+
:param body: body of request
|
65
|
+
:return: Serialized server response or error
|
66
|
+
"""
|
67
|
+
url = urljoin(self.endpoint, path)
|
68
|
+
headers = self._get_headers()
|
69
|
+
|
70
|
+
logger.debug(f"Making {method.value} request to {url} with headers {headers} and body {body}")
|
71
|
+
# https://github.com/psf/requests/issues/3070
|
72
|
+
response = requests.request(method.value, url, headers=headers, json=body, timeout=10)
|
73
|
+
logger.debug(f"Received response with status code {response.status_code} and body {response.text}")
|
74
|
+
|
75
|
+
return response.json()
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: dubidoc
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: Python SDK for dubidoc.com.ua API
|
5
|
+
Maintainer-email: Dmytro Litvinov <me@dmytrolitvinov.com>
|
6
|
+
License: MIT License
|
7
|
+
Project-URL: Homepage, https://github.com/DmytroLitvinov/python-dubidoc
|
8
|
+
Project-URL: Issues, https://github.com/DmytroLitvinov/python-dubidoc/issues
|
9
|
+
Project-URL: Changelog, https://github.com/DmytroLitvinov/python-dubidoc/CHANGELOG.md
|
10
|
+
Keywords: dubidoc,Ukraine,πΊπ¦,api,dubidoc.com.ua
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
12
|
+
Classifier: Environment :: Web Environment
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
15
|
+
Classifier: Natural Language :: English
|
16
|
+
Classifier: Operating System :: OS Independent
|
17
|
+
Classifier: Programming Language :: Python
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
19
|
+
Classifier: Programming Language :: Python :: 3.8
|
20
|
+
Classifier: Programming Language :: Python :: 3.9
|
21
|
+
Classifier: Programming Language :: Python :: 3.10
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
23
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
25
|
+
Requires-Python: >=3.8
|
26
|
+
Description-Content-Type: text/markdown
|
27
|
+
License-File: LICENSE
|
28
|
+
Requires-Dist: requests
|
29
|
+
|
30
|
+
# Dubidoc API client β
|
31
|
+
|
32
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
33
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
34
|
+
[](https://pypi.python.org/pypi/dubidoc/)
|
35
|
+
|
36
|
+
---
|
37
|
+
**Documentation**: [https://my.dubidoc.com.ua/api/api/v1/docs](https://my.dubidoc.com.ua/api/api/v1/docs)
|
38
|
+
|
39
|
+
**Source Code**: [https://github.com/DmytroLitvinov/python-dubidoc](https://github.com/DmytroLitvinov/python-dubidoc)
|
40
|
+
|
41
|
+
**PyPI**: [https://pypi.org/project/dubidoc/](https://pypi.org/project/dubidoc/)
|
42
|
+
|
43
|
+
---
|
44
|
+
|
45
|
+
Python API wrapper around Dubidoc API. Feel free to contribute and make it better! π
|
46
|
+
|
47
|
+
## Installation
|
48
|
+
|
49
|
+
```sh
|
50
|
+
pip install dubidoc
|
51
|
+
```
|
52
|
+
|
53
|
+
## Usage
|
54
|
+
|
55
|
+
1) Request your token at [Dubidoc team](https://t.me/dmytro_dubilet/814)
|
56
|
+
|
57
|
+
2) Use that token to initialize client:
|
58
|
+
|
59
|
+
```python
|
60
|
+
from dubidoc import DubidocAPIClient
|
61
|
+
|
62
|
+
api_token = 'xxxxxxxxxxxxxxx'
|
63
|
+
|
64
|
+
dubidoc = DubidocAPIClient(api_token)
|
65
|
+
|
66
|
+
documents = dubidoc.document_api.list()
|
67
|
+
print(documents)
|
68
|
+
```
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
This project is licensed under the terms of the [MIT license](https://github.com/DmytroLitvinov/python-dubidoc/blob/master/LICENSE).
|
@@ -0,0 +1,22 @@
|
|
1
|
+
LICENSE
|
2
|
+
README.md
|
3
|
+
pyproject.toml
|
4
|
+
dubidoc/__init__.py
|
5
|
+
dubidoc/client.py
|
6
|
+
dubidoc/enum.py
|
7
|
+
dubidoc.egg-info/PKG-INFO
|
8
|
+
dubidoc.egg-info/SOURCES.txt
|
9
|
+
dubidoc.egg-info/dependency_links.txt
|
10
|
+
dubidoc.egg-info/requires.txt
|
11
|
+
dubidoc.egg-info/top_level.txt
|
12
|
+
dubidoc/_modules/__init__.py
|
13
|
+
dubidoc/_modules/access_token.py
|
14
|
+
dubidoc/_modules/authentication.py
|
15
|
+
dubidoc/_modules/device.py
|
16
|
+
dubidoc/_modules/document.py
|
17
|
+
dubidoc/_modules/document_link.py
|
18
|
+
dubidoc/_modules/download.py
|
19
|
+
dubidoc/_modules/organization.py
|
20
|
+
dubidoc/_modules/organization_user.py
|
21
|
+
dubidoc/_modules/participant.py
|
22
|
+
dubidoc/_modules/storecode.py
|
@@ -0,0 +1 @@
|
|
1
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
requests
|
@@ -0,0 +1 @@
|
|
1
|
+
dubidoc
|
@@ -0,0 +1,72 @@
|
|
1
|
+
[build-system]
|
2
|
+
requires = ["setuptools>=61.0"]
|
3
|
+
build-backend = "setuptools.build_meta"
|
4
|
+
|
5
|
+
[project]
|
6
|
+
name = "dubidoc"
|
7
|
+
version = "0.1.0"
|
8
|
+
requires-python = ">=3.8"
|
9
|
+
description = "Python SDK for dubidoc.com.ua API"
|
10
|
+
readme = "README.md"
|
11
|
+
keywords = ["dubidoc", "Ukraine", "πΊπ¦", "api", "dubidoc.com.ua"]
|
12
|
+
maintainers = [
|
13
|
+
{name = "Dmytro Litvinov", email = "me@dmytrolitvinov.com"}
|
14
|
+
]
|
15
|
+
classifiers = [
|
16
|
+
"Development Status :: 4 - Beta",
|
17
|
+
"Environment :: Web Environment",
|
18
|
+
"Intended Audience :: Developers",
|
19
|
+
"License :: OSI Approved :: MIT License",
|
20
|
+
"Natural Language :: English",
|
21
|
+
"Operating System :: OS Independent",
|
22
|
+
"Programming Language :: Python",
|
23
|
+
"Programming Language :: Python :: 3",
|
24
|
+
"Programming Language :: Python :: 3.8",
|
25
|
+
"Programming Language :: Python :: 3.9",
|
26
|
+
"Programming Language :: Python :: 3.10",
|
27
|
+
"Programming Language :: Python :: 3.11",
|
28
|
+
"Topic :: Internet :: WWW/HTTP",
|
29
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
30
|
+
]
|
31
|
+
license = {text = "MIT License"}
|
32
|
+
dependencies = [
|
33
|
+
"requests"
|
34
|
+
]
|
35
|
+
|
36
|
+
[project.urls]
|
37
|
+
Homepage = "https://github.com/DmytroLitvinov/python-dubidoc"
|
38
|
+
Issues = "https://github.com/DmytroLitvinov/python-dubidoc/issues"
|
39
|
+
Changelog = "https://github.com/DmytroLitvinov/python-dubidoc/CHANGELOG.md"
|
40
|
+
|
41
|
+
[tool.setuptools.packages.find]
|
42
|
+
include = ["dubidoc*"]
|
43
|
+
|
44
|
+
# Ruff
|
45
|
+
# ----
|
46
|
+
[tool.ruff]
|
47
|
+
src = ["dubidoc"]
|
48
|
+
line-length = 120
|
49
|
+
indent-width = 4
|
50
|
+
|
51
|
+
[tool.ruff.format]
|
52
|
+
quote-style = "single"
|
53
|
+
indent-style = "space"
|
54
|
+
skip-magic-trailing-comma = false
|
55
|
+
line-ending = "auto"
|
56
|
+
|
57
|
+
# Mypy
|
58
|
+
# ----
|
59
|
+
|
60
|
+
[tool.mypy]
|
61
|
+
files = "."
|
62
|
+
|
63
|
+
# Use strict defaults
|
64
|
+
strict = true
|
65
|
+
warn_unreachable = true
|
66
|
+
warn_no_return = true
|
67
|
+
|
68
|
+
[[tool.mypy.overrides]]
|
69
|
+
# Don't require test functions to include types
|
70
|
+
module = "tests.*"
|
71
|
+
allow_untyped_defs = true
|
72
|
+
disable_error_code = "attr-defined"
|
dubidoc-0.1.0/setup.cfg
ADDED