signwell-sdk-python 0.1.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.
Files changed (110) hide show
  1. signwell_sdk/__init__.py +287 -0
  2. signwell_sdk/api/__init__.py +10 -0
  3. signwell_sdk/api/api_application_api.py +481 -0
  4. signwell_sdk/api/bulk_send_api.py +1589 -0
  5. signwell_sdk/api/document_api.py +2425 -0
  6. signwell_sdk/api/me_api.py +246 -0
  7. signwell_sdk/api/regional_api.py +345 -0
  8. signwell_sdk/api/template_api.py +1298 -0
  9. signwell_sdk/api/webhooks_api.py +710 -0
  10. signwell_sdk/api_client.py +747 -0
  11. signwell_sdk/api_response.py +20 -0
  12. signwell_sdk/configuration.py +599 -0
  13. signwell_sdk/embedded.py +385 -0
  14. signwell_sdk/exceptions.py +314 -0
  15. signwell_sdk/models/__init__.py +114 -0
  16. signwell_sdk/models/account_info_response.py +143 -0
  17. signwell_sdk/models/account_info_response_active_users_inner.py +107 -0
  18. signwell_sdk/models/account_info_response_preferences.py +147 -0
  19. signwell_sdk/models/additional_fields_inner_inner.py +274 -0
  20. signwell_sdk/models/additional_fields_inner_inner_value.py +189 -0
  21. signwell_sdk/models/additional_files_inner.py +103 -0
  22. signwell_sdk/models/api_application_response.py +137 -0
  23. signwell_sdk/models/api_application_response_owner.py +107 -0
  24. signwell_sdk/models/api_application_response_preferences.py +135 -0
  25. signwell_sdk/models/attachment_request_info.py +99 -0
  26. signwell_sdk/models/attachment_requests_inner.py +110 -0
  27. signwell_sdk/models/bulk_send_create_response.py +132 -0
  28. signwell_sdk/models/bulk_send_csv_request.py +100 -0
  29. signwell_sdk/models/bulk_send_csv_template_response.py +97 -0
  30. signwell_sdk/models/bulk_send_documents_response.py +167 -0
  31. signwell_sdk/models/bulk_send_list_item.py +141 -0
  32. signwell_sdk/models/bulk_send_list_response.py +138 -0
  33. signwell_sdk/models/bulk_send_response.py +151 -0
  34. signwell_sdk/models/bulk_send_response_templates_inner.py +98 -0
  35. signwell_sdk/models/bulk_send_validate_csv_response.py +129 -0
  36. signwell_sdk/models/checkbox_group_info.py +138 -0
  37. signwell_sdk/models/checkbox_groups_inner.py +136 -0
  38. signwell_sdk/models/checkbox_validation.py +35 -0
  39. signwell_sdk/models/completed_pdf_response.py +177 -0
  40. signwell_sdk/models/completed_pdf_url_response.py +97 -0
  41. signwell_sdk/models/copied_contact_info.py +99 -0
  42. signwell_sdk/models/copied_contacts_inner.py +98 -0
  43. signwell_sdk/models/copied_placeholders_inner.py +111 -0
  44. signwell_sdk/models/create_bulk_send_request.py +155 -0
  45. signwell_sdk/models/create_webhook_request.py +100 -0
  46. signwell_sdk/models/date_format.py +36 -0
  47. signwell_sdk/models/detailed_option.py +105 -0
  48. signwell_sdk/models/document_from_template_request.py +377 -0
  49. signwell_sdk/models/document_from_template_response.py +353 -0
  50. signwell_sdk/models/document_from_template_response_fields_inner_inner.py +270 -0
  51. signwell_sdk/models/document_from_template_response_fields_inner_inner_recipient.py +99 -0
  52. signwell_sdk/models/document_from_template_response_recipients_inner.py +206 -0
  53. signwell_sdk/models/document_list_response.py +138 -0
  54. signwell_sdk/models/document_request.py +350 -0
  55. signwell_sdk/models/document_response.py +357 -0
  56. signwell_sdk/models/document_response_attachment_requests_inner.py +101 -0
  57. signwell_sdk/models/document_response_fields_inner_inner.py +268 -0
  58. signwell_sdk/models/document_response_fields_inner_inner_options_inner.py +101 -0
  59. signwell_sdk/models/document_response_fields_inner_inner_recipient.py +98 -0
  60. signwell_sdk/models/document_response_fields_inner_inner_value.py +195 -0
  61. signwell_sdk/models/document_response_recipients_inner.py +208 -0
  62. signwell_sdk/models/document_template_list_response.py +138 -0
  63. signwell_sdk/models/document_template_request.py +307 -0
  64. signwell_sdk/models/document_template_response.py +323 -0
  65. signwell_sdk/models/document_template_response_copied_placeholders_inner.py +131 -0
  66. signwell_sdk/models/document_template_response_placeholders_inner.py +144 -0
  67. signwell_sdk/models/document_template_update_request.py +208 -0
  68. signwell_sdk/models/dropdown_option.py +153 -0
  69. signwell_sdk/models/error_response.py +107 -0
  70. signwell_sdk/models/error_response_meta.py +101 -0
  71. signwell_sdk/models/field_type.py +46 -0
  72. signwell_sdk/models/fields_inner_inner.py +268 -0
  73. signwell_sdk/models/file_format.py +33 -0
  74. signwell_sdk/models/file_info.py +98 -0
  75. signwell_sdk/models/files_inner.py +103 -0
  76. signwell_sdk/models/label_info.py +98 -0
  77. signwell_sdk/models/label_request.py +97 -0
  78. signwell_sdk/models/label_response.py +98 -0
  79. signwell_sdk/models/me_response.py +130 -0
  80. signwell_sdk/models/me_response_contact.py +147 -0
  81. signwell_sdk/models/me_response_user.py +117 -0
  82. signwell_sdk/models/me_response_user_preferences.py +105 -0
  83. signwell_sdk/models/nom151_certificate_response.py +107 -0
  84. signwell_sdk/models/nom151_certificate_response_nom151.py +125 -0
  85. signwell_sdk/models/nom151_url_response.py +97 -0
  86. signwell_sdk/models/pagination_meta.py +119 -0
  87. signwell_sdk/models/placeholders_inner.py +115 -0
  88. signwell_sdk/models/rate_limit_error_response.py +97 -0
  89. signwell_sdk/models/recipients_inner.py +141 -0
  90. signwell_sdk/models/reminder_recipients_inner.py +100 -0
  91. signwell_sdk/models/send_reminder_request.py +114 -0
  92. signwell_sdk/models/template_attachment_requests_inner.py +110 -0
  93. signwell_sdk/models/template_checkbox_groups_inner.py +136 -0
  94. signwell_sdk/models/template_field_values_inner.py +109 -0
  95. signwell_sdk/models/template_field_values_inner_value.py +189 -0
  96. signwell_sdk/models/template_fields_inner_inner.py +266 -0
  97. signwell_sdk/models/template_recipients_inner.py +146 -0
  98. signwell_sdk/models/text_validation.py +42 -0
  99. signwell_sdk/models/update_document_and_send_request.py +234 -0
  100. signwell_sdk/models/update_recipients_map_inner.py +118 -0
  101. signwell_sdk/models/update_recipients_request.py +111 -0
  102. signwell_sdk/models/validation_error_response.py +99 -0
  103. signwell_sdk/models/webhook_response.py +110 -0
  104. signwell_sdk/py.typed +0 -0
  105. signwell_sdk/rest.py +209 -0
  106. signwell_sdk/webhook.py +214 -0
  107. signwell_sdk_python-0.1.0.dist-info/METADATA +177 -0
  108. signwell_sdk_python-0.1.0.dist-info/RECORD +110 -0
  109. signwell_sdk_python-0.1.0.dist-info/WHEEL +4 -0
  110. signwell_sdk_python-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,353 @@
1
+ """
2
+ SignWell Developer API
3
+
4
+ API for creating, managing, and tracking electronic signature workflows.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: support@signwell.com
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from datetime import datetime
19
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
20
+ from typing import Any, ClassVar, Dict, List, Optional
21
+ from signwell_sdk.models.checkbox_group_info import CheckboxGroupInfo
22
+ from signwell_sdk.models.copied_contact_info import CopiedContactInfo
23
+ from signwell_sdk.models.document_from_template_response_fields_inner_inner import (
24
+ DocumentFromTemplateResponseFieldsInnerInner,
25
+ )
26
+ from signwell_sdk.models.document_from_template_response_recipients_inner import (
27
+ DocumentFromTemplateResponseRecipientsInner,
28
+ )
29
+ from signwell_sdk.models.document_response_attachment_requests_inner import DocumentResponseAttachmentRequestsInner
30
+ from signwell_sdk.models.file_info import FileInfo
31
+ from signwell_sdk.models.label_info import LabelInfo
32
+ from typing import Any, Optional, Set
33
+ from typing_extensions import Self
34
+
35
+
36
+ class DocumentFromTemplateResponse(BaseModel):
37
+ """
38
+ DocumentFromTemplateResponse
39
+ """ # noqa: E501
40
+
41
+ test_mode: StrictBool
42
+ id: StrictStr
43
+ template_id: StrictStr | None = None
44
+ template_ids: List[StrictStr] | None = None
45
+ api_application_id: StrictStr | None = None
46
+ requester_email_address: StrictStr | None = None
47
+ custom_requester_name: StrictStr | None = None
48
+ custom_requester_email: StrictStr | None = None
49
+ name: StrictStr | None = None
50
+ subject: StrictStr | None = None
51
+ message: StrictStr | None = None
52
+ metadata: Dict[str, StrictStr] | None = None
53
+ created_at: datetime | None = None
54
+ updated_at: datetime | None = None
55
+ recipients: List[DocumentFromTemplateResponseRecipientsInner] | None = None
56
+ status: StrictStr | None = Field(
57
+ default=None,
58
+ description="Possible values: Draft, Created, Sending, Sent, Pending, Viewed, Completed, Manually completed, Declined, Canceled, Bounced, Blocked, Error, Expired",
59
+ )
60
+ reminders: StrictBool | None = None
61
+ archived: StrictBool | None = None
62
+ embedded_signing: StrictBool | None = None
63
+ embedded_edit_url: StrictStr | None = None
64
+ embedded_preview_url: StrictStr | None = None
65
+ apply_signing_order: StrictBool | None = None
66
+ redirect_url: StrictStr | None = None
67
+ decline_redirect_url: StrictStr | None = None
68
+ language: StrictStr | None = None
69
+ expires_in: StrictInt | None = None
70
+ decline_message: StrictStr | None = None
71
+ error_message: StrictStr | None = None
72
+ embedded_signing_notifications: StrictBool | None = None
73
+ attachment_requests: List[DocumentResponseAttachmentRequestsInner] | None = None
74
+ files: List[FileInfo] | None = None
75
+ copied_contacts: List[CopiedContactInfo] | None = None
76
+ fields: List[List[DocumentFromTemplateResponseFieldsInnerInner]] | None = None
77
+ allow_decline: StrictBool | None = None
78
+ allow_reassign: StrictBool | None = None
79
+ labels: List[LabelInfo] | None = None
80
+ checkbox_groups: List[CheckboxGroupInfo] | None = None
81
+ additional_properties: Dict[str, Any] = {}
82
+ __properties: ClassVar[List[str]] = [
83
+ "test_mode",
84
+ "id",
85
+ "template_id",
86
+ "template_ids",
87
+ "api_application_id",
88
+ "requester_email_address",
89
+ "custom_requester_name",
90
+ "custom_requester_email",
91
+ "name",
92
+ "subject",
93
+ "message",
94
+ "metadata",
95
+ "created_at",
96
+ "updated_at",
97
+ "recipients",
98
+ "status",
99
+ "reminders",
100
+ "archived",
101
+ "embedded_signing",
102
+ "embedded_edit_url",
103
+ "embedded_preview_url",
104
+ "apply_signing_order",
105
+ "redirect_url",
106
+ "decline_redirect_url",
107
+ "language",
108
+ "expires_in",
109
+ "decline_message",
110
+ "error_message",
111
+ "embedded_signing_notifications",
112
+ "attachment_requests",
113
+ "files",
114
+ "copied_contacts",
115
+ "fields",
116
+ "allow_decline",
117
+ "allow_reassign",
118
+ "labels",
119
+ "checkbox_groups",
120
+ ]
121
+
122
+ model_config = ConfigDict(
123
+ populate_by_name=True,
124
+ validate_assignment=True,
125
+ protected_namespaces=(),
126
+ )
127
+
128
+ def to_str(self) -> str:
129
+ """Returns the string representation of the model using alias"""
130
+ return pprint.pformat(self.model_dump(by_alias=True))
131
+
132
+ def to_json(self) -> str:
133
+ """Returns the JSON representation of the model using alias"""
134
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
135
+ return json.dumps(self.to_dict())
136
+
137
+ @classmethod
138
+ def from_json(cls, json_str: str) -> Self | None:
139
+ """Create an instance of DocumentFromTemplateResponse from a JSON string"""
140
+ return cls.from_dict(json.loads(json_str))
141
+
142
+ def to_dict(self) -> Dict[str, Any]:
143
+ """Return the dictionary representation of the model using alias.
144
+
145
+ This has the following differences from calling pydantic's
146
+ `self.model_dump(by_alias=True)`:
147
+
148
+ * `None` is only added to the output dict for nullable fields that
149
+ were set at model initialization. Other fields with value `None`
150
+ are ignored.
151
+ * Fields in `self.additional_properties` are added to the output dict.
152
+ """
153
+ excluded_fields: Set[str] = set(
154
+ [
155
+ "additional_properties",
156
+ ]
157
+ )
158
+
159
+ _dict = self.model_dump(
160
+ by_alias=True,
161
+ exclude=excluded_fields,
162
+ exclude_none=True,
163
+ )
164
+ # override the default output from pydantic by calling `to_dict()` of each item in recipients (list)
165
+ _items_recipients: list[Any] = []
166
+ if self.recipients:
167
+ for _item_recipients in self.recipients:
168
+ if _item_recipients:
169
+ _items_recipients.append(_item_recipients.to_dict())
170
+ _dict["recipients"] = _items_recipients
171
+ # override the default output from pydantic by calling `to_dict()` of each item in attachment_requests (list)
172
+ _items_attachment_requests: list[Any] = []
173
+ if self.attachment_requests:
174
+ for _item_attachment_requests in self.attachment_requests:
175
+ if _item_attachment_requests:
176
+ _items_attachment_requests.append(_item_attachment_requests.to_dict())
177
+ _dict["attachment_requests"] = _items_attachment_requests
178
+ # override the default output from pydantic by calling `to_dict()` of each item in files (list)
179
+ _items_files: list[Any] = []
180
+ if self.files:
181
+ for _item_files in self.files:
182
+ if _item_files:
183
+ _items_files.append(_item_files.to_dict())
184
+ _dict["files"] = _items_files
185
+ # override the default output from pydantic by calling `to_dict()` of each item in copied_contacts (list)
186
+ _items_copied_contacts: list[Any] = []
187
+ if self.copied_contacts:
188
+ for _item_copied_contacts in self.copied_contacts:
189
+ if _item_copied_contacts:
190
+ _items_copied_contacts.append(_item_copied_contacts.to_dict())
191
+ _dict["copied_contacts"] = _items_copied_contacts
192
+ # override the default output from pydantic by calling `to_dict()` of each item in fields (list of list)
193
+ _items_fields: list[Any] = []
194
+ if self.fields:
195
+ for _item_fields in self.fields:
196
+ if _item_fields:
197
+ _items_fields.append(
198
+ [_inner_item.to_dict() for _inner_item in _item_fields if _inner_item is not None]
199
+ )
200
+ _dict["fields"] = _items_fields
201
+ # override the default output from pydantic by calling `to_dict()` of each item in labels (list)
202
+ _items_labels: list[Any] = []
203
+ if self.labels:
204
+ for _item_labels in self.labels:
205
+ if _item_labels:
206
+ _items_labels.append(_item_labels.to_dict())
207
+ _dict["labels"] = _items_labels
208
+ # override the default output from pydantic by calling `to_dict()` of each item in checkbox_groups (list)
209
+ _items_checkbox_groups: list[Any] = []
210
+ if self.checkbox_groups:
211
+ for _item_checkbox_groups in self.checkbox_groups:
212
+ if _item_checkbox_groups:
213
+ _items_checkbox_groups.append(_item_checkbox_groups.to_dict())
214
+ _dict["checkbox_groups"] = _items_checkbox_groups
215
+ # puts key-value pairs in additional_properties in the top level
216
+ if self.additional_properties is not None:
217
+ for _key, _value in self.additional_properties.items():
218
+ _dict[_key] = _value
219
+
220
+ # set to None if api_application_id (nullable) is None
221
+ # and model_fields_set contains the field
222
+ if self.api_application_id is None and "api_application_id" in self.model_fields_set:
223
+ _dict["api_application_id"] = None
224
+
225
+ # set to None if custom_requester_name (nullable) is None
226
+ # and model_fields_set contains the field
227
+ if self.custom_requester_name is None and "custom_requester_name" in self.model_fields_set:
228
+ _dict["custom_requester_name"] = None
229
+
230
+ # set to None if custom_requester_email (nullable) is None
231
+ # and model_fields_set contains the field
232
+ if self.custom_requester_email is None and "custom_requester_email" in self.model_fields_set:
233
+ _dict["custom_requester_email"] = None
234
+
235
+ # set to None if metadata (nullable) is None
236
+ # and model_fields_set contains the field
237
+ if self.metadata is None and "metadata" in self.model_fields_set:
238
+ _dict["metadata"] = None
239
+
240
+ # set to None if embedded_preview_url (nullable) is None
241
+ # and model_fields_set contains the field
242
+ if self.embedded_preview_url is None and "embedded_preview_url" in self.model_fields_set:
243
+ _dict["embedded_preview_url"] = None
244
+
245
+ # set to None if redirect_url (nullable) is None
246
+ # and model_fields_set contains the field
247
+ if self.redirect_url is None and "redirect_url" in self.model_fields_set:
248
+ _dict["redirect_url"] = None
249
+
250
+ # set to None if decline_redirect_url (nullable) is None
251
+ # and model_fields_set contains the field
252
+ if self.decline_redirect_url is None and "decline_redirect_url" in self.model_fields_set:
253
+ _dict["decline_redirect_url"] = None
254
+
255
+ # set to None if decline_message (nullable) is None
256
+ # and model_fields_set contains the field
257
+ if self.decline_message is None and "decline_message" in self.model_fields_set:
258
+ _dict["decline_message"] = None
259
+
260
+ # set to None if error_message (nullable) is None
261
+ # and model_fields_set contains the field
262
+ if self.error_message is None and "error_message" in self.model_fields_set:
263
+ _dict["error_message"] = None
264
+
265
+ # set to None if allow_decline (nullable) is None
266
+ # and model_fields_set contains the field
267
+ if self.allow_decline is None and "allow_decline" in self.model_fields_set:
268
+ _dict["allow_decline"] = None
269
+
270
+ # set to None if allow_reassign (nullable) is None
271
+ # and model_fields_set contains the field
272
+ if self.allow_reassign is None and "allow_reassign" in self.model_fields_set:
273
+ _dict["allow_reassign"] = None
274
+
275
+ return _dict
276
+
277
+ @classmethod
278
+ def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None:
279
+ """Create an instance of DocumentFromTemplateResponse from a dict"""
280
+ if obj is None:
281
+ return None
282
+
283
+ if not isinstance(obj, dict):
284
+ return cls.model_validate(obj)
285
+
286
+ _obj = cls.model_validate(
287
+ {
288
+ "test_mode": obj.get("test_mode"),
289
+ "id": obj.get("id"),
290
+ "template_id": obj.get("template_id"),
291
+ "template_ids": obj.get("template_ids"),
292
+ "api_application_id": obj.get("api_application_id"),
293
+ "requester_email_address": obj.get("requester_email_address"),
294
+ "custom_requester_name": obj.get("custom_requester_name"),
295
+ "custom_requester_email": obj.get("custom_requester_email"),
296
+ "name": obj.get("name"),
297
+ "subject": obj.get("subject"),
298
+ "message": obj.get("message"),
299
+ "metadata": obj.get("metadata"),
300
+ "created_at": obj.get("created_at"),
301
+ "updated_at": obj.get("updated_at"),
302
+ "recipients": [
303
+ DocumentFromTemplateResponseRecipientsInner.from_dict(_item) for _item in obj["recipients"]
304
+ ]
305
+ if obj.get("recipients") is not None
306
+ else None,
307
+ "status": obj.get("status"),
308
+ "reminders": obj.get("reminders"),
309
+ "archived": obj.get("archived"),
310
+ "embedded_signing": obj.get("embedded_signing"),
311
+ "embedded_edit_url": obj.get("embedded_edit_url"),
312
+ "embedded_preview_url": obj.get("embedded_preview_url"),
313
+ "apply_signing_order": obj.get("apply_signing_order"),
314
+ "redirect_url": obj.get("redirect_url"),
315
+ "decline_redirect_url": obj.get("decline_redirect_url"),
316
+ "language": obj.get("language"),
317
+ "expires_in": obj.get("expires_in"),
318
+ "decline_message": obj.get("decline_message"),
319
+ "error_message": obj.get("error_message"),
320
+ "embedded_signing_notifications": obj.get("embedded_signing_notifications"),
321
+ "attachment_requests": [
322
+ DocumentResponseAttachmentRequestsInner.from_dict(_item) for _item in obj["attachment_requests"]
323
+ ]
324
+ if obj.get("attachment_requests") is not None
325
+ else None,
326
+ "files": [FileInfo.from_dict(_item) for _item in obj["files"]]
327
+ if obj.get("files") is not None
328
+ else None,
329
+ "copied_contacts": [CopiedContactInfo.from_dict(_item) for _item in obj["copied_contacts"]]
330
+ if obj.get("copied_contacts") is not None
331
+ else None,
332
+ "fields": [
333
+ [DocumentFromTemplateResponseFieldsInnerInner.from_dict(_inner_item) for _inner_item in _item]
334
+ for _item in obj["fields"]
335
+ ]
336
+ if obj.get("fields") is not None
337
+ else None,
338
+ "allow_decline": obj.get("allow_decline"),
339
+ "allow_reassign": obj.get("allow_reassign"),
340
+ "labels": [LabelInfo.from_dict(_item) for _item in obj["labels"]]
341
+ if obj.get("labels") is not None
342
+ else None,
343
+ "checkbox_groups": [CheckboxGroupInfo.from_dict(_item) for _item in obj["checkbox_groups"]]
344
+ if obj.get("checkbox_groups") is not None
345
+ else None,
346
+ }
347
+ )
348
+ # store additional fields in additional_properties
349
+ for _key in obj.keys():
350
+ if _key not in cls.__properties:
351
+ _obj.additional_properties[_key] = obj.get(_key)
352
+
353
+ return _obj
@@ -0,0 +1,270 @@
1
+ """
2
+ SignWell Developer API
3
+
4
+ API for creating, managing, and tracking electronic signature workflows.
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: support@signwell.com
8
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
9
+
10
+ Do not edit the class manually.
11
+ """ # noqa: E501
12
+
13
+ from __future__ import annotations
14
+ import pprint
15
+ import re # noqa: F401
16
+ import json
17
+
18
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
19
+ from typing import Any, ClassVar, Dict, List, Optional, Union
20
+ from signwell_sdk.models.date_format import DateFormat
21
+ from signwell_sdk.models.document_from_template_response_fields_inner_inner_recipient import (
22
+ DocumentFromTemplateResponseFieldsInnerInnerRecipient,
23
+ )
24
+ from signwell_sdk.models.document_response_fields_inner_inner_options_inner import (
25
+ DocumentResponseFieldsInnerInnerOptionsInner,
26
+ )
27
+ from signwell_sdk.models.document_response_fields_inner_inner_value import DocumentResponseFieldsInnerInnerValue
28
+ from signwell_sdk.models.field_type import FieldType
29
+ from signwell_sdk.models.text_validation import TextValidation
30
+ from pydantic import model_validator
31
+ from typing import Any, Optional, Set, get_args
32
+ from typing_extensions import Self
33
+
34
+
35
+ class DocumentFromTemplateResponseFieldsInnerInner(BaseModel):
36
+ """
37
+ DocumentFromTemplateResponseFieldsInnerInner
38
+ """ # noqa: E501
39
+
40
+ x: Union[StrictFloat, StrictInt]
41
+ y: Union[StrictFloat, StrictInt]
42
+ page: StrictInt
43
+ recipient: DocumentFromTemplateResponseFieldsInnerInnerRecipient | None = None
44
+ api_id: StrictStr | None = None
45
+ name: StrictStr | None = None
46
+ date_format: DateFormat | None = None
47
+ fixed_width: StrictBool | None = None
48
+ formula: StrictStr | None = None
49
+ label: StrictStr | None = None
50
+ lock_sign_date: StrictBool | None = None
51
+ required: StrictBool | None = None
52
+ type: FieldType | None = None
53
+ validation: TextValidation | None = None
54
+ value: DocumentResponseFieldsInnerInnerValue | None = None
55
+ height: StrictStr | None = None
56
+ width: StrictStr | None = None
57
+ recipient_id: StrictStr | None = None
58
+ signing_elements_group_id: StrictStr | None = None
59
+ placeholder_name: StrictStr | None = None
60
+ options: List[DocumentResponseFieldsInnerInnerOptionsInner] | None = Field(
61
+ default=None, description="Dropdown options (for dropdown/select fields)"
62
+ )
63
+ default_option: StrictStr | None = Field(default=None, description="Default selected option")
64
+ allow_other: StrictBool | None = Field(default=None, description='Whether "Other" option is allowed')
65
+ additional_properties: Dict[str, Any] = {}
66
+ __properties: ClassVar[List[str]] = [
67
+ "x",
68
+ "y",
69
+ "page",
70
+ "recipient",
71
+ "api_id",
72
+ "name",
73
+ "date_format",
74
+ "fixed_width",
75
+ "formula",
76
+ "label",
77
+ "lock_sign_date",
78
+ "required",
79
+ "type",
80
+ "validation",
81
+ "value",
82
+ "height",
83
+ "width",
84
+ "recipient_id",
85
+ "signing_elements_group_id",
86
+ "placeholder_name",
87
+ "options",
88
+ "default_option",
89
+ "allow_other",
90
+ ]
91
+
92
+ @model_validator(mode="before")
93
+ @classmethod
94
+ def normalize_checkbox_value_input(cls, data: Any) -> Any:
95
+ if not isinstance(data, dict):
96
+ return data
97
+ if cls._field_type_value(data.get("type")) != "checkbox":
98
+ return data
99
+ if data.get("value") is None:
100
+ return data
101
+
102
+ normalized = dict(data)
103
+ normalized["value"] = cls._build_value_model(cls._normalize_checkbox_value(data["value"]))
104
+ return normalized
105
+
106
+ @model_validator(mode="after")
107
+ def normalize_checkbox_value(self) -> Self:
108
+ field_type = getattr(self.type, "value", self.type)
109
+ if field_type == "checkbox" and self.value is not None:
110
+ self.value.actual_instance = self._normalize_checkbox_value(self.value)
111
+ return self
112
+
113
+ @classmethod
114
+ def _build_value_model(cls, value: str) -> Any:
115
+ value_field = cls.model_fields.get("value")
116
+ if value_field is None:
117
+ return value
118
+
119
+ annotation = value_field.annotation
120
+ candidates = get_args(annotation) or (annotation,)
121
+ for candidate in candidates:
122
+ if candidate is type(None):
123
+ continue
124
+ value_model: Any = candidate
125
+ if callable(value_model):
126
+ return value_model(value)
127
+ return value
128
+
129
+ @staticmethod
130
+ def _field_type_value(value: Any) -> Any:
131
+ return getattr(value, "value", value)
132
+
133
+ @staticmethod
134
+ def _normalize_checkbox_value(value: Any) -> str:
135
+ actual_value = getattr(value, "actual_instance", value)
136
+ if isinstance(actual_value, bool):
137
+ return "t" if actual_value else "f"
138
+ if isinstance(actual_value, str):
139
+ normalized = actual_value.strip().lower()
140
+ if normalized in {"true", "t"}:
141
+ return "t"
142
+ if normalized in {"false", "f"}:
143
+ return "f"
144
+ raise ValueError('Checkbox field values must be boolean or one of "true", "false", "t", or "f"')
145
+
146
+ model_config = ConfigDict(
147
+ populate_by_name=True,
148
+ validate_assignment=True,
149
+ protected_namespaces=(),
150
+ )
151
+
152
+ def to_str(self) -> str:
153
+ """Returns the string representation of the model using alias"""
154
+ return pprint.pformat(self.model_dump(by_alias=True))
155
+
156
+ def to_json(self) -> str:
157
+ """Returns the JSON representation of the model using alias"""
158
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
159
+ return json.dumps(self.to_dict())
160
+
161
+ @classmethod
162
+ def from_json(cls, json_str: str) -> Self | None:
163
+ """Create an instance of DocumentFromTemplateResponseFieldsInnerInner from a JSON string"""
164
+ return cls.from_dict(json.loads(json_str))
165
+
166
+ def to_dict(self) -> Dict[str, Any]:
167
+ """Return the dictionary representation of the model using alias.
168
+
169
+ This has the following differences from calling pydantic's
170
+ `self.model_dump(by_alias=True)`:
171
+
172
+ * `None` is only added to the output dict for nullable fields that
173
+ were set at model initialization. Other fields with value `None`
174
+ are ignored.
175
+ * Fields in `self.additional_properties` are added to the output dict.
176
+ """
177
+ excluded_fields: Set[str] = set(
178
+ [
179
+ "additional_properties",
180
+ ]
181
+ )
182
+
183
+ _dict = self.model_dump(
184
+ by_alias=True,
185
+ exclude=excluded_fields,
186
+ exclude_none=True,
187
+ )
188
+ # override the default output from pydantic by calling `to_dict()` of recipient
189
+ if self.recipient:
190
+ _dict["recipient"] = self.recipient.to_dict()
191
+ # override the default output from pydantic by calling `to_dict()` of value
192
+ if self.value:
193
+ _dict["value"] = self.value.to_dict()
194
+ # override the default output from pydantic by calling `to_dict()` of each item in options (list)
195
+ _items_options: list[Any] = []
196
+ if self.options:
197
+ for _item_options in self.options:
198
+ if _item_options:
199
+ _items_options.append(_item_options.to_dict())
200
+ _dict["options"] = _items_options
201
+ # puts key-value pairs in additional_properties in the top level
202
+ if self.additional_properties is not None:
203
+ for _key, _value in self.additional_properties.items():
204
+ _dict[_key] = _value
205
+
206
+ # set to None if name (nullable) is None
207
+ # and model_fields_set contains the field
208
+ if self.name is None and "name" in self.model_fields_set:
209
+ _dict["name"] = None
210
+
211
+ # set to None if value (nullable) is None
212
+ # and model_fields_set contains the field
213
+ if self.value is None and "value" in self.model_fields_set:
214
+ _dict["value"] = None
215
+
216
+ # set to None if recipient_id (nullable) is None
217
+ # and model_fields_set contains the field
218
+ if self.recipient_id is None and "recipient_id" in self.model_fields_set:
219
+ _dict["recipient_id"] = None
220
+
221
+ return _dict
222
+
223
+ @classmethod
224
+ def from_dict(cls, obj: Dict[str, Any] | None) -> Self | None:
225
+ """Create an instance of DocumentFromTemplateResponseFieldsInnerInner from a dict"""
226
+ if obj is None:
227
+ return None
228
+
229
+ if not isinstance(obj, dict):
230
+ return cls.model_validate(obj)
231
+
232
+ _obj = cls.model_validate(
233
+ {
234
+ "x": obj.get("x"),
235
+ "y": obj.get("y"),
236
+ "page": obj.get("page"),
237
+ "recipient": DocumentFromTemplateResponseFieldsInnerInnerRecipient.from_dict(obj["recipient"])
238
+ if obj.get("recipient") is not None
239
+ else None,
240
+ "api_id": obj.get("api_id"),
241
+ "name": obj.get("name"),
242
+ "date_format": obj.get("date_format"),
243
+ "fixed_width": obj.get("fixed_width"),
244
+ "formula": obj.get("formula"),
245
+ "label": obj.get("label"),
246
+ "lock_sign_date": obj.get("lock_sign_date"),
247
+ "required": obj.get("required"),
248
+ "type": obj.get("type"),
249
+ "validation": obj.get("validation"),
250
+ "value": DocumentResponseFieldsInnerInnerValue.from_dict(obj["value"])
251
+ if obj.get("value") is not None
252
+ else None,
253
+ "height": obj.get("height"),
254
+ "width": obj.get("width"),
255
+ "recipient_id": obj.get("recipient_id"),
256
+ "signing_elements_group_id": obj.get("signing_elements_group_id"),
257
+ "placeholder_name": obj.get("placeholder_name"),
258
+ "options": [DocumentResponseFieldsInnerInnerOptionsInner.from_dict(_item) for _item in obj["options"]]
259
+ if obj.get("options") is not None
260
+ else None,
261
+ "default_option": obj.get("default_option"),
262
+ "allow_other": obj.get("allow_other"),
263
+ }
264
+ )
265
+ # store additional fields in additional_properties
266
+ for _key in obj.keys():
267
+ if _key not in cls.__properties:
268
+ _obj.additional_properties[_key] = obj.get(_key)
269
+
270
+ return _obj