twitter-openapi-python-generated 0.0.28__py3-none-any.whl → 0.0.30__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 (30) hide show
  1. twitter_openapi_python_generated/__init__.py +10 -1
  2. twitter_openapi_python_generated/api/default_api.py +0 -335
  3. twitter_openapi_python_generated/api_client.py +2 -2
  4. twitter_openapi_python_generated/configuration.py +10 -3
  5. twitter_openapi_python_generated/exceptions.py +17 -0
  6. twitter_openapi_python_generated/models/__init__.py +9 -0
  7. twitter_openapi_python_generated/models/content_item_type.py +1 -0
  8. twitter_openapi_python_generated/models/feedback_info.py +7 -1
  9. twitter_openapi_python_generated/models/item_content_union.py +46 -8
  10. twitter_openapi_python_generated/models/module_item.py +5 -3
  11. twitter_openapi_python_generated/models/thumbnail_image.py +92 -0
  12. twitter_openapi_python_generated/models/timeline_timeline_module.py +6 -2
  13. twitter_openapi_python_generated/models/timeline_tombstone.py +110 -0
  14. twitter_openapi_python_generated/models/timeline_trend.py +130 -0
  15. twitter_openapi_python_generated/models/tombstone_entity.py +96 -0
  16. twitter_openapi_python_generated/models/tombstone_info.py +94 -0
  17. twitter_openapi_python_generated/models/tombstone_ref.py +112 -0
  18. twitter_openapi_python_generated/models/tombstone_rich_text.py +100 -0
  19. twitter_openapi_python_generated/models/trend_image.py +88 -0
  20. twitter_openapi_python_generated/models/trend_metadata.py +92 -0
  21. twitter_openapi_python_generated/models/tweet.py +3 -1
  22. twitter_openapi_python_generated/models/type_name.py +1 -0
  23. twitter_openapi_python_generated/models/user.py +13 -1
  24. twitter_openapi_python_generated/rest.py +1 -0
  25. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/METADATA +1 -1
  26. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/RECORD +30 -21
  27. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/LICENSE +0 -0
  28. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/LICENSE.AGPL +0 -0
  29. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/WHEEL +0 -0
  30. {twitter_openapi_python_generated-0.0.28.dist-info → twitter_openapi_python_generated-0.0.30.dist-info}/top_level.txt +0 -0
@@ -18,8 +18,8 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
- from pydantic import BaseModel, ConfigDict, Field, field_validator
22
- from typing import Any, ClassVar, Dict, List
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
23
  from typing_extensions import Annotated
24
24
  from twitter_openapi_python_generated.models.module_entry import ModuleEntry
25
25
  from typing import Optional, Set
@@ -29,9 +29,10 @@ class ModuleItem(BaseModel):
29
29
  """
30
30
  ModuleItem
31
31
  """ # noqa: E501
32
+ dispensable: Optional[StrictBool] = None
32
33
  entry_id: Annotated[str, Field(strict=True)] = Field(alias="entryId")
33
34
  item: ModuleEntry
34
- __properties: ClassVar[List[str]] = ["entryId", "item"]
35
+ __properties: ClassVar[List[str]] = ["dispensable", "entryId", "item"]
35
36
 
36
37
  @field_validator('entry_id')
37
38
  def entry_id_validate_regular_expression(cls, value):
@@ -94,6 +95,7 @@ class ModuleItem(BaseModel):
94
95
  return cls.model_validate(obj)
95
96
 
96
97
  _obj = cls.model_validate({
98
+ "dispensable": obj.get("dispensable"),
97
99
  "entryId": obj.get("entryId"),
98
100
  "item": ModuleEntry.from_dict(obj["item"]) if obj.get("item") is not None else None
99
101
  })
@@ -0,0 +1,92 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.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
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class ThumbnailImage(BaseModel):
27
+ """
28
+ ThumbnailImage
29
+ """ # noqa: E501
30
+ original_img_height: Optional[StrictInt] = None
31
+ original_img_url: Optional[StrictStr] = None
32
+ original_img_width: Optional[StrictInt] = None
33
+ __properties: ClassVar[List[str]] = ["original_img_height", "original_img_url", "original_img_width"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of ThumbnailImage from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ return _dict
75
+
76
+ @classmethod
77
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
78
+ """Create an instance of ThumbnailImage from a dict"""
79
+ if obj is None:
80
+ return None
81
+
82
+ if not isinstance(obj, dict):
83
+ return cls.model_validate(obj)
84
+
85
+ _obj = cls.model_validate({
86
+ "original_img_height": obj.get("original_img_height"),
87
+ "original_img_url": obj.get("original_img_url"),
88
+ "original_img_width": obj.get("original_img_width")
89
+ })
90
+ return _obj
91
+
92
+
@@ -20,6 +20,7 @@ import json
20
20
 
21
21
  from pydantic import BaseModel, ConfigDict, Field, StrictStr
22
22
  from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.client_event_info import ClientEventInfo
23
24
  from twitter_openapi_python_generated.models.content_entry_type import ContentEntryType
24
25
  from twitter_openapi_python_generated.models.display_type import DisplayType
25
26
  from twitter_openapi_python_generated.models.feedback_info import FeedbackInfo
@@ -32,7 +33,7 @@ class TimelineTimelineModule(BaseModel):
32
33
  TimelineTimelineModule
33
34
  """ # noqa: E501
34
35
  typename: StrictStr = Field(alias="__typename")
35
- client_event_info: Dict[str, Any] = Field(alias="clientEventInfo")
36
+ client_event_info: ClientEventInfo = Field(alias="clientEventInfo")
36
37
  display_type: DisplayType = Field(alias="displayType")
37
38
  entry_type: ContentEntryType = Field(alias="entryType")
38
39
  feedback_info: Optional[FeedbackInfo] = Field(default=None, alias="feedbackInfo")
@@ -81,6 +82,9 @@ class TimelineTimelineModule(BaseModel):
81
82
  exclude=excluded_fields,
82
83
  exclude_none=True,
83
84
  )
85
+ # override the default output from pydantic by calling `to_dict()` of client_event_info
86
+ if self.client_event_info:
87
+ _dict['clientEventInfo'] = self.client_event_info.to_dict()
84
88
  # override the default output from pydantic by calling `to_dict()` of feedback_info
85
89
  if self.feedback_info:
86
90
  _dict['feedbackInfo'] = self.feedback_info.to_dict()
@@ -104,7 +108,7 @@ class TimelineTimelineModule(BaseModel):
104
108
 
105
109
  _obj = cls.model_validate({
106
110
  "__typename": obj.get("__typename"),
107
- "clientEventInfo": obj.get("clientEventInfo"),
111
+ "clientEventInfo": ClientEventInfo.from_dict(obj["clientEventInfo"]) if obj.get("clientEventInfo") is not None else None,
108
112
  "displayType": obj.get("displayType"),
109
113
  "entryType": obj.get("entryType"),
110
114
  "feedbackInfo": FeedbackInfo.from_dict(obj["feedbackInfo"]) if obj.get("feedbackInfo") is not None else None,
@@ -0,0 +1,110 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.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, Field, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.content_item_type import ContentItemType
24
+ from twitter_openapi_python_generated.models.tombstone_info import TombstoneInfo
25
+ from twitter_openapi_python_generated.models.type_name import TypeName
26
+ from typing import Optional, Set
27
+ from typing_extensions import Self
28
+
29
+ class TimelineTombstone(BaseModel):
30
+ """
31
+ TimelineTombstone
32
+ """ # noqa: E501
33
+ typename: Optional[TypeName] = Field(default=None, alias="__typename")
34
+ item_type: Optional[ContentItemType] = Field(default=None, alias="itemType")
35
+ tombstone_display_type: Optional[StrictStr] = Field(default=None, alias="tombstoneDisplayType")
36
+ tombstone_info: Optional[TombstoneInfo] = Field(default=None, alias="tombstoneInfo")
37
+ __properties: ClassVar[List[str]] = ["__typename", "itemType", "tombstoneDisplayType", "tombstoneInfo"]
38
+
39
+ @field_validator('tombstone_display_type')
40
+ def tombstone_display_type_validate_enum(cls, value):
41
+ """Validates the enum"""
42
+ if value is None:
43
+ return value
44
+
45
+ if value not in set(['Inline']):
46
+ raise ValueError("must be one of enum values ('Inline')")
47
+ return value
48
+
49
+ model_config = ConfigDict(
50
+ populate_by_name=True,
51
+ validate_assignment=True,
52
+ protected_namespaces=(),
53
+ )
54
+
55
+
56
+ def to_str(self) -> str:
57
+ """Returns the string representation of the model using alias"""
58
+ return pprint.pformat(self.model_dump(by_alias=True))
59
+
60
+ def to_json(self) -> str:
61
+ """Returns the JSON representation of the model using alias"""
62
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
63
+ return json.dumps(self.to_dict())
64
+
65
+ @classmethod
66
+ def from_json(cls, json_str: str) -> Optional[Self]:
67
+ """Create an instance of TimelineTombstone from a JSON string"""
68
+ return cls.from_dict(json.loads(json_str))
69
+
70
+ def to_dict(self) -> Dict[str, Any]:
71
+ """Return the dictionary representation of the model using alias.
72
+
73
+ This has the following differences from calling pydantic's
74
+ `self.model_dump(by_alias=True)`:
75
+
76
+ * `None` is only added to the output dict for nullable fields that
77
+ were set at model initialization. Other fields with value `None`
78
+ are ignored.
79
+ """
80
+ excluded_fields: Set[str] = set([
81
+ ])
82
+
83
+ _dict = self.model_dump(
84
+ by_alias=True,
85
+ exclude=excluded_fields,
86
+ exclude_none=True,
87
+ )
88
+ # override the default output from pydantic by calling `to_dict()` of tombstone_info
89
+ if self.tombstone_info:
90
+ _dict['tombstoneInfo'] = self.tombstone_info.to_dict()
91
+ return _dict
92
+
93
+ @classmethod
94
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
95
+ """Create an instance of TimelineTombstone from a dict"""
96
+ if obj is None:
97
+ return None
98
+
99
+ if not isinstance(obj, dict):
100
+ return cls.model_validate(obj)
101
+
102
+ _obj = cls.model_validate({
103
+ "__typename": obj.get("__typename"),
104
+ "itemType": obj.get("itemType"),
105
+ "tombstoneDisplayType": obj.get("tombstoneDisplayType"),
106
+ "tombstoneInfo": TombstoneInfo.from_dict(obj["tombstoneInfo"]) if obj.get("tombstoneInfo") is not None else None
107
+ })
108
+ return _obj
109
+
110
+
@@ -0,0 +1,130 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.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, Field, StrictBool, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.content_item_type import ContentItemType
24
+ from twitter_openapi_python_generated.models.social_context_landing_url import SocialContextLandingUrl
25
+ from twitter_openapi_python_generated.models.social_context_union import SocialContextUnion
26
+ from twitter_openapi_python_generated.models.thumbnail_image import ThumbnailImage
27
+ from twitter_openapi_python_generated.models.trend_image import TrendImage
28
+ from twitter_openapi_python_generated.models.trend_metadata import TrendMetadata
29
+ from twitter_openapi_python_generated.models.type_name import TypeName
30
+ from typing import Optional, Set
31
+ from typing_extensions import Self
32
+
33
+ class TimelineTrend(BaseModel):
34
+ """
35
+ TimelineTrend
36
+ """ # noqa: E501
37
+ typename: TypeName = Field(alias="__typename")
38
+ images: List[TrendImage]
39
+ is_ai_trend: Optional[StrictBool] = None
40
+ item_type: ContentItemType = Field(alias="itemType")
41
+ name: StrictStr
42
+ social_context: Optional[SocialContextUnion] = None
43
+ thumbnail_image: ThumbnailImage
44
+ trend_metadata: TrendMetadata
45
+ trend_url: SocialContextLandingUrl
46
+ __properties: ClassVar[List[str]] = ["__typename", "images", "is_ai_trend", "itemType", "name", "social_context", "thumbnail_image", "trend_metadata", "trend_url"]
47
+
48
+ model_config = ConfigDict(
49
+ populate_by_name=True,
50
+ validate_assignment=True,
51
+ protected_namespaces=(),
52
+ )
53
+
54
+
55
+ def to_str(self) -> str:
56
+ """Returns the string representation of the model using alias"""
57
+ return pprint.pformat(self.model_dump(by_alias=True))
58
+
59
+ def to_json(self) -> str:
60
+ """Returns the JSON representation of the model using alias"""
61
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
62
+ return json.dumps(self.to_dict())
63
+
64
+ @classmethod
65
+ def from_json(cls, json_str: str) -> Optional[Self]:
66
+ """Create an instance of TimelineTrend from a JSON string"""
67
+ return cls.from_dict(json.loads(json_str))
68
+
69
+ def to_dict(self) -> Dict[str, Any]:
70
+ """Return the dictionary representation of the model using alias.
71
+
72
+ This has the following differences from calling pydantic's
73
+ `self.model_dump(by_alias=True)`:
74
+
75
+ * `None` is only added to the output dict for nullable fields that
76
+ were set at model initialization. Other fields with value `None`
77
+ are ignored.
78
+ """
79
+ excluded_fields: Set[str] = set([
80
+ ])
81
+
82
+ _dict = self.model_dump(
83
+ by_alias=True,
84
+ exclude=excluded_fields,
85
+ exclude_none=True,
86
+ )
87
+ # override the default output from pydantic by calling `to_dict()` of each item in images (list)
88
+ _items = []
89
+ if self.images:
90
+ for _item_images in self.images:
91
+ if _item_images:
92
+ _items.append(_item_images.to_dict())
93
+ _dict['images'] = _items
94
+ # override the default output from pydantic by calling `to_dict()` of social_context
95
+ if self.social_context:
96
+ _dict['social_context'] = self.social_context.to_dict()
97
+ # override the default output from pydantic by calling `to_dict()` of thumbnail_image
98
+ if self.thumbnail_image:
99
+ _dict['thumbnail_image'] = self.thumbnail_image.to_dict()
100
+ # override the default output from pydantic by calling `to_dict()` of trend_metadata
101
+ if self.trend_metadata:
102
+ _dict['trend_metadata'] = self.trend_metadata.to_dict()
103
+ # override the default output from pydantic by calling `to_dict()` of trend_url
104
+ if self.trend_url:
105
+ _dict['trend_url'] = self.trend_url.to_dict()
106
+ return _dict
107
+
108
+ @classmethod
109
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
110
+ """Create an instance of TimelineTrend from a dict"""
111
+ if obj is None:
112
+ return None
113
+
114
+ if not isinstance(obj, dict):
115
+ return cls.model_validate(obj)
116
+
117
+ _obj = cls.model_validate({
118
+ "__typename": obj.get("__typename"),
119
+ "images": [TrendImage.from_dict(_item) for _item in obj["images"]] if obj.get("images") is not None else None,
120
+ "is_ai_trend": obj.get("is_ai_trend"),
121
+ "itemType": obj.get("itemType"),
122
+ "name": obj.get("name"),
123
+ "social_context": SocialContextUnion.from_dict(obj["social_context"]) if obj.get("social_context") is not None else None,
124
+ "thumbnail_image": ThumbnailImage.from_dict(obj["thumbnail_image"]) if obj.get("thumbnail_image") is not None else None,
125
+ "trend_metadata": TrendMetadata.from_dict(obj["trend_metadata"]) if obj.get("trend_metadata") is not None else None,
126
+ "trend_url": SocialContextLandingUrl.from_dict(obj["trend_url"]) if obj.get("trend_url") is not None else None
127
+ })
128
+ return _obj
129
+
130
+
@@ -0,0 +1,96 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.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, Field, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.tombstone_ref import TombstoneRef
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class TombstoneEntity(BaseModel):
28
+ """
29
+ TombstoneEntity
30
+ """ # noqa: E501
31
+ from_index: Optional[StrictInt] = Field(default=None, alias="fromIndex")
32
+ ref: Optional[TombstoneRef] = None
33
+ to_index: Optional[StrictInt] = Field(default=None, alias="toIndex")
34
+ __properties: ClassVar[List[str]] = ["fromIndex", "ref", "toIndex"]
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 TombstoneEntity 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
+ # override the default output from pydantic by calling `to_dict()` of ref
76
+ if self.ref:
77
+ _dict['ref'] = self.ref.to_dict()
78
+ return _dict
79
+
80
+ @classmethod
81
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
82
+ """Create an instance of TombstoneEntity from a dict"""
83
+ if obj is None:
84
+ return None
85
+
86
+ if not isinstance(obj, dict):
87
+ return cls.model_validate(obj)
88
+
89
+ _obj = cls.model_validate({
90
+ "fromIndex": obj.get("fromIndex"),
91
+ "ref": TombstoneRef.from_dict(obj["ref"]) if obj.get("ref") is not None else None,
92
+ "toIndex": obj.get("toIndex")
93
+ })
94
+ return _obj
95
+
96
+
@@ -0,0 +1,94 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Twitter OpenAPI
5
+
6
+ Twitter OpenAPI(Swagger) specification
7
+
8
+ The version of the OpenAPI document: 0.0.1
9
+ Contact: yuki@yuki0311.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, Field, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.tombstone_rich_text import TombstoneRichText
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class TombstoneInfo(BaseModel):
28
+ """
29
+ TombstoneInfo
30
+ """ # noqa: E501
31
+ rich_text: Optional[TombstoneRichText] = Field(default=None, alias="richText")
32
+ text: Optional[StrictStr] = None
33
+ __properties: ClassVar[List[str]] = ["richText", "text"]
34
+
35
+ model_config = ConfigDict(
36
+ populate_by_name=True,
37
+ validate_assignment=True,
38
+ protected_namespaces=(),
39
+ )
40
+
41
+
42
+ def to_str(self) -> str:
43
+ """Returns the string representation of the model using alias"""
44
+ return pprint.pformat(self.model_dump(by_alias=True))
45
+
46
+ def to_json(self) -> str:
47
+ """Returns the JSON representation of the model using alias"""
48
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
49
+ return json.dumps(self.to_dict())
50
+
51
+ @classmethod
52
+ def from_json(cls, json_str: str) -> Optional[Self]:
53
+ """Create an instance of TombstoneInfo from a JSON string"""
54
+ return cls.from_dict(json.loads(json_str))
55
+
56
+ def to_dict(self) -> Dict[str, Any]:
57
+ """Return the dictionary representation of the model using alias.
58
+
59
+ This has the following differences from calling pydantic's
60
+ `self.model_dump(by_alias=True)`:
61
+
62
+ * `None` is only added to the output dict for nullable fields that
63
+ were set at model initialization. Other fields with value `None`
64
+ are ignored.
65
+ """
66
+ excluded_fields: Set[str] = set([
67
+ ])
68
+
69
+ _dict = self.model_dump(
70
+ by_alias=True,
71
+ exclude=excluded_fields,
72
+ exclude_none=True,
73
+ )
74
+ # override the default output from pydantic by calling `to_dict()` of rich_text
75
+ if self.rich_text:
76
+ _dict['richText'] = self.rich_text.to_dict()
77
+ return _dict
78
+
79
+ @classmethod
80
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81
+ """Create an instance of TombstoneInfo from a dict"""
82
+ if obj is None:
83
+ return None
84
+
85
+ if not isinstance(obj, dict):
86
+ return cls.model_validate(obj)
87
+
88
+ _obj = cls.model_validate({
89
+ "richText": TombstoneRichText.from_dict(obj["richText"]) if obj.get("richText") is not None else None,
90
+ "text": obj.get("text")
91
+ })
92
+ return _obj
93
+
94
+