docspring 3.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 (72) hide show
  1. docspring/__init__.py +250 -0
  2. docspring/api/__init__.py +20 -0
  3. docspring/api/client.py +13430 -0
  4. docspring/api_client.py +805 -0
  5. docspring/api_response.py +21 -0
  6. docspring/configuration.py +598 -0
  7. docspring/exceptions.py +217 -0
  8. docspring/models/__init__.py +146 -0
  9. docspring/models/add_fields_data.py +88 -0
  10. docspring/models/batch_generate_pdfs201_response.py +111 -0
  11. docspring/models/combine_pdfs_data.py +98 -0
  12. docspring/models/combined_submission.py +173 -0
  13. docspring/models/combined_submission_action.py +156 -0
  14. docspring/models/copy_template_options.py +92 -0
  15. docspring/models/create_combined_submission_response.py +107 -0
  16. docspring/models/create_custom_file_data.py +89 -0
  17. docspring/models/create_custom_file_response.py +107 -0
  18. docspring/models/create_folder_data.py +88 -0
  19. docspring/models/create_html_template.py +88 -0
  20. docspring/models/create_pdf_submission_data.py +112 -0
  21. docspring/models/create_pdf_template.py +88 -0
  22. docspring/models/create_submission_data_request_data.py +187 -0
  23. docspring/models/create_submission_data_request_event_request.py +134 -0
  24. docspring/models/create_submission_data_request_event_response.py +107 -0
  25. docspring/models/create_submission_data_request_response.py +107 -0
  26. docspring/models/create_submission_data_request_token_response.py +107 -0
  27. docspring/models/create_submission_response.py +107 -0
  28. docspring/models/create_webhook_data.py +88 -0
  29. docspring/models/custom_file.py +100 -0
  30. docspring/models/error_or_multiple_errors_response.py +103 -0
  31. docspring/models/error_response.py +101 -0
  32. docspring/models/folder.py +114 -0
  33. docspring/models/json_schema.py +110 -0
  34. docspring/models/list_submissions_response.py +105 -0
  35. docspring/models/move_folder_data.py +93 -0
  36. docspring/models/move_template_data.py +95 -0
  37. docspring/models/multiple_errors_response.py +101 -0
  38. docspring/models/publish_version_data.py +90 -0
  39. docspring/models/rename_folder_data.py +88 -0
  40. docspring/models/restore_version_data.py +88 -0
  41. docspring/models/submission.py +287 -0
  42. docspring/models/submission422_response.py +109 -0
  43. docspring/models/submission_action.py +148 -0
  44. docspring/models/submission_batch.py +123 -0
  45. docspring/models/submission_batch_data.py +106 -0
  46. docspring/models/submission_batch_with_submissions.py +133 -0
  47. docspring/models/submission_data_request.py +253 -0
  48. docspring/models/submission_data_request_event.py +155 -0
  49. docspring/models/submission_data_request_show.py +260 -0
  50. docspring/models/submission_data_request_token.py +109 -0
  51. docspring/models/submission_preview.py +257 -0
  52. docspring/models/success_error_response.py +101 -0
  53. docspring/models/success_multiple_errors_response.py +101 -0
  54. docspring/models/template.py +402 -0
  55. docspring/models/template_add_fields_response.py +103 -0
  56. docspring/models/template_delete_response.py +110 -0
  57. docspring/models/template_model_code_response.py +103 -0
  58. docspring/models/template_preview.py +356 -0
  59. docspring/models/template_publish_version_response.py +103 -0
  60. docspring/models/update_html_template.py +88 -0
  61. docspring/models/update_pdf_template.py +88 -0
  62. docspring/models/update_submission_data_request_data.py +185 -0
  63. docspring/models/update_webhook_data.py +88 -0
  64. docspring/models/upload_presign_response.py +108 -0
  65. docspring/models/webhook.py +185 -0
  66. docspring/py.typed +0 -0
  67. docspring/rest.py +259 -0
  68. docspring-3.1.0.dist-info/METADATA +245 -0
  69. docspring-3.1.0.dist-info/RECORD +72 -0
  70. docspring-3.1.0.dist-info/WHEEL +5 -0
  71. docspring-3.1.0.dist-info/licenses/LICENSE +7 -0
  72. docspring-3.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,260 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ DocSpring API
5
+
6
+ Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
7
+
8
+ The version of the OpenAPI document: v1
9
+ Contact: support@docspring.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr, ValidationInfo, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class SubmissionDataRequestShow(BaseModel):
27
+ """
28
+ SubmissionDataRequestShow
29
+ """ # noqa: E501
30
+ id: Optional[StrictStr]
31
+ email: Optional[StrictStr]
32
+ name: Optional[StrictStr]
33
+ order: Optional[StrictInt]
34
+ sort_order: StrictInt
35
+ fields: Optional[List[StrictStr]]
36
+ metadata: Optional[Dict[str, Any]]
37
+ state: StrictStr
38
+ viewed_at: Optional[StrictStr]
39
+ completed_at: Optional[StrictStr]
40
+ declined_at: Optional[StrictStr]
41
+ data: Optional[Dict[str, Any]]
42
+ auth_type: StrictStr
43
+ auth_second_factor_type: StrictStr
44
+ auth_provider: Optional[StrictStr]
45
+ auth_session_started_at: Optional[StrictStr]
46
+ auth_session_id_hash: Optional[StrictStr]
47
+ auth_user_id_hash: Optional[StrictStr]
48
+ auth_username_hash: Optional[StrictStr]
49
+ auth_phone_number_hash: Optional[StrictStr]
50
+ ip_address: Optional[StrictStr]
51
+ user_agent: Optional[StrictStr]
52
+ submission_id: Optional[StrictStr]
53
+ __properties: ClassVar[List[str]] = ["id", "email", "name", "order", "sort_order", "fields", "metadata", "state", "viewed_at", "completed_at", "declined_at", "data", "auth_type", "auth_second_factor_type", "auth_provider", "auth_session_started_at", "auth_session_id_hash", "auth_user_id_hash", "auth_username_hash", "auth_phone_number_hash", "ip_address", "user_agent", "submission_id"]
54
+
55
+ @field_validator('state')
56
+ def state_validate_enum(cls, value, info: ValidationInfo):
57
+ """Validates the enum"""
58
+ # from_dict accepts enum values this client doesn't know about yet
59
+ if info.context and info.context.get("skip_enum_validation"):
60
+ return value
61
+
62
+ if value not in set(['pending', 'completed', 'declined']):
63
+ raise ValueError("must be one of enum values ('pending', 'completed', 'declined')")
64
+ return value
65
+
66
+ @field_validator('auth_type')
67
+ def auth_type_validate_enum(cls, value, info: ValidationInfo):
68
+ """Validates the enum"""
69
+ # from_dict accepts enum values this client doesn't know about yet
70
+ if info.context and info.context.get("skip_enum_validation"):
71
+ return value
72
+
73
+ if value not in set(['none', 'password', 'oauth', 'email_link', 'phone_number', 'ldap', 'saml']):
74
+ raise ValueError("must be one of enum values ('none', 'password', 'oauth', 'email_link', 'phone_number', 'ldap', 'saml')")
75
+ return value
76
+
77
+ @field_validator('auth_second_factor_type')
78
+ def auth_second_factor_type_validate_enum(cls, value, info: ValidationInfo):
79
+ """Validates the enum"""
80
+ # from_dict accepts enum values this client doesn't know about yet
81
+ if info.context and info.context.get("skip_enum_validation"):
82
+ return value
83
+
84
+ if value not in set(['none', 'phone_number', 'totp', 'mobile_push', 'security_key', 'fingerprint']):
85
+ raise ValueError("must be one of enum values ('none', 'phone_number', 'totp', 'mobile_push', 'security_key', 'fingerprint')")
86
+ return value
87
+
88
+ model_config = ConfigDict(
89
+ populate_by_name=True,
90
+ validate_assignment=True,
91
+ protected_namespaces=(),
92
+ )
93
+
94
+
95
+ def to_str(self) -> str:
96
+ """Returns the string representation of the model using alias"""
97
+ return pprint.pformat(self.model_dump(by_alias=True))
98
+
99
+ def to_json(self) -> str:
100
+ """Returns the JSON representation of the model using alias"""
101
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
102
+ return json.dumps(self.to_dict())
103
+
104
+ @classmethod
105
+ def from_json(cls, json_str: str) -> Optional[Self]:
106
+ """Create an instance of SubmissionDataRequestShow from a JSON string"""
107
+ return cls.from_dict(json.loads(json_str))
108
+
109
+ def to_dict(self) -> Dict[str, Any]:
110
+ """Return the dictionary representation of the model using alias.
111
+
112
+ This has the following differences from calling pydantic's
113
+ `self.model_dump(by_alias=True)`:
114
+
115
+ * `None` is only added to the output dict for nullable fields that
116
+ were set at model initialization. Other fields with value `None`
117
+ are ignored.
118
+ """
119
+ excluded_fields: Set[str] = set([
120
+ ])
121
+
122
+ _dict = self.model_dump(
123
+ by_alias=True,
124
+ exclude=excluded_fields,
125
+ exclude_none=True,
126
+ )
127
+ # set to None if id (nullable) is None
128
+ # and model_fields_set contains the field
129
+ if self.id is None and "id" in self.model_fields_set:
130
+ _dict['id'] = None
131
+
132
+ # set to None if email (nullable) is None
133
+ # and model_fields_set contains the field
134
+ if self.email is None and "email" in self.model_fields_set:
135
+ _dict['email'] = None
136
+
137
+ # set to None if name (nullable) is None
138
+ # and model_fields_set contains the field
139
+ if self.name is None and "name" in self.model_fields_set:
140
+ _dict['name'] = None
141
+
142
+ # set to None if order (nullable) is None
143
+ # and model_fields_set contains the field
144
+ if self.order is None and "order" in self.model_fields_set:
145
+ _dict['order'] = None
146
+
147
+ # set to None if fields (nullable) is None
148
+ # and model_fields_set contains the field
149
+ if self.fields is None and "fields" in self.model_fields_set:
150
+ _dict['fields'] = None
151
+
152
+ # set to None if metadata (nullable) is None
153
+ # and model_fields_set contains the field
154
+ if self.metadata is None and "metadata" in self.model_fields_set:
155
+ _dict['metadata'] = None
156
+
157
+ # set to None if viewed_at (nullable) is None
158
+ # and model_fields_set contains the field
159
+ if self.viewed_at is None and "viewed_at" in self.model_fields_set:
160
+ _dict['viewed_at'] = None
161
+
162
+ # set to None if completed_at (nullable) is None
163
+ # and model_fields_set contains the field
164
+ if self.completed_at is None and "completed_at" in self.model_fields_set:
165
+ _dict['completed_at'] = None
166
+
167
+ # set to None if declined_at (nullable) is None
168
+ # and model_fields_set contains the field
169
+ if self.declined_at is None and "declined_at" in self.model_fields_set:
170
+ _dict['declined_at'] = None
171
+
172
+ # set to None if data (nullable) is None
173
+ # and model_fields_set contains the field
174
+ if self.data is None and "data" in self.model_fields_set:
175
+ _dict['data'] = None
176
+
177
+ # set to None if auth_provider (nullable) is None
178
+ # and model_fields_set contains the field
179
+ if self.auth_provider is None and "auth_provider" in self.model_fields_set:
180
+ _dict['auth_provider'] = None
181
+
182
+ # set to None if auth_session_started_at (nullable) is None
183
+ # and model_fields_set contains the field
184
+ if self.auth_session_started_at is None and "auth_session_started_at" in self.model_fields_set:
185
+ _dict['auth_session_started_at'] = None
186
+
187
+ # set to None if auth_session_id_hash (nullable) is None
188
+ # and model_fields_set contains the field
189
+ if self.auth_session_id_hash is None and "auth_session_id_hash" in self.model_fields_set:
190
+ _dict['auth_session_id_hash'] = None
191
+
192
+ # set to None if auth_user_id_hash (nullable) is None
193
+ # and model_fields_set contains the field
194
+ if self.auth_user_id_hash is None and "auth_user_id_hash" in self.model_fields_set:
195
+ _dict['auth_user_id_hash'] = None
196
+
197
+ # set to None if auth_username_hash (nullable) is None
198
+ # and model_fields_set contains the field
199
+ if self.auth_username_hash is None and "auth_username_hash" in self.model_fields_set:
200
+ _dict['auth_username_hash'] = None
201
+
202
+ # set to None if auth_phone_number_hash (nullable) is None
203
+ # and model_fields_set contains the field
204
+ if self.auth_phone_number_hash is None and "auth_phone_number_hash" in self.model_fields_set:
205
+ _dict['auth_phone_number_hash'] = None
206
+
207
+ # set to None if ip_address (nullable) is None
208
+ # and model_fields_set contains the field
209
+ if self.ip_address is None and "ip_address" in self.model_fields_set:
210
+ _dict['ip_address'] = None
211
+
212
+ # set to None if user_agent (nullable) is None
213
+ # and model_fields_set contains the field
214
+ if self.user_agent is None and "user_agent" in self.model_fields_set:
215
+ _dict['user_agent'] = None
216
+
217
+ # set to None if submission_id (nullable) is None
218
+ # and model_fields_set contains the field
219
+ if self.submission_id is None and "submission_id" in self.model_fields_set:
220
+ _dict['submission_id'] = None
221
+
222
+ return _dict
223
+
224
+ @classmethod
225
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
226
+ """Create an instance of SubmissionDataRequestShow from a dict"""
227
+ if obj is None:
228
+ return None
229
+
230
+ if not isinstance(obj, dict):
231
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
232
+
233
+ _obj = cls.model_validate({
234
+ "id": obj.get("id"),
235
+ "email": obj.get("email"),
236
+ "name": obj.get("name"),
237
+ "order": obj.get("order"),
238
+ "sort_order": obj.get("sort_order"),
239
+ "fields": obj.get("fields"),
240
+ "metadata": obj.get("metadata"),
241
+ "state": obj.get("state"),
242
+ "viewed_at": obj.get("viewed_at"),
243
+ "completed_at": obj.get("completed_at"),
244
+ "declined_at": obj.get("declined_at"),
245
+ "data": obj.get("data"),
246
+ "auth_type": obj.get("auth_type"),
247
+ "auth_second_factor_type": obj.get("auth_second_factor_type"),
248
+ "auth_provider": obj.get("auth_provider"),
249
+ "auth_session_started_at": obj.get("auth_session_started_at"),
250
+ "auth_session_id_hash": obj.get("auth_session_id_hash"),
251
+ "auth_user_id_hash": obj.get("auth_user_id_hash"),
252
+ "auth_username_hash": obj.get("auth_username_hash"),
253
+ "auth_phone_number_hash": obj.get("auth_phone_number_hash"),
254
+ "ip_address": obj.get("ip_address"),
255
+ "user_agent": obj.get("user_agent"),
256
+ "submission_id": obj.get("submission_id")
257
+ }, context={"skip_enum_validation": True})
258
+ return _obj
259
+
260
+
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ DocSpring API
5
+
6
+ Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
7
+
8
+ The version of the OpenAPI document: v1
9
+ Contact: support@docspring.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class SubmissionDataRequestToken(BaseModel):
27
+ """
28
+ SubmissionDataRequestToken
29
+ """ # noqa: E501
30
+ id: Optional[StrictStr]
31
+ secret: StrictStr
32
+ expires_at: Optional[StrictStr]
33
+ data_request_url: Optional[StrictStr]
34
+ __properties: ClassVar[List[str]] = ["id", "secret", "expires_at", "data_request_url"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of SubmissionDataRequestToken from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # set to None if id (nullable) is None
76
+ # and model_fields_set contains the field
77
+ if self.id is None and "id" in self.model_fields_set:
78
+ _dict['id'] = None
79
+
80
+ # set to None if expires_at (nullable) is None
81
+ # and model_fields_set contains the field
82
+ if self.expires_at is None and "expires_at" in self.model_fields_set:
83
+ _dict['expires_at'] = None
84
+
85
+ # set to None if data_request_url (nullable) is None
86
+ # and model_fields_set contains the field
87
+ if self.data_request_url is None and "data_request_url" in self.model_fields_set:
88
+ _dict['data_request_url'] = None
89
+
90
+ return _dict
91
+
92
+ @classmethod
93
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
94
+ """Create an instance of SubmissionDataRequestToken from a dict"""
95
+ if obj is None:
96
+ return None
97
+
98
+ if not isinstance(obj, dict):
99
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
100
+
101
+ _obj = cls.model_validate({
102
+ "id": obj.get("id"),
103
+ "secret": obj.get("secret"),
104
+ "expires_at": obj.get("expires_at"),
105
+ "data_request_url": obj.get("data_request_url")
106
+ }, context={"skip_enum_validation": True})
107
+ return _obj
108
+
109
+
@@ -0,0 +1,257 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ DocSpring API
5
+
6
+ Use DocSpring's API to programmatically fill out PDF forms, convert HTML to PDFs, merge PDFs, or request legally binding e-signatures.
7
+
8
+ The version of the OpenAPI document: v1
9
+ Contact: support@docspring.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, StrictBool, StrictStr, ValidationInfo, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from docspring.models.submission_action import SubmissionAction
24
+ from docspring.models.submission_data_request import SubmissionDataRequest
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class SubmissionPreview(BaseModel):
29
+ """
30
+ SubmissionPreview
31
+ """ # noqa: E501
32
+ batch_id: Optional[StrictStr]
33
+ data_requests: List[SubmissionDataRequest]
34
+ editable: Optional[StrictBool]
35
+ error_message: Optional[StrictStr]
36
+ expired: StrictBool
37
+ expires_at: Optional[StrictStr]
38
+ id: Optional[StrictStr]
39
+ json_schema_errors: Optional[List[StrictStr]]
40
+ metadata: Dict[str, Any]
41
+ password: Optional[StrictStr]
42
+ processed_at: Optional[StrictStr]
43
+ state: StrictStr
44
+ template_id: Optional[StrictStr]
45
+ template_type: StrictStr
46
+ template_version: Optional[StrictStr]
47
+ test: StrictBool
48
+ truncated_text: Optional[Dict[str, Any]]
49
+ pdf_hash: Optional[StrictStr]
50
+ download_url: Optional[StrictStr]
51
+ permanent_download_url: Optional[StrictStr]
52
+ preview_download_url: Optional[StrictStr]
53
+ preview_generated_at: Optional[StrictStr]
54
+ audit_trail_download_url: Optional[StrictStr]
55
+ actions: List[SubmissionAction]
56
+ __properties: ClassVar[List[str]] = ["batch_id", "data_requests", "editable", "error_message", "expired", "expires_at", "id", "json_schema_errors", "metadata", "password", "processed_at", "state", "template_id", "template_type", "template_version", "test", "truncated_text", "pdf_hash", "download_url", "permanent_download_url", "preview_download_url", "preview_generated_at", "audit_trail_download_url", "actions"]
57
+
58
+ @field_validator('state')
59
+ def state_validate_enum(cls, value, info: ValidationInfo):
60
+ """Validates the enum"""
61
+ # from_dict accepts enum values this client doesn't know about yet
62
+ if info.context and info.context.get("skip_enum_validation"):
63
+ return value
64
+
65
+ if value not in set(['pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed', 'waiting_for_data_requests', 'syntax_error', 'account_suspended', 'license_revoked', 'accidental', 'declined']):
66
+ raise ValueError("must be one of enum values ('pending', 'processed', 'invalid_data', 'error', 'image_download_failed', 'image_processing_failed', 'waiting_for_data_requests', 'syntax_error', 'account_suspended', 'license_revoked', 'accidental', 'declined')")
67
+ return value
68
+
69
+ @field_validator('template_type')
70
+ def template_type_validate_enum(cls, value, info: ValidationInfo):
71
+ """Validates the enum"""
72
+ # from_dict accepts enum values this client doesn't know about yet
73
+ if info.context and info.context.get("skip_enum_validation"):
74
+ return value
75
+
76
+ if value not in set(['pdf', 'html']):
77
+ raise ValueError("must be one of enum values ('pdf', 'html')")
78
+ return value
79
+
80
+ model_config = ConfigDict(
81
+ populate_by_name=True,
82
+ validate_assignment=True,
83
+ protected_namespaces=(),
84
+ )
85
+
86
+
87
+ def to_str(self) -> str:
88
+ """Returns the string representation of the model using alias"""
89
+ return pprint.pformat(self.model_dump(by_alias=True))
90
+
91
+ def to_json(self) -> str:
92
+ """Returns the JSON representation of the model using alias"""
93
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
94
+ return json.dumps(self.to_dict())
95
+
96
+ @classmethod
97
+ def from_json(cls, json_str: str) -> Optional[Self]:
98
+ """Create an instance of SubmissionPreview from a JSON string"""
99
+ return cls.from_dict(json.loads(json_str))
100
+
101
+ def to_dict(self) -> Dict[str, Any]:
102
+ """Return the dictionary representation of the model using alias.
103
+
104
+ This has the following differences from calling pydantic's
105
+ `self.model_dump(by_alias=True)`:
106
+
107
+ * `None` is only added to the output dict for nullable fields that
108
+ were set at model initialization. Other fields with value `None`
109
+ are ignored.
110
+ """
111
+ excluded_fields: Set[str] = set([
112
+ ])
113
+
114
+ _dict = self.model_dump(
115
+ by_alias=True,
116
+ exclude=excluded_fields,
117
+ exclude_none=True,
118
+ )
119
+ # override the default output from pydantic by calling `to_dict()` of each item in data_requests (list)
120
+ _items = []
121
+ if self.data_requests:
122
+ for _item_data_requests in self.data_requests:
123
+ if _item_data_requests:
124
+ _items.append(_item_data_requests.to_dict())
125
+ _dict['data_requests'] = _items
126
+ # override the default output from pydantic by calling `to_dict()` of each item in actions (list)
127
+ _items = []
128
+ if self.actions:
129
+ for _item_actions in self.actions:
130
+ if _item_actions:
131
+ _items.append(_item_actions.to_dict())
132
+ _dict['actions'] = _items
133
+ # set to None if batch_id (nullable) is None
134
+ # and model_fields_set contains the field
135
+ if self.batch_id is None and "batch_id" in self.model_fields_set:
136
+ _dict['batch_id'] = None
137
+
138
+ # set to None if editable (nullable) is None
139
+ # and model_fields_set contains the field
140
+ if self.editable is None and "editable" in self.model_fields_set:
141
+ _dict['editable'] = None
142
+
143
+ # set to None if error_message (nullable) is None
144
+ # and model_fields_set contains the field
145
+ if self.error_message is None and "error_message" in self.model_fields_set:
146
+ _dict['error_message'] = None
147
+
148
+ # set to None if expires_at (nullable) is None
149
+ # and model_fields_set contains the field
150
+ if self.expires_at is None and "expires_at" in self.model_fields_set:
151
+ _dict['expires_at'] = None
152
+
153
+ # set to None if id (nullable) is None
154
+ # and model_fields_set contains the field
155
+ if self.id is None and "id" in self.model_fields_set:
156
+ _dict['id'] = None
157
+
158
+ # set to None if json_schema_errors (nullable) is None
159
+ # and model_fields_set contains the field
160
+ if self.json_schema_errors is None and "json_schema_errors" in self.model_fields_set:
161
+ _dict['json_schema_errors'] = None
162
+
163
+ # set to None if password (nullable) is None
164
+ # and model_fields_set contains the field
165
+ if self.password is None and "password" in self.model_fields_set:
166
+ _dict['password'] = None
167
+
168
+ # set to None if processed_at (nullable) is None
169
+ # and model_fields_set contains the field
170
+ if self.processed_at is None and "processed_at" in self.model_fields_set:
171
+ _dict['processed_at'] = None
172
+
173
+ # set to None if template_id (nullable) is None
174
+ # and model_fields_set contains the field
175
+ if self.template_id is None and "template_id" in self.model_fields_set:
176
+ _dict['template_id'] = None
177
+
178
+ # set to None if template_version (nullable) is None
179
+ # and model_fields_set contains the field
180
+ if self.template_version is None and "template_version" in self.model_fields_set:
181
+ _dict['template_version'] = None
182
+
183
+ # set to None if truncated_text (nullable) is None
184
+ # and model_fields_set contains the field
185
+ if self.truncated_text is None and "truncated_text" in self.model_fields_set:
186
+ _dict['truncated_text'] = None
187
+
188
+ # set to None if pdf_hash (nullable) is None
189
+ # and model_fields_set contains the field
190
+ if self.pdf_hash is None and "pdf_hash" in self.model_fields_set:
191
+ _dict['pdf_hash'] = None
192
+
193
+ # set to None if download_url (nullable) is None
194
+ # and model_fields_set contains the field
195
+ if self.download_url is None and "download_url" in self.model_fields_set:
196
+ _dict['download_url'] = None
197
+
198
+ # set to None if permanent_download_url (nullable) is None
199
+ # and model_fields_set contains the field
200
+ if self.permanent_download_url is None and "permanent_download_url" in self.model_fields_set:
201
+ _dict['permanent_download_url'] = None
202
+
203
+ # set to None if preview_download_url (nullable) is None
204
+ # and model_fields_set contains the field
205
+ if self.preview_download_url is None and "preview_download_url" in self.model_fields_set:
206
+ _dict['preview_download_url'] = None
207
+
208
+ # set to None if preview_generated_at (nullable) is None
209
+ # and model_fields_set contains the field
210
+ if self.preview_generated_at is None and "preview_generated_at" in self.model_fields_set:
211
+ _dict['preview_generated_at'] = None
212
+
213
+ # set to None if audit_trail_download_url (nullable) is None
214
+ # and model_fields_set contains the field
215
+ if self.audit_trail_download_url is None and "audit_trail_download_url" in self.model_fields_set:
216
+ _dict['audit_trail_download_url'] = None
217
+
218
+ return _dict
219
+
220
+ @classmethod
221
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
222
+ """Create an instance of SubmissionPreview from a dict"""
223
+ if obj is None:
224
+ return None
225
+
226
+ if not isinstance(obj, dict):
227
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
228
+
229
+ _obj = cls.model_validate({
230
+ "batch_id": obj.get("batch_id"),
231
+ "data_requests": [SubmissionDataRequest.from_dict(_item) for _item in obj["data_requests"]] if obj.get("data_requests") is not None else None,
232
+ "editable": obj.get("editable"),
233
+ "error_message": obj.get("error_message"),
234
+ "expired": obj.get("expired"),
235
+ "expires_at": obj.get("expires_at"),
236
+ "id": obj.get("id"),
237
+ "json_schema_errors": obj.get("json_schema_errors"),
238
+ "metadata": obj.get("metadata"),
239
+ "password": obj.get("password"),
240
+ "processed_at": obj.get("processed_at"),
241
+ "state": obj.get("state"),
242
+ "template_id": obj.get("template_id"),
243
+ "template_type": obj.get("template_type"),
244
+ "template_version": obj.get("template_version"),
245
+ "test": obj.get("test"),
246
+ "truncated_text": obj.get("truncated_text"),
247
+ "pdf_hash": obj.get("pdf_hash"),
248
+ "download_url": obj.get("download_url"),
249
+ "permanent_download_url": obj.get("permanent_download_url"),
250
+ "preview_download_url": obj.get("preview_download_url"),
251
+ "preview_generated_at": obj.get("preview_generated_at"),
252
+ "audit_trail_download_url": obj.get("audit_trail_download_url"),
253
+ "actions": [SubmissionAction.from_dict(_item) for _item in obj["actions"]] if obj.get("actions") is not None else None
254
+ }, context={"skip_enum_validation": True})
255
+ return _obj
256
+
257
+