1
1
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
3
3
from __future__ import annotations
4
- from gusto_app_integration .types import BaseModel
4
+ from gusto_app_integration .types import (
5
+ BaseModel ,
6
+ Nullable ,
7
+ OptionalNullable ,
8
+ UNSET ,
9
+ UNSET_SENTINEL ,
10
+ )
5
11
import pydantic
6
- from pydantic import ConfigDict
12
+ from pydantic import ConfigDict , model_serializer
7
13
from typing import Any , Dict , Optional
8
14
from typing_extensions import NotRequired , TypedDict
9
15
@@ -15,10 +21,10 @@ class MetadataWithOneEntityTypedDict(TypedDict):
15
21
r"""Name of the entity that the error corresponds to."""
16
22
entity_uuid : NotRequired [str ]
17
23
r"""Unique identifier for the entity."""
18
- valid_from : NotRequired [str ]
19
- valid_up_to : NotRequired [str ]
20
- key : NotRequired [str ]
21
- state : NotRequired [str ]
24
+ valid_from : NotRequired [Nullable [ str ] ]
25
+ valid_up_to : NotRequired [Nullable [ str ] ]
26
+ key : NotRequired [Nullable [ str ] ]
27
+ state : NotRequired [Nullable [ str ] ]
22
28
23
29
24
30
class MetadataWithOneEntity (BaseModel ):
@@ -35,13 +41,13 @@ class MetadataWithOneEntity(BaseModel):
35
41
entity_uuid : Optional [str ] = None
36
42
r"""Unique identifier for the entity."""
37
43
38
- valid_from : Optional [str ] = None
44
+ valid_from : OptionalNullable [str ] = UNSET
39
45
40
- valid_up_to : Optional [str ] = None
46
+ valid_up_to : OptionalNullable [str ] = UNSET
41
47
42
- key : Optional [str ] = None
48
+ key : OptionalNullable [str ] = UNSET
43
49
44
- state : Optional [str ] = None
50
+ state : OptionalNullable [str ] = UNSET
45
51
46
52
@property
47
53
def additional_properties (self ):
@@ -50,3 +56,43 @@ def additional_properties(self):
50
56
@additional_properties .setter
51
57
def additional_properties (self , value ):
52
58
self .__pydantic_extra__ = value # pyright: ignore[reportIncompatibleVariableOverride]
59
+
60
+ @model_serializer (mode = "wrap" )
61
+ def serialize_model (self , handler ):
62
+ optional_fields = [
63
+ "entity_type" ,
64
+ "entity_uuid" ,
65
+ "valid_from" ,
66
+ "valid_up_to" ,
67
+ "key" ,
68
+ "state" ,
69
+ ]
70
+ nullable_fields = ["valid_from" , "valid_up_to" , "key" , "state" ]
71
+ null_default_fields = []
72
+
73
+ serialized = handler (self )
74
+
75
+ m = {}
76
+
77
+ for n , f in self .model_fields .items ():
78
+ k = f .alias or n
79
+ val = serialized .get (k )
80
+ serialized .pop (k , None )
81
+
82
+ optional_nullable = k in optional_fields and k in nullable_fields
83
+ is_set = (
84
+ self .__pydantic_fields_set__ .intersection ({n })
85
+ or k in null_default_fields
86
+ ) # pylint: disable=no-member
87
+
88
+ if val is not None and val != UNSET_SENTINEL :
89
+ m [k ] = val
90
+ elif val != UNSET_SENTINEL and (
91
+ not k in optional_fields or (optional_nullable and is_set )
92
+ ):
93
+ m [k ] = val
94
+
95
+ for k , v in serialized .items ():
96
+ m [k ] = v
97
+
98
+ return m
0 commit comments