@@ -228,6 +228,51 @@ impl Entry {
228228 }
229229}
230230
231+ #[ cfg( not( feature = "python" ) ) ]
232+ #[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
233+ #[ serde( rename_all = "camelCase" ) ]
234+ pub struct Comment {
235+ #[ serde( alias = "id" ) ]
236+ pub comment_id : String ,
237+ pub value : Option < Value > ,
238+ }
239+
240+ #[ cfg( feature = "python" ) ]
241+ #[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
242+ #[ serde( rename_all = "camelCase" ) ]
243+ #[ pyclass( get_all) ]
244+ pub struct Comment {
245+ #[ serde( alias = "id" ) ]
246+ pub comment_id : String ,
247+ pub value : Option < Value > ,
248+ }
249+
250+ #[ cfg( feature = "python" ) ]
251+ #[ pymethods]
252+ impl Comment {
253+ #[ getter]
254+ fn comment_id ( & self ) -> PyResult < String > {
255+ Ok ( self . comment_id . clone ( ) )
256+ }
257+
258+ #[ getter]
259+ fn value ( & self ) -> PyResult < Option < Value > > {
260+ Ok ( self . value . clone ( ) )
261+ }
262+
263+ pub fn to_dict < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyDict > > {
264+ let dict = PyDict :: new_bound ( py) ;
265+ dict. set_item ( "comment_id" , & self . comment_id ) ?;
266+ if let Some ( value) = & self . value {
267+ dict. set_item ( "value" , value. to_dict ( py) ?) ?;
268+ } else {
269+ dict. set_item ( "value" , py. None ( ) ) ?;
270+ }
271+
272+ Ok ( dict)
273+ }
274+ }
275+
231276#[ cfg( not( feature = "python" ) ) ]
232277#[ derive( Clone , Debug , Deserialize , Serialize , PartialEq ) ]
233278#[ serde( rename_all = "camelCase" ) ]
@@ -248,6 +293,9 @@ pub struct Field {
248293
249294 #[ serde( alias = "entry" ) ]
250295 pub entries : Option < Vec < Entry > > ,
296+
297+ #[ serde( alias = "comment" ) ]
298+ pub comments : Option < Vec < Comment > > ,
251299}
252300
253301#[ cfg( feature = "python" ) ]
@@ -272,6 +320,9 @@ pub struct Field {
272320
273321 #[ serde( alias = "entry" ) ]
274322 pub entries : Option < Vec < Entry > > ,
323+
324+ #[ serde( alias = "comment" ) ]
325+ pub comments : Option < Vec < Comment > > ,
275326}
276327
277328#[ cfg( feature = "python" ) ]
@@ -312,6 +363,11 @@ impl Field {
312363 Ok ( self . entries . clone ( ) )
313364 }
314365
366+ #[ getter]
367+ fn comments ( & self ) -> PyResult < Option < Vec < Comment > > > {
368+ Ok ( self . comments . clone ( ) )
369+ }
370+
315371 pub fn to_dict < ' py > ( & self , py : Python < ' py > ) -> PyResult < Bound < ' py , PyDict > > {
316372 let dict = PyDict :: new_bound ( py) ;
317373 dict. set_item ( "name" , & self . name ) ?;
@@ -332,6 +388,17 @@ impl Field {
332388 dict. set_item ( "entries" , py. None ( ) ) ?;
333389 }
334390
391+ let mut comment_dicts = Vec :: new ( ) ;
392+ if let Some ( comments) = & self . comments {
393+ for comment in comments {
394+ let comment_dict = comment. to_dict ( py) ?;
395+ comment_dicts. push ( comment_dict. to_object ( py) ) ;
396+ }
397+ dict. set_item ( "comments" , comment_dicts) ?;
398+ } else {
399+ dict. set_item ( "comments" , py. None ( ) ) ?;
400+ }
401+
335402 Ok ( dict)
336403 }
337404}
0 commit comments