esignbase-sdk 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.
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: esignbase-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: SDK Package for the eSignBase API
|
|
5
|
+
Author-email: Matthias Meß <info@esignbase.com>
|
|
6
|
+
Requires-Python: <4.0,>=3.14
|
|
7
|
+
Description-Content-Type: text/markdown
|
|
8
|
+
Requires-Dist: requests<3.0.0,>=2.32.5
|
|
9
|
+
Provides-Extra: dev
|
|
10
|
+
Requires-Dist: isort; extra == "dev"
|
|
11
|
+
Requires-Dist: black; extra == "dev"
|
|
12
|
+
|
|
13
|
+
# esignbase-python-sdk
|
|
14
|
+
API Client for the [eSignBase](https://esignbase.com) API
|
|
15
|
+
|
|
16
|
+
The package provides a small, synchronous client for interacting with the eSignBase API.
|
|
17
|
+
|
|
18
|
+
Full REST API documentation is available at https://esignbase.com/en/api_documentation it also shows the format of the returned dictionary data.
|
|
19
|
+
|
|
20
|
+
### Classes
|
|
21
|
+
|
|
22
|
+
**GrantType** (Enum)
|
|
23
|
+
|
|
24
|
+
Defines the available OAuth2 grant types:
|
|
25
|
+
|
|
26
|
+
* CLIENT_CREDENTIALS: For server-to-server authentication
|
|
27
|
+
* AUTHORIZATION_CODE: For user-specific authentication
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
**Scope** (Enum)
|
|
31
|
+
|
|
32
|
+
Defines the available API permission scopes:
|
|
33
|
+
|
|
34
|
+
* ALL: Full access to all API endpoints
|
|
35
|
+
* READ: Read-only access
|
|
36
|
+
* CREATE_DOCUMENT: Permission to create documents
|
|
37
|
+
* DELETE: Permission to delete documents
|
|
38
|
+
* SANDBOX: Access to the sandbox environment, use this scope for testing
|
|
39
|
+
|
|
40
|
+
**OAuth2Client**
|
|
41
|
+
|
|
42
|
+
Main client class that stores authentication credentials and state.
|
|
43
|
+
|
|
44
|
+
Attributes:
|
|
45
|
+
```python
|
|
46
|
+
id (str) # Client ID from ESignBase
|
|
47
|
+
secret (str) # Client secret from ESignBase
|
|
48
|
+
grant_type (GrantType) # OAuth2 grant type to use
|
|
49
|
+
user_name (Optional[str]) # Username (required AUTHORIZATION_CODE)
|
|
50
|
+
password (Optional[str]) # Password (required AUTHORIZATION_CODE)
|
|
51
|
+
scope (list[Scope]) # List of requested API scopes
|
|
52
|
+
```
|
|
53
|
+
Retrieve your Client ID and Client Secret at https://app.esignbase.com/oauth2/client by creating an
|
|
54
|
+
OAuth2 Client Configuration.
|
|
55
|
+
|
|
56
|
+
**Recipient**
|
|
57
|
+
|
|
58
|
+
Represents a document recipient/signer.
|
|
59
|
+
`role_name` value is defined during template creation in the template editor.
|
|
60
|
+
|
|
61
|
+
Attributes:
|
|
62
|
+
```python
|
|
63
|
+
email (str) # Recipient's email address
|
|
64
|
+
first_name (str) # Recipient's first name
|
|
65
|
+
last_name (str) # Recipient's last name
|
|
66
|
+
role_name (str) # Role name (e.g., "Signer", "Viewer")
|
|
67
|
+
locale (str) # Locale code ("de", "en", "es")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**ESignBaseSDKError** (Exception)
|
|
71
|
+
|
|
72
|
+
Custom exception class for API-related errors.
|
|
73
|
+
|
|
74
|
+
### Functions
|
|
75
|
+
|
|
76
|
+
```python
|
|
77
|
+
def connect(client: OAuth2Client) -> None
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Authenticates with the ESignBase API
|
|
81
|
+
|
|
82
|
+
Parameters:
|
|
83
|
+
|
|
84
|
+
client: Configured OAuth2Client instance
|
|
85
|
+
|
|
86
|
+
Raises:
|
|
87
|
+
|
|
88
|
+
ESignBaseSDKError: If authentication fails or validation fails
|
|
89
|
+
|
|
90
|
+
Example:
|
|
91
|
+
```python
|
|
92
|
+
client = OAuth2Client(
|
|
93
|
+
id="your_client_id",
|
|
94
|
+
secret="your_client_secret",
|
|
95
|
+
grant_type=GrantType.CLIENT_CREDENTIALS,
|
|
96
|
+
scope=[Scope.ALL],
|
|
97
|
+
)
|
|
98
|
+
connect(client)
|
|
99
|
+
```
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
def get_templates(client: OAuth2Client) -> list[dict[str, Any]]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Retrieves a list of available document templates.
|
|
108
|
+
|
|
109
|
+
Parameters:
|
|
110
|
+
```
|
|
111
|
+
client: Authenticated OAuth2Client instance
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Returns A list of dictionaries containing template data.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
|
|
118
|
+
ESignBaseSDKError: If the API request fails
|
|
119
|
+
|
|
120
|
+
---
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
def get_template(client: OAuth2Client, template_id: str) -> dict[str, Any]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Retrieves details of a specific template.
|
|
127
|
+
|
|
128
|
+
Parameters:
|
|
129
|
+
|
|
130
|
+
client: Authenticated OAuth2Client instance
|
|
131
|
+
template_id: Unique identifier of the template
|
|
132
|
+
|
|
133
|
+
Returns:
|
|
134
|
+
Dictionary containing template details
|
|
135
|
+
|
|
136
|
+
Raises:
|
|
137
|
+
ESignBaseSDKError: If the API request fails
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
def get_documents(client: OAuth2Client, limit: int, offset: int) -> dict[str, Any]
|
|
143
|
+
```
|
|
144
|
+
Retrieves a paginated list of documents.
|
|
145
|
+
|
|
146
|
+
Parameters:
|
|
147
|
+
|
|
148
|
+
client: Authenticated OAuth2Client instance
|
|
149
|
+
limit: Maximum number of documents to return
|
|
150
|
+
offset: Pagination offset
|
|
151
|
+
|
|
152
|
+
Returns:
|
|
153
|
+
|
|
154
|
+
Dictionary containing document list and pagination info `{documents: [...]}`
|
|
155
|
+
|
|
156
|
+
Raises:
|
|
157
|
+
|
|
158
|
+
ESignBaseSDKError: If the API request fails
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
def get_document(client: OAuth2Client, document_id: str) -> dict[str, Any]
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Retrieves details of a specific document.
|
|
167
|
+
|
|
168
|
+
Parameters:
|
|
169
|
+
|
|
170
|
+
client: Authenticated OAuth2Client instance
|
|
171
|
+
document_id: Unique identifier of the document
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
|
|
175
|
+
Dictionary containing document details
|
|
176
|
+
|
|
177
|
+
Raises:
|
|
178
|
+
|
|
179
|
+
ESignBaseSDKError: If the API request fails
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
def create_document(
|
|
185
|
+
client: OAuth2Client,
|
|
186
|
+
template_id: str,
|
|
187
|
+
document_name: str,
|
|
188
|
+
recipients: list[Recipient],
|
|
189
|
+
user_defined_metadata: Optional[dict[str, str | int]] = None,
|
|
190
|
+
expiration_date: Optional[datetime] = None
|
|
191
|
+
) -> dict[str, Any]
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Creates a new document from a template.
|
|
195
|
+
|
|
196
|
+
Parameters:
|
|
197
|
+
|
|
198
|
+
client: Authenticated OAuth2Client instance
|
|
199
|
+
template_id: ID of the template to use
|
|
200
|
+
document_name: Name for the new document
|
|
201
|
+
recipients: List of Recipient objects
|
|
202
|
+
user_defined_metadata: Optional metadata to attach to the document
|
|
203
|
+
expiration_date: Optional expiration date for the document
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
|
|
207
|
+
Dictionary containing the created document id and current document status
|
|
208
|
+
|
|
209
|
+
Raises:
|
|
210
|
+
|
|
211
|
+
ESignBaseSDKError: If the API request fails
|
|
212
|
+
|
|
213
|
+
Example:
|
|
214
|
+
|
|
215
|
+
```python
|
|
216
|
+
recipients = [
|
|
217
|
+
Recipient(
|
|
218
|
+
email="signer@example.com",
|
|
219
|
+
first_name="John",
|
|
220
|
+
last_name="Doe",
|
|
221
|
+
role_name="signer",
|
|
222
|
+
locale="de"
|
|
223
|
+
)
|
|
224
|
+
]
|
|
225
|
+
|
|
226
|
+
document = create_document(
|
|
227
|
+
client=client,
|
|
228
|
+
template_id="template_123",
|
|
229
|
+
document_name="Contract Agreement",
|
|
230
|
+
recipients=recipients,
|
|
231
|
+
user_defined_metadata={"contract_id": "CTR-2024-001"},
|
|
232
|
+
expiration_date=datetime(2024, 12, 31)
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
```python
|
|
240
|
+
def delete_document(client: OAuth2Client, document_id: str) -> None
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Deletes a specific document.
|
|
244
|
+
|
|
245
|
+
Parameters:
|
|
246
|
+
|
|
247
|
+
client: Authenticated OAuth2Client instance
|
|
248
|
+
document_id: Unique identifier of the document to delete
|
|
249
|
+
|
|
250
|
+
Raises:
|
|
251
|
+
|
|
252
|
+
ESignBaseSDKError: If the API request fails
|
|
253
|
+
|
|
254
|
+
---
|
|
255
|
+
|
|
256
|
+
```python
|
|
257
|
+
def get_credits(client: OAuth2Client) -> dict[str, Any]
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Retrieves credit balance information.
|
|
261
|
+
|
|
262
|
+
Parameters:
|
|
263
|
+
|
|
264
|
+
client: Authenticated OAuth2Client instance
|
|
265
|
+
|
|
266
|
+
Returns:
|
|
267
|
+
|
|
268
|
+
Dictionary containing credit balance data
|
|
269
|
+
|
|
270
|
+
Raises:
|
|
271
|
+
|
|
272
|
+
ESignBaseSDKError: If the API request fails
|
|
273
|
+
|
|
274
|
+
Error Handling
|
|
275
|
+
|
|
276
|
+
All functions raise ESignBaseSDKError exceptions for API errors, network issues, or validation failures. Always wrap API calls in try-except blocks:
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
try:
|
|
280
|
+
templates = get_templates(client)
|
|
281
|
+
except ESignBaseSDKError as e:
|
|
282
|
+
print(f"API Error: {e}")
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Complete Example
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
|
|
290
|
+
from datetime import datetime
|
|
291
|
+
|
|
292
|
+
# Setup client
|
|
293
|
+
client = OAuth2Client(
|
|
294
|
+
id="your_client_id",
|
|
295
|
+
secret="your_client_secret",
|
|
296
|
+
grant_type=GrantType.CLIENT_CREDENTIALS,
|
|
297
|
+
scope=[Scope.CREATE_DOCUMENT, Scope.READ]
|
|
298
|
+
)
|
|
299
|
+
|
|
300
|
+
# Authenticate
|
|
301
|
+
connect(client)
|
|
302
|
+
|
|
303
|
+
# Get available templates
|
|
304
|
+
templates = get_templates(client)
|
|
305
|
+
|
|
306
|
+
# Create a document
|
|
307
|
+
recipients = [
|
|
308
|
+
Recipient(
|
|
309
|
+
email="alice@example.com",
|
|
310
|
+
first_name="Alice",
|
|
311
|
+
last_name="Smith",
|
|
312
|
+
role_name="Signer",
|
|
313
|
+
locale="en"
|
|
314
|
+
)
|
|
315
|
+
]
|
|
316
|
+
template_id = templates[0]["id"]
|
|
317
|
+
|
|
318
|
+
document = create_document(
|
|
319
|
+
client=client,
|
|
320
|
+
template_id=template_id,
|
|
321
|
+
document_name="NDA Agreement",
|
|
322
|
+
recipients=recipients
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
# Check document status
|
|
326
|
+
document_details = get_document(client, document["id"])
|
|
327
|
+
|
|
328
|
+
# Delete the document (if needed)
|
|
329
|
+
delete_document(client, document["id"])
|
|
330
|
+
```
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
esignbase_sdk-1.0.0.dist-info/METADATA,sha256=M4gRi6cKF017_i5fOibZFr760EA4vJAJU-VCjiAHpbI,7085
|
|
2
|
+
esignbase_sdk-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
3
|
+
esignbase_sdk-1.0.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
4
|
+
esignbase_sdk-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|