twitter-openapi-python 0.0.43__py3-none-any.whl → 0.0.45__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.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/METADATA +118 -117
  23. twitter_openapi_python-0.0.45.dist-info/RECORD +27 -0
  24. {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/WHEEL +1 -2
  25. {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE +31 -31
  26. {twitter_openapi_python-0.0.43.dist-info → twitter_openapi_python-0.0.45.dist-info}/licenses/LICENSE.AGPL +660 -660
  27. twitter_openapi_python-0.0.43.dist-info/RECORD +0 -28
  28. twitter_openapi_python-0.0.43.dist-info/top_level.txt +0 -1
@@ -1,353 +1,428 @@
1
- from typing import Any, Callable, List, Literal, 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 (
8
- ApiUtilsRaw,
9
- TimelineApiUtilsResponse,
10
- TweetApiUtilsData,
11
- TwitterApiUtilsResponse,
12
- )
13
- from twitter_openapi_python.utils import (
14
- build_response,
15
- entries_cursor,
16
- error_check,
17
- get_kwargs,
18
- instruction_to_entry,
19
- tweet_entries_converter,
20
- )
21
-
22
- T = TypeVar("T")
23
- ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[TweetApiUtilsData]]
24
- ApiFnType = Callable[..., twitter.ApiResponse[T]]
25
- ParamType = dict[str, Any]
26
-
27
-
28
- class TweetApiUtils:
29
- api: twitter.TweetApi
30
- flag: ParamType
31
-
32
- def __init__(self, api: twitter.TweetApi, flag: ParamType, ct: ClientTransaction):
33
- self.api = api
34
- self.flag = flag
35
- self.ct = ct
36
-
37
- def request(
38
- self,
39
- apiFn: "ApiFnType[T]",
40
- convertFn: Callable[[T], List[models.InstructionUnion]],
41
- key: str,
42
- param: ParamType,
43
- ) -> ResponseType:
44
- args = get_kwargs(flag=self.flag[key], additional=param, ct=self.ct)
45
- res = apiFn(**args)
46
- instruction = convertFn(res.data)
47
- entry = instruction_to_entry(instruction)
48
- tweet_list = tweet_entries_converter(entry)
49
- raw = ApiUtilsRaw(
50
- instruction=instruction,
51
- entry=entry,
52
- )
53
- data = TimelineApiUtilsResponse[TweetApiUtilsData](
54
- raw=raw,
55
- cursor=entries_cursor(entry),
56
- data=tweet_list,
57
- )
58
- return build_response(res, data)
59
-
60
- def get_tweet_detail(
61
- self,
62
- focal_tweet_id: str,
63
- cursor: Optional[str] = None,
64
- controller_data: Optional[str] = None,
65
- extra_param: Optional[ParamType] = None,
66
- ) -> ResponseType:
67
- param: ParamType = {"focalTweetId": focal_tweet_id}
68
- if cursor is not None:
69
- param["cursor"] = cursor
70
- if controller_data is not None:
71
- param["controller_data"] = controller_data
72
- if extra_param is not None:
73
- param.update(extra_param)
74
-
75
- response = self.request(
76
- apiFn=self.api.get_tweet_detail_with_http_info,
77
- convertFn=lambda e: error_check(e.data.threaded_conversation_with_injections_v2, e.errors).instructions,
78
- key="TweetDetail",
79
- param=param,
80
- )
81
- return response
82
-
83
- def get_search_timeline(
84
- self,
85
- raw_query: str,
86
- product: Optional[Literal["Top", "Latest", "People", "Photos", "Videos"]] = None,
87
- cursor: Optional[str] = None,
88
- count: Optional[int] = None,
89
- extra_param: Optional[ParamType] = None,
90
- ) -> ResponseType:
91
- param: ParamType = {"rawQuery": raw_query}
92
- if product is not None:
93
- param["product"] = product
94
- if cursor is not None:
95
- param["cursor"] = cursor
96
- if count is not None:
97
- param["count"] = count
98
- if extra_param is not None:
99
- param.update(extra_param)
100
-
101
- response = self.request(
102
- apiFn=self.api.get_search_timeline_with_http_info,
103
- convertFn=lambda e: error_check(e.data.search_by_raw_query, e.errors).search_timeline.timeline.instructions,
104
- key="SearchTimeline",
105
- param=param,
106
- )
107
- return response
108
-
109
- def get_home_timeline(
110
- self,
111
- cursor: Optional[str] = None,
112
- count: Optional[int] = None,
113
- extra_param: Optional[ParamType] = None,
114
- ) -> ResponseType:
115
- param: ParamType = {}
116
- if cursor is not None:
117
- param["cursor"] = cursor
118
- if count is not None:
119
- param["count"] = count
120
- if extra_param is not None:
121
- param.update(extra_param)
122
-
123
- response = self.request(
124
- apiFn=self.api.get_home_timeline_with_http_info,
125
- convertFn=lambda e: error_check(e.data.home, e.errors).home_timeline_urt.instructions,
126
- key="HomeTimeline",
127
- param=param,
128
- )
129
- return response
130
-
131
- def get_home_latest_timeline(
132
- self,
133
- cursor: Optional[str] = None,
134
- count: Optional[int] = None,
135
- extra_param: Optional[ParamType] = None,
136
- ) -> ResponseType:
137
- param: ParamType = {}
138
- if cursor is not None:
139
- param["cursor"] = cursor
140
- if count is not None:
141
- param["count"] = count
142
- if extra_param is not None:
143
- param.update(extra_param)
144
-
145
- response = self.request(
146
- apiFn=self.api.get_home_latest_timeline_with_http_info,
147
- convertFn=lambda e: error_check(e.data.home, e.errors).home_timeline_urt.instructions,
148
- key="HomeLatestTimeline",
149
- param=param,
150
- )
151
- return response
152
-
153
- def get_list_latest_tweets_timeline(
154
- self,
155
- list_id: str,
156
- cursor: Optional[str] = None,
157
- count: Optional[int] = None,
158
- extra_param: Optional[ParamType] = None,
159
- ) -> ResponseType:
160
- param: ParamType = {"listId": list_id}
161
- if cursor is not None:
162
- param["cursor"] = cursor
163
- if count is not None:
164
- param["count"] = count
165
- if extra_param is not None:
166
- param.update(extra_param)
167
-
168
- response = self.request(
169
- apiFn=self.api.get_list_latest_tweets_timeline_with_http_info,
170
- convertFn=lambda e: error_check(
171
- error_check(e.data.list, e.errors).tweets_timeline.timeline, e.errors
172
- ).instructions,
173
- key="ListLatestTweetsTimeline",
174
- param=param,
175
- )
176
- return response
177
-
178
- def get_user_tweets(
179
- self,
180
- user_id: str,
181
- cursor: Optional[str] = None,
182
- count: Optional[int] = None,
183
- extra_param: Optional[ParamType] = None,
184
- ) -> ResponseType:
185
- param: ParamType = {"userId": user_id}
186
- if cursor is not None:
187
- param["cursor"] = cursor
188
- if count is not None:
189
- param["count"] = count
190
- if extra_param is not None:
191
- param.update(extra_param)
192
-
193
- response = self.request(
194
- apiFn=self.api.get_user_tweets_with_http_info,
195
- convertFn=lambda e: error_check(
196
- error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
197
- ).instructions,
198
- key="UserTweets",
199
- param=param,
200
- )
201
- return response
202
-
203
- def get_user_tweets_and_replies(
204
- self,
205
- user_id: str,
206
- cursor: Optional[str] = None,
207
- count: Optional[int] = None,
208
- extra_param: Optional[ParamType] = None,
209
- ) -> ResponseType:
210
- param: ParamType = {"userId": user_id}
211
- if cursor is not None:
212
- param["cursor"] = cursor
213
- if count is not None:
214
- param["count"] = count
215
- if extra_param is not None:
216
- param.update(extra_param)
217
-
218
- response = self.request(
219
- apiFn=self.api.get_user_tweets_and_replies_with_http_info,
220
- convertFn=lambda e: error_check(
221
- error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
222
- ).instructions,
223
- key="UserTweetsAndReplies",
224
- param=param,
225
- )
226
- return response
227
-
228
- def get_user_media(
229
- self,
230
- user_id: str,
231
- cursor: Optional[str] = None,
232
- count: Optional[int] = None,
233
- extra_param: Optional[ParamType] = None,
234
- ) -> ResponseType:
235
- param: ParamType = {"userId": user_id}
236
- if cursor is not None:
237
- param["cursor"] = cursor
238
- if count is not None:
239
- param["count"] = count
240
- if extra_param is not None:
241
- param.update(extra_param)
242
-
243
- response = self.request(
244
- apiFn=self.api.get_user_media_with_http_info,
245
- convertFn=lambda e: error_check(
246
- error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
247
- ).instructions,
248
- key="UserMedia",
249
- param=param,
250
- )
251
- return response
252
-
253
- def get_likes(
254
- self,
255
- user_id: str,
256
- cursor: Optional[str] = None,
257
- count: Optional[int] = None,
258
- extra_param: Optional[ParamType] = None,
259
- ) -> ResponseType:
260
- param: ParamType = {"userId": user_id}
261
- if cursor is not None:
262
- param["cursor"] = cursor
263
- if count is not None:
264
- param["count"] = count
265
- if extra_param is not None:
266
- param.update(extra_param)
267
-
268
- response = self.request(
269
- apiFn=self.api.get_likes_with_http_info,
270
- convertFn=lambda e: error_check(
271
- error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
272
- ).instructions,
273
- key="Likes",
274
- param=param,
275
- )
276
- return response
277
-
278
- def get_bookmarks(
279
- self,
280
- cursor: Optional[str] = None,
281
- count: Optional[int] = None,
282
- extra_param: Optional[ParamType] = None,
283
- ) -> ResponseType:
284
- param: ParamType = {}
285
- if cursor is not None:
286
- param["cursor"] = cursor
287
- if count is not None:
288
- param["count"] = count
289
- if extra_param is not None:
290
- param.update(extra_param)
291
-
292
- response = self.request(
293
- apiFn=self.api.get_bookmarks_with_http_info,
294
- convertFn=lambda e: error_check(
295
- error_check(e.data, e.errors).bookmark_timeline_v2.timeline, e.errors
296
- ).instructions,
297
- key="Bookmarks",
298
- param=param,
299
- )
300
- return response
301
-
302
- def get_community_tweets_timeline(
303
- self,
304
- community_id: str,
305
- cursor: Optional[str] = None,
306
- count: Optional[int] = None,
307
- rankingMode: Optional[Literal["Recency", "Relevance"]] = None,
308
- extra_param: Optional[ParamType] = None,
309
- ) -> ResponseType:
310
- param: ParamType = {"communityId": community_id}
311
- if cursor is not None:
312
- param["cursor"] = cursor
313
- if count is not None:
314
- param["count"] = count
315
- if rankingMode is not None:
316
- param["rankingMode"] = rankingMode
317
- if extra_param is not None:
318
- param.update(extra_param)
319
-
320
- response = self.request(
321
- apiFn=self.api.get_community_tweets_timeline_with_http_info,
322
- convertFn=lambda e: error_check(
323
- error_check(e.data, e.errors).community_results.result.ranked_community_timeline.timeline, e.errors
324
- ).instructions,
325
- key="CommunityTweetsTimeline",
326
- param=param,
327
- )
328
- return response
329
-
330
- def get_community_media_timeline(
331
- self,
332
- community_id: str,
333
- cursor: Optional[str] = None,
334
- count: Optional[int] = None,
335
- extra_param: Optional[ParamType] = None,
336
- ) -> ResponseType:
337
- param: ParamType = {"communityId": community_id}
338
- if cursor is not None:
339
- param["cursor"] = cursor
340
- if count is not None:
341
- param["count"] = count
342
- if extra_param is not None:
343
- param.update(extra_param)
344
-
345
- response = self.request(
346
- apiFn=self.api.get_community_media_timeline_with_http_info,
347
- convertFn=lambda e: error_check(
348
- error_check(e.data, e.errors).community_results.result.community_media_timeline.timeline, e.errors
349
- ).instructions,
350
- key="CommunityMediaTimeline",
351
- param=param,
352
- )
353
- return response
1
+ from typing import Any, Callable, List, Literal, 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 (
8
+ ApiUtilsRaw,
9
+ TimelineApiUtilsResponse,
10
+ TweetApiUtilsData,
11
+ TwitterApiUtilsResponse,
12
+ )
13
+ from twitter_openapi_python.utils import (
14
+ build_response,
15
+ entries_cursor,
16
+ error_check,
17
+ get_kwargs,
18
+ instruction_to_entry,
19
+ tweet_entries_converter,
20
+ )
21
+
22
+ T = TypeVar("T")
23
+ ResponseType = TwitterApiUtilsResponse[TimelineApiUtilsResponse[TweetApiUtilsData]]
24
+ ApiFnType = Callable[..., twitter.ApiResponse[T]]
25
+ ParamType = dict[str, Any]
26
+
27
+
28
+ class TweetApiUtils:
29
+ api: twitter.TweetApi
30
+ flag: ParamType
31
+
32
+ def __init__(self, api: twitter.TweetApi, flag: ParamType, ct: ClientTransaction):
33
+ self.api = api
34
+ self.flag = flag
35
+ self.ct = ct
36
+
37
+ def request(
38
+ self,
39
+ apiFn: "ApiFnType[T]",
40
+ convertFn: Callable[[T], List[models.InstructionUnion]],
41
+ key: str,
42
+ param: ParamType,
43
+ ) -> ResponseType:
44
+ args = get_kwargs(flag=self.flag[key], additional=param, ct=self.ct)
45
+ res = apiFn(**args)
46
+ instruction = convertFn(res.data)
47
+ entry = instruction_to_entry(instruction)
48
+ tweet_list = tweet_entries_converter(entry)
49
+ raw = ApiUtilsRaw(
50
+ instruction=instruction,
51
+ entry=entry,
52
+ )
53
+ data = TimelineApiUtilsResponse[TweetApiUtilsData](
54
+ raw=raw,
55
+ cursor=entries_cursor(entry),
56
+ data=tweet_list,
57
+ )
58
+ return build_response(res, data)
59
+
60
+ def get_tweet_detail(
61
+ self,
62
+ focal_tweet_id: str,
63
+ cursor: Optional[str] = None,
64
+ controller_data: Optional[str] = None,
65
+ extra_param: Optional[ParamType] = None,
66
+ ) -> ResponseType:
67
+ param: ParamType = {"focalTweetId": focal_tweet_id}
68
+ if cursor is not None:
69
+ param["cursor"] = cursor
70
+ if controller_data is not None:
71
+ param["controller_data"] = controller_data
72
+ if extra_param is not None:
73
+ param.update(extra_param)
74
+
75
+ response = self.request(
76
+ apiFn=self.api.get_tweet_detail_with_http_info,
77
+ convertFn=lambda e: error_check(e.data.threaded_conversation_with_injections_v2, e.errors).instructions,
78
+ key="TweetDetail",
79
+ param=param,
80
+ )
81
+ return response
82
+
83
+ def get_search_timeline(
84
+ self,
85
+ raw_query: str,
86
+ product: Optional[Literal["Top", "Latest", "People", "Photos", "Videos"]] = None,
87
+ cursor: Optional[str] = None,
88
+ count: Optional[int] = None,
89
+ extra_param: Optional[ParamType] = None,
90
+ ) -> ResponseType:
91
+ param: ParamType = {"rawQuery": raw_query}
92
+ if product is not None:
93
+ param["product"] = product
94
+ if cursor is not None:
95
+ param["cursor"] = cursor
96
+ if count is not None:
97
+ param["count"] = count
98
+ if extra_param is not None:
99
+ param.update(extra_param)
100
+
101
+ response = self.request(
102
+ apiFn=self.api.get_search_timeline_with_http_info,
103
+ convertFn=lambda e: error_check(e.data.search_by_raw_query, e.errors).search_timeline.timeline.instructions,
104
+ key="SearchTimeline",
105
+ param=param,
106
+ )
107
+ return response
108
+
109
+ def get_home_timeline(
110
+ self,
111
+ cursor: Optional[str] = None,
112
+ count: Optional[int] = None,
113
+ extra_param: Optional[ParamType] = None,
114
+ ) -> ResponseType:
115
+ param: ParamType = {}
116
+ if cursor is not None:
117
+ param["cursor"] = cursor
118
+ if count is not None:
119
+ param["count"] = count
120
+ if extra_param is not None:
121
+ param.update(extra_param)
122
+
123
+ response = self.request(
124
+ apiFn=self.api.get_home_timeline_with_http_info,
125
+ convertFn=lambda e: error_check(e.data.home, e.errors).home_timeline_urt.instructions,
126
+ key="HomeTimeline",
127
+ param=param,
128
+ )
129
+ return response
130
+
131
+ def get_home_latest_timeline(
132
+ self,
133
+ cursor: Optional[str] = None,
134
+ count: Optional[int] = None,
135
+ extra_param: Optional[ParamType] = None,
136
+ ) -> ResponseType:
137
+ param: ParamType = {}
138
+ if cursor is not None:
139
+ param["cursor"] = cursor
140
+ if count is not None:
141
+ param["count"] = count
142
+ if extra_param is not None:
143
+ param.update(extra_param)
144
+
145
+ response = self.request(
146
+ apiFn=self.api.get_home_latest_timeline_with_http_info,
147
+ convertFn=lambda e: error_check(e.data.home, e.errors).home_timeline_urt.instructions,
148
+ key="HomeLatestTimeline",
149
+ param=param,
150
+ )
151
+ return response
152
+
153
+ def get_list_latest_tweets_timeline(
154
+ self,
155
+ list_id: str,
156
+ cursor: Optional[str] = None,
157
+ count: Optional[int] = None,
158
+ extra_param: Optional[ParamType] = None,
159
+ ) -> ResponseType:
160
+ param: ParamType = {"listId": list_id}
161
+ if cursor is not None:
162
+ param["cursor"] = cursor
163
+ if count is not None:
164
+ param["count"] = count
165
+ if extra_param is not None:
166
+ param.update(extra_param)
167
+
168
+ response = self.request(
169
+ apiFn=self.api.get_list_latest_tweets_timeline_with_http_info,
170
+ convertFn=lambda e: error_check(
171
+ error_check(e.data.list, e.errors).tweets_timeline.timeline, e.errors
172
+ ).instructions,
173
+ key="ListLatestTweetsTimeline",
174
+ param=param,
175
+ )
176
+ return response
177
+
178
+ def get_user_tweets(
179
+ self,
180
+ user_id: str,
181
+ cursor: Optional[str] = None,
182
+ count: Optional[int] = None,
183
+ extra_param: Optional[ParamType] = None,
184
+ ) -> ResponseType:
185
+ param: ParamType = {"userId": user_id}
186
+ if cursor is not None:
187
+ param["cursor"] = cursor
188
+ if count is not None:
189
+ param["count"] = count
190
+ if extra_param is not None:
191
+ param.update(extra_param)
192
+
193
+ response = self.request(
194
+ apiFn=self.api.get_user_tweets_with_http_info,
195
+ convertFn=lambda e: error_check(
196
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
197
+ ).instructions,
198
+ key="UserTweets",
199
+ param=param,
200
+ )
201
+ return response
202
+
203
+ def get_user_originals_timeline(
204
+ self,
205
+ user_id: str,
206
+ cursor: Optional[str] = None,
207
+ count: Optional[int] = None,
208
+ extra_param: Optional[ParamType] = None,
209
+ ) -> ResponseType:
210
+ param: ParamType = {"userId": user_id}
211
+ if cursor is not None:
212
+ param["cursor"] = cursor
213
+ if count is not None:
214
+ param["count"] = count
215
+ if extra_param is not None:
216
+ param.update(extra_param)
217
+
218
+ response = self.request(
219
+ apiFn=self.api.get_user_originals_timeline_with_http_info,
220
+ convertFn=lambda e: error_check(
221
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
222
+ ).instructions,
223
+ key="UserOriginalsTimeline",
224
+ param=param,
225
+ )
226
+ return response
227
+
228
+ def get_user_replies_timeline(
229
+ self,
230
+ user_id: str,
231
+ cursor: Optional[str] = None,
232
+ count: Optional[int] = None,
233
+ extra_param: Optional[ParamType] = None,
234
+ ) -> ResponseType:
235
+ param: ParamType = {"userId": user_id}
236
+ if cursor is not None:
237
+ param["cursor"] = cursor
238
+ if count is not None:
239
+ param["count"] = count
240
+ if extra_param is not None:
241
+ param.update(extra_param)
242
+
243
+ response = self.request(
244
+ apiFn=self.api.get_user_replies_timeline_with_http_info,
245
+ convertFn=lambda e: error_check(
246
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
247
+ ).instructions,
248
+ key="UserRepliesTimeline",
249
+ param=param,
250
+ )
251
+ return response
252
+
253
+ def get_user_video_timeline(
254
+ self,
255
+ user_id: str,
256
+ cursor: Optional[str] = None,
257
+ count: Optional[int] = None,
258
+ extra_param: Optional[ParamType] = None,
259
+ ) -> ResponseType:
260
+ param: ParamType = {"userId": user_id}
261
+ if cursor is not None:
262
+ param["cursor"] = cursor
263
+ if count is not None:
264
+ param["count"] = count
265
+ if extra_param is not None:
266
+ param.update(extra_param)
267
+
268
+ response = self.request(
269
+ apiFn=self.api.get_user_video_timeline_with_http_info,
270
+ convertFn=lambda e: error_check(
271
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
272
+ ).instructions,
273
+ key="UserVideoTimeline",
274
+ param=param,
275
+ )
276
+ return response
277
+
278
+ def get_user_tweets_and_replies(
279
+ self,
280
+ user_id: str,
281
+ cursor: Optional[str] = None,
282
+ count: Optional[int] = None,
283
+ extra_param: Optional[ParamType] = None,
284
+ ) -> ResponseType:
285
+ param: ParamType = {"userId": user_id}
286
+ if cursor is not None:
287
+ param["cursor"] = cursor
288
+ if count is not None:
289
+ param["count"] = count
290
+ if extra_param is not None:
291
+ param.update(extra_param)
292
+
293
+ response = self.request(
294
+ apiFn=self.api.get_user_tweets_and_replies_with_http_info,
295
+ convertFn=lambda e: error_check(
296
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
297
+ ).instructions,
298
+ key="UserTweetsAndReplies",
299
+ param=param,
300
+ )
301
+ return response
302
+
303
+ def get_user_media(
304
+ self,
305
+ user_id: str,
306
+ cursor: Optional[str] = None,
307
+ count: Optional[int] = None,
308
+ extra_param: Optional[ParamType] = None,
309
+ ) -> ResponseType:
310
+ param: ParamType = {"userId": user_id}
311
+ if cursor is not None:
312
+ param["cursor"] = cursor
313
+ if count is not None:
314
+ param["count"] = count
315
+ if extra_param is not None:
316
+ param.update(extra_param)
317
+
318
+ response = self.request(
319
+ apiFn=self.api.get_user_media_with_http_info,
320
+ convertFn=lambda e: error_check(
321
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
322
+ ).instructions,
323
+ key="UserMedia",
324
+ param=param,
325
+ )
326
+ return response
327
+
328
+ def get_likes(
329
+ self,
330
+ user_id: str,
331
+ cursor: Optional[str] = None,
332
+ count: Optional[int] = None,
333
+ extra_param: Optional[ParamType] = None,
334
+ ) -> ResponseType:
335
+ param: ParamType = {"userId": user_id}
336
+ if cursor is not None:
337
+ param["cursor"] = cursor
338
+ if count is not None:
339
+ param["count"] = count
340
+ if extra_param is not None:
341
+ param.update(extra_param)
342
+
343
+ response = self.request(
344
+ apiFn=self.api.get_likes_with_http_info,
345
+ convertFn=lambda e: error_check(
346
+ error_check(e.data.user, e.errors).result.timeline.timeline, e.errors
347
+ ).instructions,
348
+ key="Likes",
349
+ param=param,
350
+ )
351
+ return response
352
+
353
+ def get_bookmarks(
354
+ self,
355
+ cursor: Optional[str] = None,
356
+ count: Optional[int] = None,
357
+ extra_param: Optional[ParamType] = None,
358
+ ) -> ResponseType:
359
+ param: ParamType = {}
360
+ if cursor is not None:
361
+ param["cursor"] = cursor
362
+ if count is not None:
363
+ param["count"] = count
364
+ if extra_param is not None:
365
+ param.update(extra_param)
366
+
367
+ response = self.request(
368
+ apiFn=self.api.get_bookmarks_with_http_info,
369
+ convertFn=lambda e: error_check(
370
+ error_check(e.data, e.errors).bookmark_timeline_v2.timeline, e.errors
371
+ ).instructions,
372
+ key="Bookmarks",
373
+ param=param,
374
+ )
375
+ return response
376
+
377
+ def get_community_tweets_timeline(
378
+ self,
379
+ community_id: str,
380
+ cursor: Optional[str] = None,
381
+ count: Optional[int] = None,
382
+ rankingMode: Optional[Literal["Recency", "Relevance"]] = None,
383
+ extra_param: Optional[ParamType] = None,
384
+ ) -> ResponseType:
385
+ param: ParamType = {"communityId": community_id}
386
+ if cursor is not None:
387
+ param["cursor"] = cursor
388
+ if count is not None:
389
+ param["count"] = count
390
+ if rankingMode is not None:
391
+ param["rankingMode"] = rankingMode
392
+ if extra_param is not None:
393
+ param.update(extra_param)
394
+
395
+ response = self.request(
396
+ apiFn=self.api.get_community_tweets_timeline_with_http_info,
397
+ convertFn=lambda e: error_check(
398
+ error_check(e.data, e.errors).community_results.result.ranked_community_timeline.timeline, e.errors
399
+ ).instructions,
400
+ key="CommunityTweetsTimeline",
401
+ param=param,
402
+ )
403
+ return response
404
+
405
+ def get_community_media_timeline(
406
+ self,
407
+ community_id: str,
408
+ cursor: Optional[str] = None,
409
+ count: Optional[int] = None,
410
+ extra_param: Optional[ParamType] = None,
411
+ ) -> ResponseType:
412
+ param: ParamType = {"communityId": community_id}
413
+ if cursor is not None:
414
+ param["cursor"] = cursor
415
+ if count is not None:
416
+ param["count"] = count
417
+ if extra_param is not None:
418
+ param.update(extra_param)
419
+
420
+ response = self.request(
421
+ apiFn=self.api.get_community_media_timeline_with_http_info,
422
+ convertFn=lambda e: error_check(
423
+ error_check(e.data, e.errors).community_results.result.community_media_timeline.timeline, e.errors
424
+ ).instructions,
425
+ key="CommunityMediaTimeline",
426
+ param=param,
427
+ )
428
+ return response