twitter-openapi-python-generated 0.0.27__py3-none-any.whl → 0.0.29__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 (36) hide show
  1. twitter_openapi_python_generated/__init__.py +16 -1
  2. twitter_openapi_python_generated/api/tweet_api.py +17 -0
  3. twitter_openapi_python_generated/api_client.py +1 -1
  4. twitter_openapi_python_generated/configuration.py +1 -1
  5. twitter_openapi_python_generated/models/__init__.py +15 -0
  6. twitter_openapi_python_generated/models/community_data.py +24 -15
  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/grok_share_attachment.py +96 -0
  10. twitter_openapi_python_generated/models/grok_share_attachment_item.py +90 -0
  11. twitter_openapi_python_generated/models/item_content_union.py +27 -8
  12. twitter_openapi_python_generated/models/limited_action_results_data.py +95 -0
  13. twitter_openapi_python_generated/models/timeline_timeline_module.py +6 -2
  14. twitter_openapi_python_generated/models/timeline_tombstone.py +110 -0
  15. twitter_openapi_python_generated/models/timeline_tweet.py +4 -2
  16. twitter_openapi_python_generated/models/tombstone_entity.py +96 -0
  17. twitter_openapi_python_generated/models/tombstone_info.py +94 -0
  18. twitter_openapi_python_generated/models/tombstone_ref.py +112 -0
  19. twitter_openapi_python_generated/models/tombstone_rich_text.py +100 -0
  20. twitter_openapi_python_generated/models/trend_results.py +96 -0
  21. twitter_openapi_python_generated/models/tweet.py +17 -1
  22. twitter_openapi_python_generated/models/tweet_limited_action_results.py +96 -0
  23. twitter_openapi_python_generated/models/tweet_preview_display.py +107 -0
  24. twitter_openapi_python_generated/models/tweet_preview_display_cta.py +94 -0
  25. twitter_openapi_python_generated/models/tweet_preview_display_cta_url.py +97 -0
  26. twitter_openapi_python_generated/models/tweet_preview_display_tweet.py +131 -0
  27. twitter_openapi_python_generated/models/tweet_preview_display_tweet_view_count.py +96 -0
  28. twitter_openapi_python_generated/models/tweet_union.py +27 -8
  29. twitter_openapi_python_generated/models/type_name.py +2 -0
  30. twitter_openapi_python_generated/models/user.py +15 -1
  31. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/METADATA +6 -6
  32. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/RECORD +36 -21
  33. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/WHEEL +1 -1
  34. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/LICENSE +0 -0
  35. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/LICENSE.AGPL +0 -0
  36. {twitter_openapi_python_generated-0.0.27.dist-info → twitter_openapi_python_generated-0.0.29.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,95 @@
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, StrictStr, field_validator
22
+ from typing import Any, ClassVar, Dict, List
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class LimitedActionResultsData(BaseModel):
27
+ """
28
+ LimitedActionResultsData
29
+ """ # noqa: E501
30
+ action: StrictStr
31
+ __properties: ClassVar[List[str]] = ["action"]
32
+
33
+ @field_validator('action')
34
+ def action_validate_enum(cls, value):
35
+ """Validates the enum"""
36
+ if value not in set(['Reply', 'Retweet', 'QuoteTweet', 'Like', 'React', 'AddToBookmarks', 'AddToMoment', 'PinToProfile', 'ViewHiddenReplies', 'VoteOnPoll', 'ShowRetweetActionMenu', 'ReplyDownVote', 'SendViaDm', 'ViewPostEngagements']):
37
+ raise ValueError("must be one of enum values ('Reply', 'Retweet', 'QuoteTweet', 'Like', 'React', 'AddToBookmarks', 'AddToMoment', 'PinToProfile', 'ViewHiddenReplies', 'VoteOnPoll', 'ShowRetweetActionMenu', 'ReplyDownVote', 'SendViaDm', 'ViewPostEngagements')")
38
+ return value
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of LimitedActionResultsData from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ return _dict
80
+
81
+ @classmethod
82
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
83
+ """Create an instance of LimitedActionResultsData from a dict"""
84
+ if obj is None:
85
+ return None
86
+
87
+ if not isinstance(obj, dict):
88
+ return cls.model_validate(obj)
89
+
90
+ _obj = cls.model_validate({
91
+ "action": obj.get("action")
92
+ })
93
+ return _obj
94
+
95
+
@@ -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
+
@@ -18,7 +18,7 @@ import pprint
18
18
  import re # noqa: F401
19
19
  import json
20
20
 
21
- from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
22
22
  from typing import Any, ClassVar, Dict, List, Optional
23
23
  from twitter_openapi_python_generated.models.content_item_type import ContentItemType
24
24
  from twitter_openapi_python_generated.models.highlight import Highlight
@@ -33,13 +33,14 @@ class TimelineTweet(BaseModel):
33
33
  TimelineTweet
34
34
  """ # noqa: E501
35
35
  typename: TypeName = Field(alias="__typename")
36
+ has_moderated_replies: Optional[StrictBool] = Field(default=None, alias="hasModeratedReplies")
36
37
  highlights: Optional[Highlight] = None
37
38
  item_type: ContentItemType = Field(alias="itemType")
38
39
  promoted_metadata: Optional[Dict[str, Any]] = Field(default=None, alias="promotedMetadata")
39
40
  social_context: Optional[SocialContextUnion] = Field(default=None, alias="socialContext")
40
41
  tweet_display_type: StrictStr = Field(alias="tweetDisplayType")
41
42
  tweet_results: ItemResult
42
- __properties: ClassVar[List[str]] = ["__typename", "highlights", "itemType", "promotedMetadata", "socialContext", "tweetDisplayType", "tweet_results"]
43
+ __properties: ClassVar[List[str]] = ["__typename", "hasModeratedReplies", "highlights", "itemType", "promotedMetadata", "socialContext", "tweetDisplayType", "tweet_results"]
43
44
 
44
45
  @field_validator('tweet_display_type')
45
46
  def tweet_display_type_validate_enum(cls, value):
@@ -109,6 +110,7 @@ class TimelineTweet(BaseModel):
109
110
 
110
111
  _obj = cls.model_validate({
111
112
  "__typename": obj.get("__typename"),
113
+ "hasModeratedReplies": obj.get("hasModeratedReplies"),
112
114
  "highlights": Highlight.from_dict(obj["highlights"]) if obj.get("highlights") is not None else None,
113
115
  "itemType": obj.get("itemType"),
114
116
  "promotedMetadata": obj.get("promotedMetadata"),
@@ -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
+
@@ -0,0 +1,112 @@
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 typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class TombstoneRef(BaseModel):
27
+ """
28
+ TombstoneRef
29
+ """ # noqa: E501
30
+ type: Optional[StrictStr] = None
31
+ url: Optional[StrictStr] = None
32
+ url_type: Optional[StrictStr] = Field(default=None, alias="urlType")
33
+ __properties: ClassVar[List[str]] = ["type", "url", "urlType"]
34
+
35
+ @field_validator('type')
36
+ def type_validate_enum(cls, value):
37
+ """Validates the enum"""
38
+ if value is None:
39
+ return value
40
+
41
+ if value not in set(['TimelineUrl']):
42
+ raise ValueError("must be one of enum values ('TimelineUrl')")
43
+ return value
44
+
45
+ @field_validator('url_type')
46
+ def url_type_validate_enum(cls, value):
47
+ """Validates the enum"""
48
+ if value is None:
49
+ return value
50
+
51
+ if value not in set(['ExternalUrl']):
52
+ raise ValueError("must be one of enum values ('ExternalUrl')")
53
+ return value
54
+
55
+ model_config = ConfigDict(
56
+ populate_by_name=True,
57
+ validate_assignment=True,
58
+ protected_namespaces=(),
59
+ )
60
+
61
+
62
+ def to_str(self) -> str:
63
+ """Returns the string representation of the model using alias"""
64
+ return pprint.pformat(self.model_dump(by_alias=True))
65
+
66
+ def to_json(self) -> str:
67
+ """Returns the JSON representation of the model using alias"""
68
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
69
+ return json.dumps(self.to_dict())
70
+
71
+ @classmethod
72
+ def from_json(cls, json_str: str) -> Optional[Self]:
73
+ """Create an instance of TombstoneRef from a JSON string"""
74
+ return cls.from_dict(json.loads(json_str))
75
+
76
+ def to_dict(self) -> Dict[str, Any]:
77
+ """Return the dictionary representation of the model using alias.
78
+
79
+ This has the following differences from calling pydantic's
80
+ `self.model_dump(by_alias=True)`:
81
+
82
+ * `None` is only added to the output dict for nullable fields that
83
+ were set at model initialization. Other fields with value `None`
84
+ are ignored.
85
+ """
86
+ excluded_fields: Set[str] = set([
87
+ ])
88
+
89
+ _dict = self.model_dump(
90
+ by_alias=True,
91
+ exclude=excluded_fields,
92
+ exclude_none=True,
93
+ )
94
+ return _dict
95
+
96
+ @classmethod
97
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98
+ """Create an instance of TombstoneRef from a dict"""
99
+ if obj is None:
100
+ return None
101
+
102
+ if not isinstance(obj, dict):
103
+ return cls.model_validate(obj)
104
+
105
+ _obj = cls.model_validate({
106
+ "type": obj.get("type"),
107
+ "url": obj.get("url"),
108
+ "urlType": obj.get("urlType")
109
+ })
110
+ return _obj
111
+
112
+
@@ -0,0 +1,100 @@
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, StrictBool, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from twitter_openapi_python_generated.models.tombstone_entity import TombstoneEntity
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class TombstoneRichText(BaseModel):
28
+ """
29
+ TombstoneRichText
30
+ """ # noqa: E501
31
+ entities: Optional[List[TombstoneEntity]] = None
32
+ rtl: Optional[StrictBool] = None
33
+ text: Optional[StrictStr] = None
34
+ __properties: ClassVar[List[str]] = ["entities", "rtl", "text"]
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 TombstoneRichText 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 each item in entities (list)
76
+ _items = []
77
+ if self.entities:
78
+ for _item_entities in self.entities:
79
+ if _item_entities:
80
+ _items.append(_item_entities.to_dict())
81
+ _dict['entities'] = _items
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of TombstoneRichText from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "entities": [TombstoneEntity.from_dict(_item) for _item in obj["entities"]] if obj.get("entities") is not None else None,
95
+ "rtl": obj.get("rtl"),
96
+ "text": obj.get("text")
97
+ })
98
+ return _obj
99
+
100
+