twitter-openapi-python-generated 0.0.26__py3-none-any.whl → 0.0.28__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.
- twitter_openapi_python_generated/__init__.py +13 -3
- twitter_openapi_python_generated/api/tweet_api.py +17 -0
- twitter_openapi_python_generated/api_client.py +1 -1
- twitter_openapi_python_generated/configuration.py +1 -1
- twitter_openapi_python_generated/models/__init__.py +12 -2
- twitter_openapi_python_generated/models/community_actions.py +3 -3
- twitter_openapi_python_generated/models/community_data.py +24 -15
- twitter_openapi_python_generated/models/{community_join_action_result.py → community_join_action.py} +4 -4
- twitter_openapi_python_generated/models/{community_join_action_union.py → community_join_action_result_union.py} +21 -26
- twitter_openapi_python_generated/models/grok_share_attachment.py +96 -0
- twitter_openapi_python_generated/models/grok_share_attachment_item.py +90 -0
- twitter_openapi_python_generated/models/limited_action_results_data.py +95 -0
- twitter_openapi_python_generated/models/timeline_tweet.py +4 -2
- twitter_openapi_python_generated/models/trend_results.py +96 -0
- twitter_openapi_python_generated/models/tweet.py +15 -1
- twitter_openapi_python_generated/models/tweet_limited_action_results.py +96 -0
- twitter_openapi_python_generated/models/tweet_preview_display.py +107 -0
- twitter_openapi_python_generated/models/tweet_preview_display_cta.py +94 -0
- twitter_openapi_python_generated/models/tweet_preview_display_cta_url.py +97 -0
- twitter_openapi_python_generated/models/tweet_preview_display_tweet.py +131 -0
- twitter_openapi_python_generated/models/tweet_preview_display_tweet_view_count.py +96 -0
- twitter_openapi_python_generated/models/tweet_union.py +27 -8
- twitter_openapi_python_generated/models/type_name.py +1 -0
- twitter_openapi_python_generated/models/user.py +3 -1
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.dist-info}/METADATA +6 -6
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.dist-info}/RECORD +30 -20
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.dist-info}/WHEEL +1 -1
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.dist-info}/LICENSE +0 -0
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.dist-info}/LICENSE.AGPL +0 -0
- {twitter_openapi_python_generated-0.0.26.dist-info → twitter_openapi_python_generated-0.0.28.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
|
+
|
|
@@ -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, field_validator
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing_extensions import Annotated
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class TrendResults(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
TrendResults
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
rest_id: Annotated[str, Field(strict=True)]
|
|
32
|
+
__properties: ClassVar[List[str]] = ["rest_id"]
|
|
33
|
+
|
|
34
|
+
@field_validator('rest_id')
|
|
35
|
+
def rest_id_validate_regular_expression(cls, value):
|
|
36
|
+
"""Validates the regular expression"""
|
|
37
|
+
if not re.match(r"^[0-9]+$", value):
|
|
38
|
+
raise ValueError(r"must validate the regular expression /^[0-9]+$/")
|
|
39
|
+
return value
|
|
40
|
+
|
|
41
|
+
model_config = ConfigDict(
|
|
42
|
+
populate_by_name=True,
|
|
43
|
+
validate_assignment=True,
|
|
44
|
+
protected_namespaces=(),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def to_str(self) -> str:
|
|
49
|
+
"""Returns the string representation of the model using alias"""
|
|
50
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
"""Returns the JSON representation of the model using alias"""
|
|
54
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
55
|
+
return json.dumps(self.to_dict())
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
59
|
+
"""Create an instance of TrendResults from a JSON string"""
|
|
60
|
+
return cls.from_dict(json.loads(json_str))
|
|
61
|
+
|
|
62
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
63
|
+
"""Return the dictionary representation of the model using alias.
|
|
64
|
+
|
|
65
|
+
This has the following differences from calling pydantic's
|
|
66
|
+
`self.model_dump(by_alias=True)`:
|
|
67
|
+
|
|
68
|
+
* `None` is only added to the output dict for nullable fields that
|
|
69
|
+
were set at model initialization. Other fields with value `None`
|
|
70
|
+
are ignored.
|
|
71
|
+
"""
|
|
72
|
+
excluded_fields: Set[str] = set([
|
|
73
|
+
])
|
|
74
|
+
|
|
75
|
+
_dict = self.model_dump(
|
|
76
|
+
by_alias=True,
|
|
77
|
+
exclude=excluded_fields,
|
|
78
|
+
exclude_none=True,
|
|
79
|
+
)
|
|
80
|
+
return _dict
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
84
|
+
"""Create an instance of TrendResults from a dict"""
|
|
85
|
+
if obj is None:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
if not isinstance(obj, dict):
|
|
89
|
+
return cls.model_validate(obj)
|
|
90
|
+
|
|
91
|
+
_obj = cls.model_validate({
|
|
92
|
+
"rest_id": obj.get("rest_id")
|
|
93
|
+
})
|
|
94
|
+
return _obj
|
|
95
|
+
|
|
96
|
+
|
|
@@ -26,8 +26,10 @@ from twitter_openapi_python_generated.models.author_community_relationship impor
|
|
|
26
26
|
from twitter_openapi_python_generated.models.birdwatch_pivot import BirdwatchPivot
|
|
27
27
|
from twitter_openapi_python_generated.models.community import Community
|
|
28
28
|
from twitter_openapi_python_generated.models.community_relationship import CommunityRelationship
|
|
29
|
+
from twitter_openapi_python_generated.models.grok_share_attachment import GrokShareAttachment
|
|
29
30
|
from twitter_openapi_python_generated.models.note_tweet import NoteTweet
|
|
30
31
|
from twitter_openapi_python_generated.models.super_follows_reply_user_result import SuperFollowsReplyUserResult
|
|
32
|
+
from twitter_openapi_python_generated.models.trend_results import TrendResults
|
|
31
33
|
from twitter_openapi_python_generated.models.tweet_card import TweetCard
|
|
32
34
|
from twitter_openapi_python_generated.models.tweet_edit_control import TweetEditControl
|
|
33
35
|
from twitter_openapi_python_generated.models.tweet_edit_prespective import TweetEditPrespective
|
|
@@ -53,6 +55,8 @@ class Tweet(BaseModel):
|
|
|
53
55
|
core: Optional[UserResultCore] = None
|
|
54
56
|
edit_control: Optional[TweetEditControl] = None
|
|
55
57
|
edit_prespective: Optional[TweetEditPrespective] = None
|
|
58
|
+
grok_analysis_followups: Optional[List[StrictStr]] = None
|
|
59
|
+
grok_share_attachment: Optional[GrokShareAttachment] = None
|
|
56
60
|
has_birdwatch_notes: Optional[StrictBool] = None
|
|
57
61
|
is_translatable: Optional[StrictBool] = None
|
|
58
62
|
legacy: Optional[TweetLegacy] = None
|
|
@@ -64,10 +68,11 @@ class Tweet(BaseModel):
|
|
|
64
68
|
rest_id: Annotated[str, Field(strict=True)]
|
|
65
69
|
source: Optional[StrictStr] = None
|
|
66
70
|
super_follows_reply_user_result: Optional[SuperFollowsReplyUserResult] = Field(default=None, alias="superFollowsReplyUserResult")
|
|
71
|
+
trend_results: Optional[TrendResults] = None
|
|
67
72
|
unified_card: Optional[UnifiedCard] = None
|
|
68
73
|
unmention_data: Optional[Dict[str, Any]] = None
|
|
69
74
|
views: Optional[TweetView] = None
|
|
70
|
-
__properties: ClassVar[List[str]] = ["__typename", "article", "author_community_relationship", "birdwatch_pivot", "card", "community_relationship", "community_results", "core", "edit_control", "edit_prespective", "has_birdwatch_notes", "is_translatable", "legacy", "note_tweet", "previous_counts", "quick_promote_eligibility", "quotedRefResult", "quoted_status_result", "rest_id", "source", "superFollowsReplyUserResult", "unified_card", "unmention_data", "views"]
|
|
75
|
+
__properties: ClassVar[List[str]] = ["__typename", "article", "author_community_relationship", "birdwatch_pivot", "card", "community_relationship", "community_results", "core", "edit_control", "edit_prespective", "grok_analysis_followups", "grok_share_attachment", "has_birdwatch_notes", "is_translatable", "legacy", "note_tweet", "previous_counts", "quick_promote_eligibility", "quotedRefResult", "quoted_status_result", "rest_id", "source", "superFollowsReplyUserResult", "trend_results", "unified_card", "unmention_data", "views"]
|
|
71
76
|
|
|
72
77
|
@field_validator('rest_id')
|
|
73
78
|
def rest_id_validate_regular_expression(cls, value):
|
|
@@ -142,6 +147,9 @@ class Tweet(BaseModel):
|
|
|
142
147
|
# override the default output from pydantic by calling `to_dict()` of edit_prespective
|
|
143
148
|
if self.edit_prespective:
|
|
144
149
|
_dict['edit_prespective'] = self.edit_prespective.to_dict()
|
|
150
|
+
# override the default output from pydantic by calling `to_dict()` of grok_share_attachment
|
|
151
|
+
if self.grok_share_attachment:
|
|
152
|
+
_dict['grok_share_attachment'] = self.grok_share_attachment.to_dict()
|
|
145
153
|
# override the default output from pydantic by calling `to_dict()` of legacy
|
|
146
154
|
if self.legacy:
|
|
147
155
|
_dict['legacy'] = self.legacy.to_dict()
|
|
@@ -160,6 +168,9 @@ class Tweet(BaseModel):
|
|
|
160
168
|
# override the default output from pydantic by calling `to_dict()` of super_follows_reply_user_result
|
|
161
169
|
if self.super_follows_reply_user_result:
|
|
162
170
|
_dict['superFollowsReplyUserResult'] = self.super_follows_reply_user_result.to_dict()
|
|
171
|
+
# override the default output from pydantic by calling `to_dict()` of trend_results
|
|
172
|
+
if self.trend_results:
|
|
173
|
+
_dict['trend_results'] = self.trend_results.to_dict()
|
|
163
174
|
# override the default output from pydantic by calling `to_dict()` of unified_card
|
|
164
175
|
if self.unified_card:
|
|
165
176
|
_dict['unified_card'] = self.unified_card.to_dict()
|
|
@@ -188,6 +199,8 @@ class Tweet(BaseModel):
|
|
|
188
199
|
"core": UserResultCore.from_dict(obj["core"]) if obj.get("core") is not None else None,
|
|
189
200
|
"edit_control": TweetEditControl.from_dict(obj["edit_control"]) if obj.get("edit_control") is not None else None,
|
|
190
201
|
"edit_prespective": TweetEditPrespective.from_dict(obj["edit_prespective"]) if obj.get("edit_prespective") is not None else None,
|
|
202
|
+
"grok_analysis_followups": obj.get("grok_analysis_followups"),
|
|
203
|
+
"grok_share_attachment": GrokShareAttachment.from_dict(obj["grok_share_attachment"]) if obj.get("grok_share_attachment") is not None else None,
|
|
191
204
|
"has_birdwatch_notes": obj.get("has_birdwatch_notes"),
|
|
192
205
|
"is_translatable": obj.get("is_translatable"),
|
|
193
206
|
"legacy": TweetLegacy.from_dict(obj["legacy"]) if obj.get("legacy") is not None else None,
|
|
@@ -199,6 +212,7 @@ class Tweet(BaseModel):
|
|
|
199
212
|
"rest_id": obj.get("rest_id"),
|
|
200
213
|
"source": obj.get("source"),
|
|
201
214
|
"superFollowsReplyUserResult": SuperFollowsReplyUserResult.from_dict(obj["superFollowsReplyUserResult"]) if obj.get("superFollowsReplyUserResult") is not None else None,
|
|
215
|
+
"trend_results": TrendResults.from_dict(obj["trend_results"]) if obj.get("trend_results") is not None else None,
|
|
202
216
|
"unified_card": UnifiedCard.from_dict(obj["unified_card"]) if obj.get("unified_card") is not None else None,
|
|
203
217
|
"unmention_data": obj.get("unmention_data"),
|
|
204
218
|
"views": TweetView.from_dict(obj["views"]) if obj.get("views") is not None else None
|
|
@@ -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
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from twitter_openapi_python_generated.models.limited_action_results_data import LimitedActionResultsData
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class TweetLimitedActionResults(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
TweetLimitedActionResults
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
limited_actions: List[LimitedActionResultsData]
|
|
32
|
+
__properties: ClassVar[List[str]] = ["limited_actions"]
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(
|
|
35
|
+
populate_by_name=True,
|
|
36
|
+
validate_assignment=True,
|
|
37
|
+
protected_namespaces=(),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def to_str(self) -> str:
|
|
42
|
+
"""Returns the string representation of the model using alias"""
|
|
43
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
44
|
+
|
|
45
|
+
def to_json(self) -> str:
|
|
46
|
+
"""Returns the JSON representation of the model using alias"""
|
|
47
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
48
|
+
return json.dumps(self.to_dict())
|
|
49
|
+
|
|
50
|
+
@classmethod
|
|
51
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
52
|
+
"""Create an instance of TweetLimitedActionResults from a JSON string"""
|
|
53
|
+
return cls.from_dict(json.loads(json_str))
|
|
54
|
+
|
|
55
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
56
|
+
"""Return the dictionary representation of the model using alias.
|
|
57
|
+
|
|
58
|
+
This has the following differences from calling pydantic's
|
|
59
|
+
`self.model_dump(by_alias=True)`:
|
|
60
|
+
|
|
61
|
+
* `None` is only added to the output dict for nullable fields that
|
|
62
|
+
were set at model initialization. Other fields with value `None`
|
|
63
|
+
are ignored.
|
|
64
|
+
"""
|
|
65
|
+
excluded_fields: Set[str] = set([
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
_dict = self.model_dump(
|
|
69
|
+
by_alias=True,
|
|
70
|
+
exclude=excluded_fields,
|
|
71
|
+
exclude_none=True,
|
|
72
|
+
)
|
|
73
|
+
# override the default output from pydantic by calling `to_dict()` of each item in limited_actions (list)
|
|
74
|
+
_items = []
|
|
75
|
+
if self.limited_actions:
|
|
76
|
+
for _item_limited_actions in self.limited_actions:
|
|
77
|
+
if _item_limited_actions:
|
|
78
|
+
_items.append(_item_limited_actions.to_dict())
|
|
79
|
+
_dict['limited_actions'] = _items
|
|
80
|
+
return _dict
|
|
81
|
+
|
|
82
|
+
@classmethod
|
|
83
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
84
|
+
"""Create an instance of TweetLimitedActionResults from a dict"""
|
|
85
|
+
if obj is None:
|
|
86
|
+
return None
|
|
87
|
+
|
|
88
|
+
if not isinstance(obj, dict):
|
|
89
|
+
return cls.model_validate(obj)
|
|
90
|
+
|
|
91
|
+
_obj = cls.model_validate({
|
|
92
|
+
"limited_actions": [LimitedActionResultsData.from_dict(_item) for _item in obj["limited_actions"]] if obj.get("limited_actions") is not None else None
|
|
93
|
+
})
|
|
94
|
+
return _obj
|
|
95
|
+
|
|
96
|
+
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from twitter_openapi_python_generated.models.tweet_limited_action_results import TweetLimitedActionResults
|
|
24
|
+
from twitter_openapi_python_generated.models.tweet_preview_display_cta import TweetPreviewDisplayCta
|
|
25
|
+
from twitter_openapi_python_generated.models.tweet_preview_display_tweet import TweetPreviewDisplayTweet
|
|
26
|
+
from twitter_openapi_python_generated.models.type_name import TypeName
|
|
27
|
+
from typing import Optional, Set
|
|
28
|
+
from typing_extensions import Self
|
|
29
|
+
|
|
30
|
+
class TweetPreviewDisplay(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
TweetPreviewDisplay
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
typename: TypeName = Field(alias="__typename")
|
|
35
|
+
cta: TweetPreviewDisplayCta
|
|
36
|
+
limited_action_results: TweetLimitedActionResults
|
|
37
|
+
tweet: TweetPreviewDisplayTweet
|
|
38
|
+
__properties: ClassVar[List[str]] = ["__typename", "cta", "limited_action_results", "tweet"]
|
|
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 TweetPreviewDisplay 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
|
+
# override the default output from pydantic by calling `to_dict()` of cta
|
|
80
|
+
if self.cta:
|
|
81
|
+
_dict['cta'] = self.cta.to_dict()
|
|
82
|
+
# override the default output from pydantic by calling `to_dict()` of limited_action_results
|
|
83
|
+
if self.limited_action_results:
|
|
84
|
+
_dict['limited_action_results'] = self.limited_action_results.to_dict()
|
|
85
|
+
# override the default output from pydantic by calling `to_dict()` of tweet
|
|
86
|
+
if self.tweet:
|
|
87
|
+
_dict['tweet'] = self.tweet.to_dict()
|
|
88
|
+
return _dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
92
|
+
"""Create an instance of TweetPreviewDisplay from a dict"""
|
|
93
|
+
if obj is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not isinstance(obj, dict):
|
|
97
|
+
return cls.model_validate(obj)
|
|
98
|
+
|
|
99
|
+
_obj = cls.model_validate({
|
|
100
|
+
"__typename": obj.get("__typename"),
|
|
101
|
+
"cta": TweetPreviewDisplayCta.from_dict(obj["cta"]) if obj.get("cta") is not None else None,
|
|
102
|
+
"limited_action_results": TweetLimitedActionResults.from_dict(obj["limited_action_results"]) if obj.get("limited_action_results") is not None else None,
|
|
103
|
+
"tweet": TweetPreviewDisplayTweet.from_dict(obj["tweet"]) if obj.get("tweet") is not None else None
|
|
104
|
+
})
|
|
105
|
+
return _obj
|
|
106
|
+
|
|
107
|
+
|
|
@@ -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, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from twitter_openapi_python_generated.models.tweet_preview_display_cta_url import TweetPreviewDisplayCtaUrl
|
|
24
|
+
from typing import Optional, Set
|
|
25
|
+
from typing_extensions import Self
|
|
26
|
+
|
|
27
|
+
class TweetPreviewDisplayCta(BaseModel):
|
|
28
|
+
"""
|
|
29
|
+
TweetPreviewDisplayCta
|
|
30
|
+
""" # noqa: E501
|
|
31
|
+
title: StrictStr
|
|
32
|
+
url: TweetPreviewDisplayCtaUrl
|
|
33
|
+
__properties: ClassVar[List[str]] = ["title", "url"]
|
|
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 TweetPreviewDisplayCta 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 url
|
|
75
|
+
if self.url:
|
|
76
|
+
_dict['url'] = self.url.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 TweetPreviewDisplayCta 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
|
+
"title": obj.get("title"),
|
|
90
|
+
"url": TweetPreviewDisplayCtaUrl.from_dict(obj["url"]) if obj.get("url") is not None else None
|
|
91
|
+
})
|
|
92
|
+
return _obj
|
|
93
|
+
|
|
94
|
+
|