1+ import datetime
2+ import json
13from collections .abc import Mapping
24from io import BytesIO
3- from typing import Any , TypeVar , Union
5+ from typing import TYPE_CHECKING , Any , TypeVar
46
57from attrs import define as _attrs_define
68from attrs import field as _attrs_field
9+ from dateutil .parser import isoparse
10+
11+ from ..types import File
12+
13+ if TYPE_CHECKING :
14+ from ..models .an_object import AnObject
715
8- from ..types import UNSET , File , Unset
916
1017T = TypeVar ("T" , bound = "PostBodyMultipartBody" )
1118
@@ -15,46 +22,77 @@ class PostBodyMultipartBody:
1522 """
1623 Attributes:
1724 a_string (str):
18- file (File): For the sake of this test, include a file name and content type. The payload should also be valid
19- UTF-8.
20- description (Union[Unset, str]):
25+ files (list[File]):
26+ description (str):
27+ objects (list['AnObject']):
28+ times (list[datetime.datetime]):
2129 """
2230
2331 a_string : str
24- file : File
25- description : Union [Unset , str ] = UNSET
32+ files : list [File ]
33+ description : str
34+ objects : list ["AnObject" ]
35+ times : list [datetime .datetime ]
2636 additional_properties : dict [str , Any ] = _attrs_field (init = False , factory = dict )
2737
2838 def to_dict (self ) -> dict [str , Any ]:
2939 a_string = self .a_string
3040
31- file = self .file .to_tuple ()
41+ files = []
42+ for files_item_data in self .files :
43+ files_item = files_item_data .to_tuple ()
44+
45+ files .append (files_item )
3246
3347 description = self .description
3448
49+ objects = []
50+ for objects_item_data in self .objects :
51+ objects_item = objects_item_data .to_dict ()
52+ objects .append (objects_item )
53+
54+ times = []
55+ for times_item_data in self .times :
56+ times_item = times_item_data .isoformat ()
57+ times .append (times_item )
58+
3559 field_dict : dict [str , Any ] = {}
3660 field_dict .update (self .additional_properties )
3761 field_dict .update (
3862 {
3963 "a_string" : a_string ,
40- "file" : file ,
64+ "files" : files ,
65+ "description" : description ,
66+ "objects" : objects ,
67+ "times" : times ,
4168 }
4269 )
43- if description is not UNSET :
44- field_dict ["description" ] = description
4570
4671 return field_dict
4772
4873 def to_multipart (self ) -> dict [str , Any ]:
4974 a_string = (None , str (self .a_string ).encode (), "text/plain" )
5075
51- file = self .file .to_tuple ()
76+ _temp_files = []
77+ for files_item_data in self .files :
78+ files_item = files_item_data .to_tuple ()
5279
53- description = (
54- self .description
55- if isinstance (self .description , Unset )
56- else (None , str (self .description ).encode (), "text/plain" )
57- )
80+ _temp_files .append (files_item )
81+ files = (None , json .dumps (_temp_files ).encode (), "application/json" )
82+
83+ description = (None , str (self .description ).encode (), "text/plain" )
84+
85+ _temp_objects = []
86+ for objects_item_data in self .objects :
87+ objects_item = objects_item_data .to_dict ()
88+ _temp_objects .append (objects_item )
89+ objects = (None , json .dumps (_temp_objects ).encode (), "application/json" )
90+
91+ _temp_times = []
92+ for times_item_data in self .times :
93+ times_item = times_item_data .isoformat ()
94+ _temp_times .append (times_item )
95+ times = (None , json .dumps (_temp_times ).encode (), "application/json" )
5896
5997 field_dict : dict [str , Any ] = {}
6098 for prop_name , prop in self .additional_properties .items ():
@@ -63,27 +101,51 @@ def to_multipart(self) -> dict[str, Any]:
63101 field_dict .update (
64102 {
65103 "a_string" : a_string ,
66- "file" : file ,
104+ "files" : files ,
105+ "description" : description ,
106+ "objects" : objects ,
107+ "times" : times ,
67108 }
68109 )
69- if description is not UNSET :
70- field_dict ["description" ] = description
71110
72111 return field_dict
73112
74113 @classmethod
75114 def from_dict (cls : type [T ], src_dict : Mapping [str , Any ]) -> T :
115+ from ..models .an_object import AnObject
116+
76117 d = dict (src_dict )
77118 a_string = d .pop ("a_string" )
78119
79- file = File (payload = BytesIO (d .pop ("file" )))
120+ files = []
121+ _files = d .pop ("files" )
122+ for files_item_data in _files :
123+ files_item = File (payload = BytesIO (files_item_data ))
124+
125+ files .append (files_item )
126+
127+ description = d .pop ("description" )
128+
129+ objects = []
130+ _objects = d .pop ("objects" )
131+ for objects_item_data in _objects :
132+ objects_item = AnObject .from_dict (objects_item_data )
133+
134+ objects .append (objects_item )
135+
136+ times = []
137+ _times = d .pop ("times" )
138+ for times_item_data in _times :
139+ times_item = isoparse (times_item_data )
80140
81- description = d . pop ( "description" , UNSET )
141+ times . append ( times_item )
82142
83143 post_body_multipart_body = cls (
84144 a_string = a_string ,
85- file = file ,
145+ files = files ,
86146 description = description ,
147+ objects = objects ,
148+ times = times ,
87149 )
88150
89151 post_body_multipart_body .additional_properties = d
0 commit comments