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,107 @@
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, ValidationInfo, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from docspring.models.custom_file import CustomFile
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class CreateCustomFileResponse(BaseModel):
28
+ """
29
+ CreateCustomFileResponse
30
+ """ # noqa: E501
31
+ status: StrictStr
32
+ custom_file: CustomFile
33
+ errors: Optional[List[StrictStr]] = None
34
+ __properties: ClassVar[List[str]] = ["status", "custom_file", "errors"]
35
+
36
+ @field_validator('status')
37
+ def status_validate_enum(cls, value, info: ValidationInfo):
38
+ """Validates the enum"""
39
+ # from_dict accepts enum values this client doesn't know about yet
40
+ if info.context and info.context.get("skip_enum_validation"):
41
+ return value
42
+
43
+ if value not in set(['success', 'error']):
44
+ raise ValueError("must be one of enum values ('success', 'error')")
45
+ return value
46
+
47
+ model_config = ConfigDict(
48
+ populate_by_name=True,
49
+ validate_assignment=True,
50
+ protected_namespaces=(),
51
+ )
52
+
53
+
54
+ def to_str(self) -> str:
55
+ """Returns the string representation of the model using alias"""
56
+ return pprint.pformat(self.model_dump(by_alias=True))
57
+
58
+ def to_json(self) -> str:
59
+ """Returns the JSON representation of the model using alias"""
60
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
61
+ return json.dumps(self.to_dict())
62
+
63
+ @classmethod
64
+ def from_json(cls, json_str: str) -> Optional[Self]:
65
+ """Create an instance of CreateCustomFileResponse from a JSON string"""
66
+ return cls.from_dict(json.loads(json_str))
67
+
68
+ def to_dict(self) -> Dict[str, Any]:
69
+ """Return the dictionary representation of the model using alias.
70
+
71
+ This has the following differences from calling pydantic's
72
+ `self.model_dump(by_alias=True)`:
73
+
74
+ * `None` is only added to the output dict for nullable fields that
75
+ were set at model initialization. Other fields with value `None`
76
+ are ignored.
77
+ """
78
+ excluded_fields: Set[str] = set([
79
+ ])
80
+
81
+ _dict = self.model_dump(
82
+ by_alias=True,
83
+ exclude=excluded_fields,
84
+ exclude_none=True,
85
+ )
86
+ # override the default output from pydantic by calling `to_dict()` of custom_file
87
+ if self.custom_file:
88
+ _dict['custom_file'] = self.custom_file.to_dict()
89
+ return _dict
90
+
91
+ @classmethod
92
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
93
+ """Create an instance of CreateCustomFileResponse from a dict"""
94
+ if obj is None:
95
+ return None
96
+
97
+ if not isinstance(obj, dict):
98
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
99
+
100
+ _obj = cls.model_validate({
101
+ "status": obj.get("status"),
102
+ "custom_file": CustomFile.from_dict(obj["custom_file"]) if obj.get("custom_file") is not None else None,
103
+ "errors": obj.get("errors")
104
+ }, context={"skip_enum_validation": True})
105
+ return _obj
106
+
107
+
@@ -0,0 +1,88 @@
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class CreateFolderData(BaseModel):
27
+ """
28
+ CreateFolderData
29
+ """ # noqa: E501
30
+ folder: Dict[str, Any]
31
+ __properties: ClassVar[List[str]] = ["folder"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of CreateFolderData from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of CreateFolderData from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
82
+
83
+ _obj = cls.model_validate({
84
+ "folder": obj.get("folder")
85
+ }, context={"skip_enum_validation": True})
86
+ return _obj
87
+
88
+
@@ -0,0 +1,88 @@
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class CreateHtmlTemplate(BaseModel):
27
+ """
28
+ CreateHtmlTemplate
29
+ """ # noqa: E501
30
+ template: Dict[str, Any]
31
+ __properties: ClassVar[List[str]] = ["template"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of CreateHtmlTemplate from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of CreateHtmlTemplate from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
82
+
83
+ _obj = cls.model_validate({
84
+ "template": obj.get("template")
85
+ }, context={"skip_enum_validation": True})
86
+ return _obj
87
+
88
+
@@ -0,0 +1,112 @@
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, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from docspring.models.create_submission_data_request_data import CreateSubmissionDataRequestData
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class CreatePdfSubmissionData(BaseModel):
28
+ """
29
+ CreatePdfSubmissionData
30
+ """ # noqa: E501
31
+ data: Dict[str, Any]
32
+ data_requests: Optional[List[CreateSubmissionDataRequestData]] = None
33
+ editable: Optional[StrictBool] = None
34
+ expires_in: Optional[StrictInt] = None
35
+ field_overrides: Optional[Dict[str, Any]] = None
36
+ metadata: Optional[Dict[str, Any]] = None
37
+ password: Optional[StrictStr] = None
38
+ test: Optional[StrictBool] = None
39
+ version: Optional[StrictStr] = None
40
+ __properties: ClassVar[List[str]] = ["data", "data_requests", "editable", "expires_in", "field_overrides", "metadata", "password", "test", "version"]
41
+
42
+ model_config = ConfigDict(
43
+ populate_by_name=True,
44
+ validate_assignment=True,
45
+ protected_namespaces=(),
46
+ )
47
+
48
+
49
+ def to_str(self) -> str:
50
+ """Returns the string representation of the model using alias"""
51
+ return pprint.pformat(self.model_dump(by_alias=True))
52
+
53
+ def to_json(self) -> str:
54
+ """Returns the JSON representation of the model using alias"""
55
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
56
+ return json.dumps(self.to_dict())
57
+
58
+ @classmethod
59
+ def from_json(cls, json_str: str) -> Optional[Self]:
60
+ """Create an instance of CreatePdfSubmissionData from a JSON string"""
61
+ return cls.from_dict(json.loads(json_str))
62
+
63
+ def to_dict(self) -> Dict[str, Any]:
64
+ """Return the dictionary representation of the model using alias.
65
+
66
+ This has the following differences from calling pydantic's
67
+ `self.model_dump(by_alias=True)`:
68
+
69
+ * `None` is only added to the output dict for nullable fields that
70
+ were set at model initialization. Other fields with value `None`
71
+ are ignored.
72
+ """
73
+ excluded_fields: Set[str] = set([
74
+ ])
75
+
76
+ _dict = self.model_dump(
77
+ by_alias=True,
78
+ exclude=excluded_fields,
79
+ exclude_none=True,
80
+ )
81
+ # override the default output from pydantic by calling `to_dict()` of each item in data_requests (list)
82
+ _items = []
83
+ if self.data_requests:
84
+ for _item_data_requests in self.data_requests:
85
+ if _item_data_requests:
86
+ _items.append(_item_data_requests.to_dict())
87
+ _dict['data_requests'] = _items
88
+ return _dict
89
+
90
+ @classmethod
91
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
92
+ """Create an instance of CreatePdfSubmissionData from a dict"""
93
+ if obj is None:
94
+ return None
95
+
96
+ if not isinstance(obj, dict):
97
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
98
+
99
+ _obj = cls.model_validate({
100
+ "data": obj.get("data"),
101
+ "data_requests": [CreateSubmissionDataRequestData.from_dict(_item) for _item in obj["data_requests"]] if obj.get("data_requests") is not None else None,
102
+ "editable": obj.get("editable"),
103
+ "expires_in": obj.get("expires_in"),
104
+ "field_overrides": obj.get("field_overrides"),
105
+ "metadata": obj.get("metadata"),
106
+ "password": obj.get("password"),
107
+ "test": obj.get("test"),
108
+ "version": obj.get("version")
109
+ }, context={"skip_enum_validation": True})
110
+ return _obj
111
+
112
+
@@ -0,0 +1,88 @@
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
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class CreatePdfTemplate(BaseModel):
27
+ """
28
+ CreatePdfTemplate
29
+ """ # noqa: E501
30
+ template: Dict[str, Any]
31
+ __properties: ClassVar[List[str]] = ["template"]
32
+
33
+ model_config = ConfigDict(
34
+ populate_by_name=True,
35
+ validate_assignment=True,
36
+ protected_namespaces=(),
37
+ )
38
+
39
+
40
+ def to_str(self) -> str:
41
+ """Returns the string representation of the model using alias"""
42
+ return pprint.pformat(self.model_dump(by_alias=True))
43
+
44
+ def to_json(self) -> str:
45
+ """Returns the JSON representation of the model using alias"""
46
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
47
+ return json.dumps(self.to_dict())
48
+
49
+ @classmethod
50
+ def from_json(cls, json_str: str) -> Optional[Self]:
51
+ """Create an instance of CreatePdfTemplate from a JSON string"""
52
+ return cls.from_dict(json.loads(json_str))
53
+
54
+ def to_dict(self) -> Dict[str, Any]:
55
+ """Return the dictionary representation of the model using alias.
56
+
57
+ This has the following differences from calling pydantic's
58
+ `self.model_dump(by_alias=True)`:
59
+
60
+ * `None` is only added to the output dict for nullable fields that
61
+ were set at model initialization. Other fields with value `None`
62
+ are ignored.
63
+ """
64
+ excluded_fields: Set[str] = set([
65
+ ])
66
+
67
+ _dict = self.model_dump(
68
+ by_alias=True,
69
+ exclude=excluded_fields,
70
+ exclude_none=True,
71
+ )
72
+ return _dict
73
+
74
+ @classmethod
75
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
76
+ """Create an instance of CreatePdfTemplate from a dict"""
77
+ if obj is None:
78
+ return None
79
+
80
+ if not isinstance(obj, dict):
81
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
82
+
83
+ _obj = cls.model_validate({
84
+ "template": obj.get("template")
85
+ }, context={"skip_enum_validation": True})
86
+ return _obj
87
+
88
+
@@ -0,0 +1,187 @@
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, 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 CreateSubmissionDataRequestData(BaseModel):
27
+ """
28
+ CreateSubmissionDataRequestData
29
+ """ # noqa: E501
30
+ auth_phone_number_hash: Optional[StrictStr] = None
31
+ auth_provider: Optional[StrictStr] = None
32
+ auth_second_factor_type: Optional[StrictStr] = None
33
+ auth_session_id_hash: Optional[StrictStr] = None
34
+ auth_session_started_at: Optional[StrictStr] = None
35
+ auth_type: Optional[StrictStr] = None
36
+ auth_user_id_hash: Optional[StrictStr] = None
37
+ auth_username_hash: Optional[StrictStr] = None
38
+ email: Optional[StrictStr] = None
39
+ fields: Optional[List[Optional[StrictStr]]] = None
40
+ metadata: Optional[Dict[str, Any]] = None
41
+ name: Optional[StrictStr] = None
42
+ order: Optional[StrictInt] = None
43
+ skipped: Optional[StrictBool] = None
44
+ __properties: ClassVar[List[str]] = ["auth_phone_number_hash", "auth_provider", "auth_second_factor_type", "auth_session_id_hash", "auth_session_started_at", "auth_type", "auth_user_id_hash", "auth_username_hash", "email", "fields", "metadata", "name", "order", "skipped"]
45
+
46
+ @field_validator('auth_second_factor_type')
47
+ def auth_second_factor_type_validate_enum(cls, value, info: ValidationInfo):
48
+ """Validates the enum"""
49
+ # from_dict accepts enum values this client doesn't know about yet
50
+ if info.context and info.context.get("skip_enum_validation"):
51
+ return value
52
+
53
+ if value is None:
54
+ return value
55
+
56
+ if value not in set(['none', 'phone_number', 'totp', 'mobile_push', 'security_key', 'fingerprint']):
57
+ raise ValueError("must be one of enum values ('none', 'phone_number', 'totp', 'mobile_push', 'security_key', 'fingerprint')")
58
+ return value
59
+
60
+ @field_validator('auth_type')
61
+ def auth_type_validate_enum(cls, value, info: ValidationInfo):
62
+ """Validates the enum"""
63
+ # from_dict accepts enum values this client doesn't know about yet
64
+ if info.context and info.context.get("skip_enum_validation"):
65
+ return value
66
+
67
+ if value is None:
68
+ return value
69
+
70
+ if value not in set(['none', 'password', 'oauth', 'email_link', 'phone_number', 'ldap', 'saml']):
71
+ raise ValueError("must be one of enum values ('none', 'password', 'oauth', 'email_link', 'phone_number', 'ldap', 'saml')")
72
+ return value
73
+
74
+ model_config = ConfigDict(
75
+ populate_by_name=True,
76
+ validate_assignment=True,
77
+ protected_namespaces=(),
78
+ )
79
+
80
+
81
+ def to_str(self) -> str:
82
+ """Returns the string representation of the model using alias"""
83
+ return pprint.pformat(self.model_dump(by_alias=True))
84
+
85
+ def to_json(self) -> str:
86
+ """Returns the JSON representation of the model using alias"""
87
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
88
+ return json.dumps(self.to_dict())
89
+
90
+ @classmethod
91
+ def from_json(cls, json_str: str) -> Optional[Self]:
92
+ """Create an instance of CreateSubmissionDataRequestData from a JSON string"""
93
+ return cls.from_dict(json.loads(json_str))
94
+
95
+ def to_dict(self) -> Dict[str, Any]:
96
+ """Return the dictionary representation of the model using alias.
97
+
98
+ This has the following differences from calling pydantic's
99
+ `self.model_dump(by_alias=True)`:
100
+
101
+ * `None` is only added to the output dict for nullable fields that
102
+ were set at model initialization. Other fields with value `None`
103
+ are ignored.
104
+ """
105
+ excluded_fields: Set[str] = set([
106
+ ])
107
+
108
+ _dict = self.model_dump(
109
+ by_alias=True,
110
+ exclude=excluded_fields,
111
+ exclude_none=True,
112
+ )
113
+ # set to None if auth_phone_number_hash (nullable) is None
114
+ # and model_fields_set contains the field
115
+ if self.auth_phone_number_hash is None and "auth_phone_number_hash" in self.model_fields_set:
116
+ _dict['auth_phone_number_hash'] = None
117
+
118
+ # set to None if auth_provider (nullable) is None
119
+ # and model_fields_set contains the field
120
+ if self.auth_provider is None and "auth_provider" in self.model_fields_set:
121
+ _dict['auth_provider'] = None
122
+
123
+ # set to None if auth_session_id_hash (nullable) is None
124
+ # and model_fields_set contains the field
125
+ if self.auth_session_id_hash is None and "auth_session_id_hash" in self.model_fields_set:
126
+ _dict['auth_session_id_hash'] = None
127
+
128
+ # set to None if auth_session_started_at (nullable) is None
129
+ # and model_fields_set contains the field
130
+ if self.auth_session_started_at is None and "auth_session_started_at" in self.model_fields_set:
131
+ _dict['auth_session_started_at'] = None
132
+
133
+ # set to None if auth_user_id_hash (nullable) is None
134
+ # and model_fields_set contains the field
135
+ if self.auth_user_id_hash is None and "auth_user_id_hash" in self.model_fields_set:
136
+ _dict['auth_user_id_hash'] = None
137
+
138
+ # set to None if auth_username_hash (nullable) is None
139
+ # and model_fields_set contains the field
140
+ if self.auth_username_hash is None and "auth_username_hash" in self.model_fields_set:
141
+ _dict['auth_username_hash'] = None
142
+
143
+ # set to None if email (nullable) is None
144
+ # and model_fields_set contains the field
145
+ if self.email is None and "email" in self.model_fields_set:
146
+ _dict['email'] = None
147
+
148
+ # set to None if name (nullable) is None
149
+ # and model_fields_set contains the field
150
+ if self.name is None and "name" in self.model_fields_set:
151
+ _dict['name'] = None
152
+
153
+ # set to None if skipped (nullable) is None
154
+ # and model_fields_set contains the field
155
+ if self.skipped is None and "skipped" in self.model_fields_set:
156
+ _dict['skipped'] = None
157
+
158
+ return _dict
159
+
160
+ @classmethod
161
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
162
+ """Create an instance of CreateSubmissionDataRequestData from a dict"""
163
+ if obj is None:
164
+ return None
165
+
166
+ if not isinstance(obj, dict):
167
+ return cls.model_validate(obj, context={"skip_enum_validation": True})
168
+
169
+ _obj = cls.model_validate({
170
+ "auth_phone_number_hash": obj.get("auth_phone_number_hash"),
171
+ "auth_provider": obj.get("auth_provider"),
172
+ "auth_second_factor_type": obj.get("auth_second_factor_type"),
173
+ "auth_session_id_hash": obj.get("auth_session_id_hash"),
174
+ "auth_session_started_at": obj.get("auth_session_started_at"),
175
+ "auth_type": obj.get("auth_type"),
176
+ "auth_user_id_hash": obj.get("auth_user_id_hash"),
177
+ "auth_username_hash": obj.get("auth_username_hash"),
178
+ "email": obj.get("email"),
179
+ "fields": obj.get("fields"),
180
+ "metadata": obj.get("metadata"),
181
+ "name": obj.get("name"),
182
+ "order": obj.get("order"),
183
+ "skipped": obj.get("skipped")
184
+ }, context={"skip_enum_validation": True})
185
+ return _obj
186
+
187
+