docuseal 1.0.0__py3-none-any.whl

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.
docuseal/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ from docuseal._api import DocusealApi
2
+
3
+ api = DocusealApi()
4
+
5
+ docuseal = api
docuseal/_api.py ADDED
@@ -0,0 +1,118 @@
1
+ from docuseal._http import DocusealHttp
2
+
3
+
4
+ class DocusealApi:
5
+ def __init__(self, key=None, url="https://api.docuseal.com", read_timeout=60, open_timeout=60):
6
+ self.config = {}
7
+
8
+ self.config["key"] = key
9
+ self.config["url"] = url
10
+ self.config["read_timeout"] = read_timeout
11
+ self.config["open_timeout"] = open_timeout
12
+
13
+ self.http = DocusealHttp(self.config)
14
+
15
+ @property
16
+ def key(self):
17
+ return self.config["key"]
18
+
19
+ @key.setter
20
+ def key(self, value):
21
+ self.config["key"] = value
22
+
23
+ @property
24
+ def url(self):
25
+ return self.config["url"]
26
+
27
+ @url.setter
28
+ def url(self, value):
29
+ self.config["url"] = value
30
+
31
+ @property
32
+ def read_timeout(self):
33
+ return self.config["read_timeout"]
34
+
35
+ @read_timeout.setter
36
+ def read_timeout(self, value):
37
+ self.config["read_timeout"] = value
38
+
39
+ @property
40
+ def open_timeout(self):
41
+ return self.config["open_timeout"]
42
+
43
+ @open_timeout.setter
44
+ def open_timeout(self, value):
45
+ self.config["open_timeout"] = value
46
+
47
+ def list_templates(self, params=None):
48
+ if params is None:
49
+ params = {}
50
+ return self.http.get("/templates", params)
51
+
52
+ def get_template(self, template_id, params=None):
53
+ if params is None:
54
+ params = {}
55
+ return self.http.get(f"/templates/{template_id}", params)
56
+
57
+ def create_template_from_docx(self, data):
58
+ return self.http.post("/templates/docx", data)
59
+
60
+ def create_template_from_html(self, data):
61
+ return self.http.post("/templates/html", data)
62
+
63
+ def create_template_from_pdf(self, data):
64
+ return self.http.post("/templates/pdf", data)
65
+
66
+ def merge_templates(self, data):
67
+ return self.http.post("/templates/merge", data)
68
+
69
+ def clone_template(self, template_id, data):
70
+ return self.http.post(f"/templates/{template_id}/clone", data)
71
+
72
+ def update_template(self, template_id, data):
73
+ return self.http.put(f"/templates/{template_id}", data)
74
+
75
+ def update_template_documents(self, template_id, data):
76
+ return self.http.put(f"/templates/{template_id}/documents", data)
77
+
78
+ def archive_template(self, template_id):
79
+ return self.http.delete(f"/templates/{template_id}")
80
+
81
+ def permanently_delete_template(self, template_id):
82
+ return self.http.delete(f"/templates/{template_id}", {"permanently": True})
83
+
84
+ def list_submissions(self, params=None):
85
+ if params is None:
86
+ params = {}
87
+ return self.http.get("/submissions", params)
88
+
89
+ def get_submission(self, submission_id, params=None):
90
+ if params is None:
91
+ params = {}
92
+ return self.http.get(f"/submissions/{submission_id}", params)
93
+
94
+ def create_submission(self, data):
95
+ return self.http.post("/submissions/init", data)
96
+
97
+ def create_submission_from_emails(self, data):
98
+ return self.http.post("/submissions/emails", data)
99
+
100
+ def archive_submission(self, submission_id):
101
+ return self.http.delete(f"/submissions/{submission_id}")
102
+
103
+ def permanently_delete_submission(self, submission_id):
104
+ return self.http.delete(f"/submissions/{submission_id}", {"permanently": True})
105
+
106
+ def list_submitters(self, params=None):
107
+ if params is None:
108
+ params = {}
109
+ return self.http.get("/submitters", params)
110
+
111
+ def get_submitter(self, submitter_id, params=None):
112
+ if params is None:
113
+ params = {}
114
+ return self.http.get(f"/submitters/{submitter_id}", params)
115
+
116
+ def update_submitter(self, submitter_id, data):
117
+ return self.http.put(f"/submitters/{submitter_id}", data)
118
+
docuseal/_http.py ADDED
@@ -0,0 +1,73 @@
1
+ import json
2
+ import urllib.parse
3
+ import http.client
4
+ from docuseal._version import VERSION
5
+
6
+
7
+ class ApiError(Exception):
8
+ pass
9
+
10
+
11
+ class DocusealHttp:
12
+ BODY_METHODS = {"POST", "PUT"}
13
+
14
+ def __init__(self, config):
15
+ self.config = config
16
+
17
+ def get(self, path, params=None):
18
+ return self.send_request("GET", path, params)
19
+
20
+ def post(self, path, body=None):
21
+ return self.send_request("POST", path, None, body)
22
+
23
+ def put(self, path, body=None):
24
+ return self.send_request("PUT", path, None, body)
25
+
26
+ def delete(self, path, params=None):
27
+ return self.send_request("DELETE", path, params)
28
+
29
+ def send_request(self, method, path, params=None, body=None):
30
+ if params is None:
31
+ params = {}
32
+
33
+ url = urllib.parse.urljoin(self.config["url"], path)
34
+ full_path = f"{url}{self.to_query(params)}"
35
+
36
+ parsed_url = urllib.parse.urlparse(full_path)
37
+ connection_class = (
38
+ http.client.HTTPSConnection
39
+ if parsed_url.scheme == "https"
40
+ else http.client.HTTPConnection
41
+ )
42
+ conn = connection_class(
43
+ parsed_url.hostname or "", parsed_url.port, timeout=self.config.get("open_timeout", 60)
44
+ )
45
+
46
+ headers = self.headers()
47
+ data = json.dumps(body) if body is not None else None
48
+
49
+ conn.request(method, f"{parsed_url.path}?{parsed_url.query}", body=data, headers=headers)
50
+ response = conn.getresponse()
51
+
52
+ conn.sock.settimeout(self.config.get("read_timeout", 60))
53
+
54
+ return self.handle_response(response)
55
+
56
+ def headers(self):
57
+ return {
58
+ "X-Auth-Token": self.config["key"] or "",
59
+ "Content-Type": "application/json",
60
+ "User-Agent": f"DocuSeal Python v{VERSION}",
61
+ }
62
+
63
+ def to_query(self, params):
64
+ if not params:
65
+ return ""
66
+ return f"?{urllib.parse.urlencode(params)}"
67
+
68
+ def handle_response(self, response):
69
+ response_body = response.read().decode("utf-8")
70
+ if 200 <= response.status < 300:
71
+ return json.loads(response_body)
72
+ else:
73
+ raise ApiError(f"API Error {response.status}: {response_body}")
docuseal/_version.py ADDED
@@ -0,0 +1 @@
1
+ VERSION = "1.0.0"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 DocuSeal LLC
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,36 @@
1
+ Metadata-Version: 2.1
2
+ Name: docuseal
3
+ Version: 1.0.0
4
+ Summary: A example Python package
5
+ Home-page: https://github.com/docusealco/docuseal-python
6
+ Author: DocuSeal
7
+ Author-email: admin@docuseal.com
8
+ License: MIT
9
+ Project-URL: Bug Tracker, https://github.com/docuseaoco/docuseal-python/issues
10
+ Project-URL: Changes, https://github.com/docuseaoco/docuseal-python/blob/master/CHANGELOG.md
11
+ Project-URL: Documentation, https://www.docuseal.com/docs/api?lang=python
12
+ Project-URL: Source Code, https://github.com/docuseaoco/docuseal-python
13
+ Keywords: docuseal document signature
14
+ Platform: UNKNOWN
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3 :: Only
22
+ Classifier: Programming Language :: Python :: 3.6
23
+ Classifier: Programming Language :: Python :: 3.7
24
+ Classifier: Programming Language :: Python :: 3.8
25
+ Classifier: Programming Language :: Python :: 3.9
26
+ Classifier: Programming Language :: Python :: 3.10
27
+ Classifier: Programming Language :: Python :: 3.11
28
+ Classifier: Programming Language :: Python :: 3.12
29
+ Classifier: Programming Language :: Python :: Implementation :: CPython
30
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
31
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
32
+ Requires-Python: >=3.6
33
+ License-File: LICENSE
34
+
35
+ UNKNOWN
36
+
@@ -0,0 +1,9 @@
1
+ docuseal/__init__.py,sha256=8Fg68dFcrXmZyf4nse7uzgcBh63Qnd1KZAhosrSvFxw,75
2
+ docuseal/_api.py,sha256=D1bITRVSjWImVcx95FZGTqxcxtdL8Wm1b22rzqJ1ONs,3660
3
+ docuseal/_http.py,sha256=cGQFPcsr5e0IyaWI9XMWGe0lTcKR4BDWvjW-SZVceX4,2188
4
+ docuseal/_version.py,sha256=lzGFsymf0DtA_1oAZcPbeQ557iY-1BRkekhfA2qaFh8,18
5
+ docuseal-1.0.0.dist-info/LICENSE,sha256=RApvlVytF3v-pdLtKUE6zzpkl0dqUSGOX71SzK5d47c,1079
6
+ docuseal-1.0.0.dist-info/METADATA,sha256=ndGUnMxxiNL0mJCH1vyvnd08JqkvEc3e4zwZFGqr3TY,1547
7
+ docuseal-1.0.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
8
+ docuseal-1.0.0.dist-info/top_level.txt,sha256=8WHWTySIaA8JR5D-U0gmBn5cksASAdMss9rXuAwMKxI,9
9
+ docuseal-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.37.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ docuseal