twitter-openapi-python 0.0.44__py3-none-any.whl → 0.1.0__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 (28) hide show
  1. twitter_openapi_python/__init__.py +15 -15
  2. twitter_openapi_python/api/__init__.py +13 -13
  3. twitter_openapi_python/api/default_api.py +80 -80
  4. twitter_openapi_python/api/initial_state_api.py +72 -72
  5. twitter_openapi_python/api/post_api.py +166 -166
  6. twitter_openapi_python/api/tweet_api.py +428 -353
  7. twitter_openapi_python/api/user_api.py +80 -80
  8. twitter_openapi_python/api/user_list_api.py +171 -171
  9. twitter_openapi_python/api/users_api.py +56 -56
  10. twitter_openapi_python/api/v11_get_api.py +67 -70
  11. twitter_openapi_python/api/v11_post_api.py +61 -66
  12. twitter_openapi_python/client.py +194 -194
  13. twitter_openapi_python/models/__init__.py +22 -22
  14. twitter_openapi_python/models/base.py +9 -9
  15. twitter_openapi_python/models/header.py +20 -20
  16. twitter_openapi_python/models/initial_state.py +17 -17
  17. twitter_openapi_python/models/response.py +19 -19
  18. twitter_openapi_python/models/timeline.py +40 -40
  19. twitter_openapi_python/tid.py +27 -17
  20. twitter_openapi_python/utils/__init__.py +22 -22
  21. twitter_openapi_python/utils/api.py +288 -288
  22. {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.1.0.dist-info}/METADATA +118 -117
  23. twitter_openapi_python-0.1.0.dist-info/RECORD +27 -0
  24. {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.1.0.dist-info}/WHEEL +1 -2
  25. {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.1.0.dist-info}/licenses/LICENSE +31 -31
  26. {twitter_openapi_python-0.0.44.dist-info → twitter_openapi_python-0.1.0.dist-info}/licenses/LICENSE.AGPL +660 -660
  27. twitter_openapi_python-0.0.44.dist-info/RECORD +0 -28
  28. twitter_openapi_python-0.0.44.dist-info/top_level.txt +0 -1
@@ -1,166 +1,166 @@
1
- from typing import Any, Optional, TypeVar
2
-
3
- import twitter_openapi_python_generated as twitter
4
- import twitter_openapi_python_generated.models as models
5
- from x_client_transaction import ClientTransaction
6
-
7
- from twitter_openapi_python.models import TwitterApiUtilsResponse
8
- from twitter_openapi_python.utils import build_response, non_nullable
9
- from twitter_openapi_python.utils.api import get_headers
10
-
11
- T = TypeVar("T")
12
- ResponseType = TwitterApiUtilsResponse[T]
13
- ParamType = dict[str, Any]
14
-
15
-
16
- class PostApiUtils:
17
- api: twitter.PostApi
18
- flag: ParamType
19
-
20
- def __init__(self, api: twitter.PostApi, flag: ParamType, ct: ClientTransaction):
21
- self.api = api
22
- self.flag = flag
23
- self.ct = ct
24
-
25
- def post_create_tweet(
26
- self,
27
- tweet_text: str,
28
- media_ids: Optional[list[str]] = None,
29
- tagged_users: Optional[list[list[str]]] = None,
30
- in_reply_to_tweet_id: Optional[str] = None,
31
- attachment_url: Optional[str] = None,
32
- conversation_control: Optional[str] = None,
33
- ) -> ResponseType[models.CreateTweetResponse]:
34
- variables = non_nullable(
35
- twitter.PostCreateTweetRequestVariables.from_dict(self.flag["CreateTweet"]["variables"])
36
- )
37
- features = non_nullable(twitter.PostCreateTweetRequestFeatures.from_dict(self.flag["CreateTweet"]["features"]))
38
- variables.tweet_text = tweet_text
39
- if media_ids:
40
- tagged_or = tagged_users or []
41
- variables.media.media_entities = [
42
- twitter.PostCreateTweetRequestVariablesMediaMediaEntitiesInner(
43
- media_id=media_id,
44
- tagged_users=tagged_or[idx] if len(tagged_or) > idx else [],
45
- )
46
- for idx, media_id in enumerate(media_ids)
47
- ]
48
- variables.attachment_url = attachment_url
49
- if conversation_control:
50
- variables.conversation_control = twitter.PostCreateTweetRequestVariablesConversationControl(
51
- mode=conversation_control
52
- )
53
-
54
- if in_reply_to_tweet_id:
55
- variables.reply = twitter.PostCreateTweetRequestVariablesReply(
56
- exclude_reply_user_ids=[],
57
- in_reply_to_tweet_id=in_reply_to_tweet_id,
58
- )
59
-
60
- res = self.api.post_create_tweet_with_http_info(
61
- path_query_id=self.flag["CreateTweet"]["queryId"],
62
- post_create_tweet_request=twitter.PostCreateTweetRequest(
63
- queryId=self.flag["CreateTweet"]["queryId"],
64
- variables=variables,
65
- features=features,
66
- ),
67
- _headers=get_headers(self.flag["CreateTweet"], self.ct),
68
- )
69
- return build_response(res, res.data)
70
-
71
- def post_delete_tweet(
72
- self,
73
- tweet_id: str,
74
- ) -> ResponseType[models.DeleteTweetResponse]:
75
- variables = non_nullable(
76
- twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["DeleteTweet"]["variables"])
77
- )
78
- variables.tweet_id = tweet_id
79
-
80
- res = self.api.post_delete_tweet_with_http_info(
81
- path_query_id=self.flag["DeleteTweet"]["queryId"],
82
- post_delete_tweet_request=twitter.PostDeleteTweetRequest(
83
- queryId=self.flag["DeleteTweet"]["queryId"],
84
- variables=variables,
85
- ),
86
- _headers=get_headers(self.flag["DeleteTweet"], self.ct),
87
- )
88
- return build_response(res, res.data)
89
-
90
- def post_create_retweet(
91
- self,
92
- tweet_id: str,
93
- ) -> ResponseType[models.CreateRetweetResponse]:
94
- variables = non_nullable(
95
- twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["CreateRetweet"]["variables"])
96
- )
97
- variables.tweet_id = tweet_id
98
-
99
- res = self.api.post_create_retweet_with_http_info(
100
- path_query_id=self.flag["CreateRetweet"]["queryId"],
101
- post_create_retweet_request=twitter.PostCreateRetweetRequest(
102
- queryId=self.flag["CreateRetweet"]["queryId"],
103
- variables=variables,
104
- ),
105
- _headers=get_headers(self.flag["CreateRetweet"], self.ct),
106
- )
107
- return build_response(res, res.data)
108
-
109
- def post_delete_retweet(
110
- self,
111
- source_tweet_id: str,
112
- ) -> ResponseType[models.DeleteRetweetResponse]:
113
- variables = non_nullable(
114
- twitter.PostDeleteRetweetRequestVariables.from_dict(self.flag["DeleteRetweet"]["variables"])
115
- )
116
- variables.source_tweet_id = source_tweet_id
117
-
118
- res = self.api.post_delete_retweet_with_http_info(
119
- path_query_id=self.flag["DeleteRetweet"]["queryId"],
120
- post_delete_retweet_request=twitter.PostDeleteRetweetRequest(
121
- queryId=self.flag["DeleteRetweet"]["queryId"],
122
- variables=variables,
123
- ),
124
- _headers=get_headers(self.flag["DeleteRetweet"], self.ct),
125
- )
126
- return build_response(res, res.data)
127
-
128
- # postFavoriteTweet
129
- def post_favorite_tweet(
130
- self,
131
- tweet_id: str,
132
- ) -> ResponseType[models.FavoriteTweetResponse]:
133
- variables = non_nullable(
134
- twitter.PostCreateBookmarkRequestVariables.from_dict(self.flag["FavoriteTweet"]["variables"])
135
- )
136
- variables.tweet_id = tweet_id
137
-
138
- res = self.api.post_favorite_tweet_with_http_info(
139
- path_query_id=self.flag["FavoriteTweet"]["queryId"],
140
- post_favorite_tweet_request=twitter.PostFavoriteTweetRequest(
141
- queryId=self.flag["FavoriteTweet"]["queryId"],
142
- variables=variables,
143
- ),
144
- _headers=get_headers(self.flag["FavoriteTweet"], self.ct),
145
- )
146
- return build_response(res, res.data)
147
-
148
- # postUnfavoriteTweet
149
- def post_unfavorite_tweet(
150
- self,
151
- tweet_id: str,
152
- ) -> ResponseType[models.UnfavoriteTweetResponse]:
153
- variables = non_nullable(
154
- twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["UnfavoriteTweet"]["variables"])
155
- )
156
- variables.tweet_id = tweet_id
157
-
158
- res = self.api.post_unfavorite_tweet_with_http_info(
159
- path_query_id=self.flag["UnfavoriteTweet"]["queryId"],
160
- post_unfavorite_tweet_request=twitter.PostUnfavoriteTweetRequest(
161
- queryId=self.flag["UnfavoriteTweet"]["queryId"],
162
- variables=variables,
163
- ),
164
- _headers=get_headers(self.flag["UnfavoriteTweet"], self.ct),
165
- )
166
- return build_response(res, res.data)
1
+ from typing import Any, Optional, TypeVar
2
+
3
+ import twitter_openapi_python_generated as twitter
4
+ import twitter_openapi_python_generated.models as models
5
+ from x_client_transaction import ClientTransaction
6
+
7
+ from twitter_openapi_python.models import TwitterApiUtilsResponse
8
+ from twitter_openapi_python.utils import build_response, non_nullable
9
+ from twitter_openapi_python.utils.api import get_headers
10
+
11
+ T = TypeVar("T")
12
+ ResponseType = TwitterApiUtilsResponse[T]
13
+ ParamType = dict[str, Any]
14
+
15
+
16
+ class PostApiUtils:
17
+ api: twitter.PostApi
18
+ flag: ParamType
19
+
20
+ def __init__(self, api: twitter.PostApi, flag: ParamType, ct: ClientTransaction):
21
+ self.api = api
22
+ self.flag = flag
23
+ self.ct = ct
24
+
25
+ def post_create_tweet(
26
+ self,
27
+ tweet_text: str,
28
+ media_ids: Optional[list[str]] = None,
29
+ tagged_users: Optional[list[list[str]]] = None,
30
+ in_reply_to_tweet_id: Optional[str] = None,
31
+ attachment_url: Optional[str] = None,
32
+ conversation_control: Optional[str] = None,
33
+ ) -> ResponseType[models.CreateTweetResponse]:
34
+ variables = non_nullable(
35
+ twitter.PostCreateTweetRequestVariables.from_dict(self.flag["CreateTweet"]["variables"])
36
+ )
37
+ features = non_nullable(twitter.PostCreateTweetRequestFeatures.from_dict(self.flag["CreateTweet"]["features"]))
38
+ variables.tweet_text = tweet_text
39
+ if media_ids:
40
+ tagged_or = tagged_users or []
41
+ variables.media.media_entities = [
42
+ twitter.PostCreateTweetRequestVariablesMediaMediaEntitiesInner(
43
+ media_id=media_id,
44
+ tagged_users=tagged_or[idx] if len(tagged_or) > idx else [],
45
+ )
46
+ for idx, media_id in enumerate(media_ids)
47
+ ]
48
+ variables.attachment_url = attachment_url
49
+ if conversation_control:
50
+ variables.conversation_control = twitter.PostCreateTweetRequestVariablesConversationControl(
51
+ mode=conversation_control
52
+ )
53
+
54
+ if in_reply_to_tweet_id:
55
+ variables.reply = twitter.PostCreateTweetRequestVariablesReply(
56
+ exclude_reply_user_ids=[],
57
+ in_reply_to_tweet_id=in_reply_to_tweet_id,
58
+ )
59
+
60
+ res = self.api.post_create_tweet_with_http_info(
61
+ path_query_id=self.flag["CreateTweet"]["queryId"],
62
+ post_create_tweet_request=twitter.PostCreateTweetRequest(
63
+ queryId=self.flag["CreateTweet"]["queryId"],
64
+ variables=variables,
65
+ features=features,
66
+ ),
67
+ _headers=get_headers(self.flag["CreateTweet"], self.ct),
68
+ )
69
+ return build_response(res, res.data)
70
+
71
+ def post_delete_tweet(
72
+ self,
73
+ tweet_id: str,
74
+ ) -> ResponseType[models.DeleteTweetResponse]:
75
+ variables = non_nullable(
76
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["DeleteTweet"]["variables"])
77
+ )
78
+ variables.tweet_id = tweet_id
79
+
80
+ res = self.api.post_delete_tweet_with_http_info(
81
+ path_query_id=self.flag["DeleteTweet"]["queryId"],
82
+ post_delete_tweet_request=twitter.PostDeleteTweetRequest(
83
+ queryId=self.flag["DeleteTweet"]["queryId"],
84
+ variables=variables,
85
+ ),
86
+ _headers=get_headers(self.flag["DeleteTweet"], self.ct),
87
+ )
88
+ return build_response(res, res.data)
89
+
90
+ def post_create_retweet(
91
+ self,
92
+ tweet_id: str,
93
+ ) -> ResponseType[models.CreateRetweetResponse]:
94
+ variables = non_nullable(
95
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["CreateRetweet"]["variables"])
96
+ )
97
+ variables.tweet_id = tweet_id
98
+
99
+ res = self.api.post_create_retweet_with_http_info(
100
+ path_query_id=self.flag["CreateRetweet"]["queryId"],
101
+ post_create_retweet_request=twitter.PostCreateRetweetRequest(
102
+ queryId=self.flag["CreateRetweet"]["queryId"],
103
+ variables=variables,
104
+ ),
105
+ _headers=get_headers(self.flag["CreateRetweet"], self.ct),
106
+ )
107
+ return build_response(res, res.data)
108
+
109
+ def post_delete_retweet(
110
+ self,
111
+ source_tweet_id: str,
112
+ ) -> ResponseType[models.DeleteRetweetResponse]:
113
+ variables = non_nullable(
114
+ twitter.PostDeleteRetweetRequestVariables.from_dict(self.flag["DeleteRetweet"]["variables"])
115
+ )
116
+ variables.source_tweet_id = source_tweet_id
117
+
118
+ res = self.api.post_delete_retweet_with_http_info(
119
+ path_query_id=self.flag["DeleteRetweet"]["queryId"],
120
+ post_delete_retweet_request=twitter.PostDeleteRetweetRequest(
121
+ queryId=self.flag["DeleteRetweet"]["queryId"],
122
+ variables=variables,
123
+ ),
124
+ _headers=get_headers(self.flag["DeleteRetweet"], self.ct),
125
+ )
126
+ return build_response(res, res.data)
127
+
128
+ # postFavoriteTweet
129
+ def post_favorite_tweet(
130
+ self,
131
+ tweet_id: str,
132
+ ) -> ResponseType[models.FavoriteTweetResponse]:
133
+ variables = non_nullable(
134
+ twitter.PostCreateBookmarkRequestVariables.from_dict(self.flag["FavoriteTweet"]["variables"])
135
+ )
136
+ variables.tweet_id = tweet_id
137
+
138
+ res = self.api.post_favorite_tweet_with_http_info(
139
+ path_query_id=self.flag["FavoriteTweet"]["queryId"],
140
+ post_favorite_tweet_request=twitter.PostFavoriteTweetRequest(
141
+ queryId=self.flag["FavoriteTweet"]["queryId"],
142
+ variables=variables,
143
+ ),
144
+ _headers=get_headers(self.flag["FavoriteTweet"], self.ct),
145
+ )
146
+ return build_response(res, res.data)
147
+
148
+ # postUnfavoriteTweet
149
+ def post_unfavorite_tweet(
150
+ self,
151
+ tweet_id: str,
152
+ ) -> ResponseType[models.UnfavoriteTweetResponse]:
153
+ variables = non_nullable(
154
+ twitter.PostCreateRetweetRequestVariables.from_dict(self.flag["UnfavoriteTweet"]["variables"])
155
+ )
156
+ variables.tweet_id = tweet_id
157
+
158
+ res = self.api.post_unfavorite_tweet_with_http_info(
159
+ path_query_id=self.flag["UnfavoriteTweet"]["queryId"],
160
+ post_unfavorite_tweet_request=twitter.PostUnfavoriteTweetRequest(
161
+ queryId=self.flag["UnfavoriteTweet"]["queryId"],
162
+ variables=variables,
163
+ ),
164
+ _headers=get_headers(self.flag["UnfavoriteTweet"], self.ct),
165
+ )
166
+ return build_response(res, res.data)