x-twitter-scraper 0.10.4 → 0.10.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +69 -29
- data/lib/x_twitter_scraper/client.rb +0 -13
- data/lib/x_twitter_scraper/file_part.rb +0 -3
- data/lib/x_twitter_scraper/internal/transport/base_client.rb +3 -211
- data/lib/x_twitter_scraper/internal/transport/pooled_net_requester.rb +2 -56
- data/lib/x_twitter_scraper/internal/type/array_of.rb +1 -77
- data/lib/x_twitter_scraper/internal/type/base_model.rb +3 -133
- data/lib/x_twitter_scraper/internal/type/base_page.rb +0 -13
- data/lib/x_twitter_scraper/internal/type/boolean.rb +0 -38
- data/lib/x_twitter_scraper/internal/type/converter.rb +0 -136
- data/lib/x_twitter_scraper/internal/type/enum.rb +1 -80
- data/lib/x_twitter_scraper/internal/type/file_input.rb +0 -39
- data/lib/x_twitter_scraper/internal/type/hash_of.rb +1 -77
- data/lib/x_twitter_scraper/internal/type/request_parameters.rb +0 -13
- data/lib/x_twitter_scraper/internal/type/union.rb +0 -101
- data/lib/x_twitter_scraper/internal/type/unknown.rb +0 -40
- data/lib/x_twitter_scraper/internal/util.rb +2 -307
- data/lib/x_twitter_scraper/models/account_retrieve_response.rb +0 -3
- data/lib/x_twitter_scraper/models/compose_create_params.rb +0 -4
- data/lib/x_twitter_scraper/models/compose_create_response.rb +0 -4
- data/lib/x_twitter_scraper/models/credit_retrieve_balance_response.rb +0 -3
- data/lib/x_twitter_scraper/models/credit_topup_balance_response.rb +0 -3
- data/lib/x_twitter_scraper/models/draft_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/draw_export_params.rb +0 -3
- data/lib/x_twitter_scraper/models/draw_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/draw_run_response.rb +0 -3
- data/lib/x_twitter_scraper/models/embedded_tweet.rb +0 -3
- data/lib/x_twitter_scraper/models/event.rb +0 -3
- data/lib/x_twitter_scraper/models/event_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/extraction_estimate_cost_params.rb +0 -3
- data/lib/x_twitter_scraper/models/extraction_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/extraction_run_params.rb +0 -3
- data/lib/x_twitter_scraper/models/guest_wallet_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/guest_wallet_retrieve_status_response.rb +0 -3
- data/lib/x_twitter_scraper/models/guest_wallet_topup_response.rb +0 -3
- data/lib/x_twitter_scraper/models/radar_item.rb +0 -3
- data/lib/x_twitter_scraper/models/radar_retrieve_trending_topics_params.rb +0 -3
- data/lib/x_twitter_scraper/models/search_tweet.rb +0 -3
- data/lib/x_twitter_scraper/models/trend_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/webhook.rb +0 -3
- data/lib/x_twitter_scraper/models/x/communities/join_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/communities/join_delete_all_response.rb +0 -4
- data/lib/x_twitter_scraper/models/x/communities/tweet_list_by_community_params.rb +0 -4
- data/lib/x_twitter_scraper/models/x/communities/tweet_list_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/community_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/community_delete_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/community_retrieve_members_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/community_retrieve_moderators_params.rb +0 -4
- data/lib/x_twitter_scraper/models/x/community_retrieve_search_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/dm_retrieve_history_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/dm_retrieve_history_response.rb +0 -4
- data/lib/x_twitter_scraper/models/x/dm_send_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/list_retrieve_followers_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/list_retrieve_members_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/list_retrieve_tweets_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/media_upload_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/profile_update_avatar_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/profile_update_banner_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/profile_update_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_create_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_delete_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_detail.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_get_favoriters_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_get_quotes_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_get_replies_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_get_retweeters_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_get_thread_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_retrieve_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweet_search_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweets/like_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweets/like_delete_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweets/retweet_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/tweets/retweet_delete_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_remove_follower_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_batch_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_batch_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_followers_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_followers_you_know_params.rb +0 -4
- data/lib/x_twitter_scraper/models/x/user_retrieve_following_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_likes_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_media_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_mentions_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_replies_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_search_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_tweets_params.rb +0 -3
- data/lib/x_twitter_scraper/models/x/user_retrieve_verified_followers_params.rb +0 -4
- data/lib/x_twitter_scraper/models/x/users/follow_create_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/users/follow_delete_all_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/write_action_retrieve_response.rb +0 -3
- data/lib/x_twitter_scraper/models/x/x_account.rb +0 -3
- data/lib/x_twitter_scraper/models/x_get_article_response.rb +0 -4
- data/lib/x_twitter_scraper/request_options.rb +0 -2
- data/lib/x_twitter_scraper/resources/drafts.rb +0 -3
- data/lib/x_twitter_scraper/resources/draws.rb +0 -6
- data/lib/x_twitter_scraper/resources/events.rb +0 -3
- data/lib/x_twitter_scraper/resources/extractions.rb +0 -9
- data/lib/x_twitter_scraper/resources/guest_wallets.rb +0 -6
- data/lib/x_twitter_scraper/resources/monitors/keywords.rb +1 -1
- data/lib/x_twitter_scraper/resources/monitors.rb +1 -1
- data/lib/x_twitter_scraper/resources/radar.rb +0 -3
- data/lib/x_twitter_scraper/resources/support/tickets.rb +0 -6
- data/lib/x_twitter_scraper/resources/trends.rb +0 -3
- data/lib/x_twitter_scraper/resources/x/communities/join.rb +0 -6
- data/lib/x_twitter_scraper/resources/x/communities/tweets.rb +0 -7
- data/lib/x_twitter_scraper/resources/x/communities.rb +0 -16
- data/lib/x_twitter_scraper/resources/x/dm.rb +0 -6
- data/lib/x_twitter_scraper/resources/x/lists.rb +0 -9
- data/lib/x_twitter_scraper/resources/x/media.rb +0 -3
- data/lib/x_twitter_scraper/resources/x/profile.rb +0 -9
- data/lib/x_twitter_scraper/resources/x/tweets/like.rb +0 -6
- data/lib/x_twitter_scraper/resources/x/tweets/retweet.rb +0 -6
- data/lib/x_twitter_scraper/resources/x/tweets.rb +0 -24
- data/lib/x_twitter_scraper/resources/x/users/follow.rb +0 -6
- data/lib/x_twitter_scraper/resources/x/users.rb +0 -38
- data/lib/x_twitter_scraper/resources/x.rb +0 -3
- data/lib/x_twitter_scraper/version.rb +1 -1
- data/lib/x_twitter_scraper.rb +0 -5
- data/rbi/x_twitter_scraper/client.rbi +0 -4
- data/rbi/x_twitter_scraper/file_part.rbi +0 -1
- data/rbi/x_twitter_scraper/internal/transport/base_client.rbi +0 -19
- data/rbi/x_twitter_scraper/internal/transport/pooled_net_requester.rbi +0 -9
- data/rbi/x_twitter_scraper/internal/type/array_of.rbi +0 -10
- data/rbi/x_twitter_scraper/internal/type/base_model.rbi +0 -47
- data/rbi/x_twitter_scraper/internal/type/base_page.rbi +0 -4
- data/rbi/x_twitter_scraper/internal/type/boolean.rbi +0 -8
- data/rbi/x_twitter_scraper/internal/type/converter.rbi +0 -36
- data/rbi/x_twitter_scraper/internal/type/enum.rbi +0 -20
- data/rbi/x_twitter_scraper/internal/type/file_input.rbi +0 -10
- data/rbi/x_twitter_scraper/internal/type/hash_of.rbi +0 -10
- data/rbi/x_twitter_scraper/internal/type/request_parameters.rbi +0 -4
- data/rbi/x_twitter_scraper/internal/type/union.rbi +0 -18
- data/rbi/x_twitter_scraper/internal/type/unknown.rbi +0 -8
- data/rbi/x_twitter_scraper/internal/util.rbi +0 -75
- data/rbi/x_twitter_scraper/internal.rbi +0 -2
- data/rbi/x_twitter_scraper/request_options.rbi +0 -1
- data/rbi/x_twitter_scraper/resources/monitors/keywords.rbi +1 -1
- data/rbi/x_twitter_scraper/resources/monitors.rbi +1 -1
- data/sig/x_twitter_scraper/internal/transport/base_client.rbs +0 -1
- metadata +13 -5
|
@@ -31,15 +31,10 @@ module XTwitterScraper
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
class << self
|
|
34
|
-
# @api private
|
|
35
|
-
#
|
|
36
|
-
# Assumes superclass fields are totally defined before fields are accessed /
|
|
37
|
-
# defined on subclasses.
|
|
38
34
|
sig { params(child: XTwitterScraper::Internal::Type::BaseModel).void }
|
|
39
35
|
def inherited(child)
|
|
40
36
|
end
|
|
41
37
|
|
|
42
|
-
# @api private
|
|
43
38
|
sig do
|
|
44
39
|
returns(
|
|
45
40
|
T::Hash[
|
|
@@ -59,7 +54,6 @@ module XTwitterScraper
|
|
|
59
54
|
def known_fields
|
|
60
55
|
end
|
|
61
56
|
|
|
62
|
-
# @api private
|
|
63
57
|
sig do
|
|
64
58
|
returns(
|
|
65
59
|
T::Hash[
|
|
@@ -74,7 +68,6 @@ module XTwitterScraper
|
|
|
74
68
|
def fields
|
|
75
69
|
end
|
|
76
70
|
|
|
77
|
-
# @api private
|
|
78
71
|
sig do
|
|
79
72
|
params(
|
|
80
73
|
name_sym: Symbol,
|
|
@@ -112,7 +105,6 @@ module XTwitterScraper
|
|
|
112
105
|
private def add_field(name_sym, required:, type_info:, spec:)
|
|
113
106
|
end
|
|
114
107
|
|
|
115
|
-
# @api private
|
|
116
108
|
sig do
|
|
117
109
|
params(
|
|
118
110
|
name_sym: Symbol,
|
|
@@ -130,7 +122,6 @@ module XTwitterScraper
|
|
|
130
122
|
def required(name_sym, type_info, spec = {})
|
|
131
123
|
end
|
|
132
124
|
|
|
133
|
-
# @api private
|
|
134
125
|
sig do
|
|
135
126
|
params(
|
|
136
127
|
name_sym: Symbol,
|
|
@@ -148,17 +139,10 @@ module XTwitterScraper
|
|
|
148
139
|
def optional(name_sym, type_info, spec = {})
|
|
149
140
|
end
|
|
150
141
|
|
|
151
|
-
# @api private
|
|
152
|
-
#
|
|
153
|
-
# `request_only` attributes not excluded from `.#coerce` when receiving responses
|
|
154
|
-
# even if well behaved servers should not send them
|
|
155
142
|
sig { params(blk: T.proc.void).void }
|
|
156
143
|
private def request_only(&blk)
|
|
157
144
|
end
|
|
158
145
|
|
|
159
|
-
# @api private
|
|
160
|
-
#
|
|
161
|
-
# `response_only` attributes are omitted from `.#dump` when making requests
|
|
162
146
|
sig { params(blk: T.proc.void).void }
|
|
163
147
|
private def response_only(&blk)
|
|
164
148
|
end
|
|
@@ -181,7 +165,6 @@ module XTwitterScraper
|
|
|
181
165
|
end
|
|
182
166
|
|
|
183
167
|
class << self
|
|
184
|
-
# @api private
|
|
185
168
|
sig do
|
|
186
169
|
override
|
|
187
170
|
.params(
|
|
@@ -198,7 +181,6 @@ module XTwitterScraper
|
|
|
198
181
|
def coerce(value, state:)
|
|
199
182
|
end
|
|
200
183
|
|
|
201
|
-
# @api private
|
|
202
184
|
sig do
|
|
203
185
|
override
|
|
204
186
|
.params(
|
|
@@ -210,14 +192,12 @@ module XTwitterScraper
|
|
|
210
192
|
def dump(value, state:)
|
|
211
193
|
end
|
|
212
194
|
|
|
213
|
-
# @api private
|
|
214
195
|
sig { returns(T.anything) }
|
|
215
196
|
def to_sorbet_type
|
|
216
197
|
end
|
|
217
198
|
end
|
|
218
199
|
|
|
219
200
|
class << self
|
|
220
|
-
# @api private
|
|
221
201
|
sig do
|
|
222
202
|
params(
|
|
223
203
|
model: XTwitterScraper::Internal::Type::BaseModel,
|
|
@@ -228,42 +208,18 @@ module XTwitterScraper
|
|
|
228
208
|
end
|
|
229
209
|
end
|
|
230
210
|
|
|
231
|
-
# Returns the raw value associated with the given key, if found. Otherwise, nil is
|
|
232
|
-
# returned.
|
|
233
|
-
#
|
|
234
|
-
# It is valid to lookup keys that are not in the API spec, for example to access
|
|
235
|
-
# undocumented features. This method does not parse response data into
|
|
236
|
-
# higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
|
|
237
211
|
sig { params(key: Symbol).returns(T.nilable(T.anything)) }
|
|
238
212
|
def [](key)
|
|
239
213
|
end
|
|
240
214
|
|
|
241
|
-
# Returns a Hash of the data underlying this object. O(1)
|
|
242
|
-
#
|
|
243
|
-
# Keys are Symbols and values are the raw values from the response. The return
|
|
244
|
-
# value indicates which values were ever set on the object. i.e. there will be a
|
|
245
|
-
# key in this hash if they ever were, even if the set value was nil.
|
|
246
|
-
#
|
|
247
|
-
# This method is not recursive. The returned value is shared by the object, so it
|
|
248
|
-
# should not be mutated.
|
|
249
215
|
sig { overridable.returns(XTwitterScraper::Internal::AnyHash) }
|
|
250
216
|
def to_h
|
|
251
217
|
end
|
|
252
218
|
|
|
253
|
-
# Returns a Hash of the data underlying this object. O(1)
|
|
254
|
-
#
|
|
255
|
-
# Keys are Symbols and values are the raw values from the response. The return
|
|
256
|
-
# value indicates which values were ever set on the object. i.e. there will be a
|
|
257
|
-
# key in this hash if they ever were, even if the set value was nil.
|
|
258
|
-
#
|
|
259
|
-
# This method is not recursive. The returned value is shared by the object, so it
|
|
260
|
-
# should not be mutated.
|
|
261
219
|
sig { overridable.returns(XTwitterScraper::Internal::AnyHash) }
|
|
262
220
|
def to_hash
|
|
263
221
|
end
|
|
264
222
|
|
|
265
|
-
# In addition to the behaviour of `#to_h`, this method will recursively call
|
|
266
|
-
# `#to_h` on nested models.
|
|
267
223
|
sig { overridable.returns(XTwitterScraper::Internal::AnyHash) }
|
|
268
224
|
def deep_to_h
|
|
269
225
|
end
|
|
@@ -284,7 +240,6 @@ module XTwitterScraper
|
|
|
284
240
|
def to_yaml(*a)
|
|
285
241
|
end
|
|
286
242
|
|
|
287
|
-
# Create a new instance of a model.
|
|
288
243
|
sig do
|
|
289
244
|
params(
|
|
290
245
|
data:
|
|
@@ -298,7 +253,6 @@ module XTwitterScraper
|
|
|
298
253
|
end
|
|
299
254
|
|
|
300
255
|
class << self
|
|
301
|
-
# @api private
|
|
302
256
|
sig { params(depth: Integer).returns(String) }
|
|
303
257
|
def inspect(depth: 0)
|
|
304
258
|
end
|
|
@@ -308,7 +262,6 @@ module XTwitterScraper
|
|
|
308
262
|
def to_s
|
|
309
263
|
end
|
|
310
264
|
|
|
311
|
-
# @api private
|
|
312
265
|
sig { returns(String) }
|
|
313
266
|
def inspect
|
|
314
267
|
end
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# This module provides a base implementation for paginated responses in the SDK.
|
|
13
10
|
module BasePage
|
|
14
11
|
Elem = type_member(:out)
|
|
15
12
|
|
|
@@ -29,7 +26,6 @@ module XTwitterScraper
|
|
|
29
26
|
def to_enum
|
|
30
27
|
end
|
|
31
28
|
|
|
32
|
-
# @api private
|
|
33
29
|
sig do
|
|
34
30
|
params(
|
|
35
31
|
client: XTwitterScraper::Internal::Transport::BaseClient,
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# Ruby has no Boolean class; this is something for models to refer to.
|
|
13
10
|
class Boolean
|
|
14
11
|
extend XTwitterScraper::Internal::Type::Converter
|
|
15
12
|
extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
@@ -25,9 +22,6 @@ module XTwitterScraper
|
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
class << self
|
|
28
|
-
# @api private
|
|
29
|
-
#
|
|
30
|
-
# Coerce value to Boolean if possible, otherwise return the original value.
|
|
31
25
|
sig do
|
|
32
26
|
override
|
|
33
27
|
.params(
|
|
@@ -39,7 +33,6 @@ module XTwitterScraper
|
|
|
39
33
|
def coerce(value, state:)
|
|
40
34
|
end
|
|
41
35
|
|
|
42
|
-
# @api private
|
|
43
36
|
sig do
|
|
44
37
|
override
|
|
45
38
|
.params(
|
|
@@ -51,7 +44,6 @@ module XTwitterScraper
|
|
|
51
44
|
def dump(value, state:)
|
|
52
45
|
end
|
|
53
46
|
|
|
54
|
-
# @api private
|
|
55
47
|
sig { returns(T.anything) }
|
|
56
48
|
def to_sorbet_type
|
|
57
49
|
end
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
10
|
module Converter
|
|
12
11
|
extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
13
12
|
|
|
@@ -36,7 +35,6 @@ module XTwitterScraper
|
|
|
36
35
|
|
|
37
36
|
DumpState = T.type_alias { { can_retry: T::Boolean } }
|
|
38
37
|
|
|
39
|
-
# @api private
|
|
40
38
|
sig do
|
|
41
39
|
overridable
|
|
42
40
|
.params(
|
|
@@ -48,7 +46,6 @@ module XTwitterScraper
|
|
|
48
46
|
def coerce(value, state:)
|
|
49
47
|
end
|
|
50
48
|
|
|
51
|
-
# @api private
|
|
52
49
|
sig do
|
|
53
50
|
overridable
|
|
54
51
|
.params(
|
|
@@ -60,13 +57,11 @@ module XTwitterScraper
|
|
|
60
57
|
def dump(value, state:)
|
|
61
58
|
end
|
|
62
59
|
|
|
63
|
-
# @api private
|
|
64
60
|
sig { params(depth: Integer).returns(String) }
|
|
65
61
|
def inspect(depth: 0)
|
|
66
62
|
end
|
|
67
63
|
|
|
68
64
|
class << self
|
|
69
|
-
# @api private
|
|
70
65
|
sig do
|
|
71
66
|
params(
|
|
72
67
|
spec:
|
|
@@ -99,7 +94,6 @@ module XTwitterScraper
|
|
|
99
94
|
def self.type_info(spec)
|
|
100
95
|
end
|
|
101
96
|
|
|
102
|
-
# @api private
|
|
103
97
|
sig do
|
|
104
98
|
params(
|
|
105
99
|
type_info:
|
|
@@ -157,7 +151,6 @@ module XTwitterScraper
|
|
|
157
151
|
def self.meta_info(type_info, spec)
|
|
158
152
|
end
|
|
159
153
|
|
|
160
|
-
# @api private
|
|
161
154
|
sig do
|
|
162
155
|
params(translate_names: T::Boolean).returns(
|
|
163
156
|
XTwitterScraper::Internal::Type::Converter::CoerceState
|
|
@@ -166,17 +159,6 @@ module XTwitterScraper
|
|
|
166
159
|
def self.new_coerce_state(translate_names: true)
|
|
167
160
|
end
|
|
168
161
|
|
|
169
|
-
# @api private
|
|
170
|
-
#
|
|
171
|
-
# Based on `target`, transform `value` into `target`, to the extent possible:
|
|
172
|
-
#
|
|
173
|
-
# 1. if the given `value` conforms to `target` already, return the given `value`
|
|
174
|
-
# 2. if it's possible and safe to convert the given `value` to `target`, then the
|
|
175
|
-
# converted value
|
|
176
|
-
# 3. otherwise, the given `value` unaltered
|
|
177
|
-
#
|
|
178
|
-
# The coercion process is subject to improvement between minor release versions.
|
|
179
|
-
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
|
|
180
162
|
sig do
|
|
181
163
|
params(
|
|
182
164
|
target: XTwitterScraper::Internal::Type::Converter::Input,
|
|
@@ -187,27 +169,10 @@ module XTwitterScraper
|
|
|
187
169
|
def self.coerce(
|
|
188
170
|
target,
|
|
189
171
|
value,
|
|
190
|
-
# The `strictness` is one of `true`, `false`. This informs the coercion strategy
|
|
191
|
-
# when we have to decide between multiple possible conversion targets:
|
|
192
|
-
#
|
|
193
|
-
# - `true`: the conversion must be exact, with minimum coercion.
|
|
194
|
-
# - `false`: the conversion can be approximate, with some coercion.
|
|
195
|
-
#
|
|
196
|
-
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
|
197
|
-
# any given conversion attempt, the exactness will be updated based on how closely
|
|
198
|
-
# the value recursively matches the target type:
|
|
199
|
-
#
|
|
200
|
-
# - `yes`: the value can be converted to the target type with minimum coercion.
|
|
201
|
-
# - `maybe`: the value can be converted to the target type with some reasonable
|
|
202
|
-
# coercion.
|
|
203
|
-
# - `no`: the value cannot be converted to the target type.
|
|
204
|
-
#
|
|
205
|
-
# See implementation below for more details.
|
|
206
172
|
state: XTwitterScraper::Internal::Type::Converter.new_coerce_state
|
|
207
173
|
)
|
|
208
174
|
end
|
|
209
175
|
|
|
210
|
-
# @api private
|
|
211
176
|
sig do
|
|
212
177
|
params(
|
|
213
178
|
target: XTwitterScraper::Internal::Type::Converter::Input,
|
|
@@ -218,7 +183,6 @@ module XTwitterScraper
|
|
|
218
183
|
def self.dump(target, value, state: { can_retry: true })
|
|
219
184
|
end
|
|
220
185
|
|
|
221
|
-
# @api private
|
|
222
186
|
sig { params(target: T.anything, depth: Integer).returns(String) }
|
|
223
187
|
def self.inspect(target, depth:)
|
|
224
188
|
end
|
|
@@ -7,23 +7,10 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# A value from among a specified list of options. OpenAPI enum values map to Ruby
|
|
13
|
-
# values in the SDK as follows:
|
|
14
|
-
#
|
|
15
|
-
# 1. boolean => true | false
|
|
16
|
-
# 2. integer => Integer
|
|
17
|
-
# 3. float => Float
|
|
18
|
-
# 4. string => Symbol
|
|
19
|
-
#
|
|
20
|
-
# We can therefore convert string values to Symbols, but can't convert other
|
|
21
|
-
# values safely.
|
|
22
10
|
module Enum
|
|
23
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
24
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
25
13
|
|
|
26
|
-
# All of the valid Symbol values for this enum.
|
|
27
14
|
sig do
|
|
28
15
|
overridable.returns(
|
|
29
16
|
T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)]
|
|
@@ -44,10 +31,6 @@ module XTwitterScraper
|
|
|
44
31
|
def hash
|
|
45
32
|
end
|
|
46
33
|
|
|
47
|
-
# @api private
|
|
48
|
-
#
|
|
49
|
-
# Unlike with primitives, `Enum` additionally validates that the value is a member
|
|
50
|
-
# of the enum.
|
|
51
34
|
sig do
|
|
52
35
|
override
|
|
53
36
|
.params(
|
|
@@ -59,7 +42,6 @@ module XTwitterScraper
|
|
|
59
42
|
def coerce(value, state:)
|
|
60
43
|
end
|
|
61
44
|
|
|
62
|
-
# @api private
|
|
63
45
|
sig do
|
|
64
46
|
override
|
|
65
47
|
.params(
|
|
@@ -71,12 +53,10 @@ module XTwitterScraper
|
|
|
71
53
|
def dump(value, state:)
|
|
72
54
|
end
|
|
73
55
|
|
|
74
|
-
# @api private
|
|
75
56
|
sig { returns(T.anything) }
|
|
76
57
|
def to_sorbet_type
|
|
77
58
|
end
|
|
78
59
|
|
|
79
|
-
# @api private
|
|
80
60
|
sig { params(depth: Integer).returns(String) }
|
|
81
61
|
def inspect(depth: 0)
|
|
82
62
|
end
|
|
@@ -7,13 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# Either `Pathname` or `StringIO`, or `IO`, or
|
|
13
|
-
# `XTwitterScraper::Internal::Type::FileInput`.
|
|
14
|
-
#
|
|
15
|
-
# Note: when `IO` is used, all retries are disabled, since many IO` streams are
|
|
16
|
-
# not rewindable.
|
|
17
10
|
class FileInput
|
|
18
11
|
extend XTwitterScraper::Internal::Type::Converter
|
|
19
12
|
|
|
@@ -28,7 +21,6 @@ module XTwitterScraper
|
|
|
28
21
|
end
|
|
29
22
|
|
|
30
23
|
class << self
|
|
31
|
-
# @api private
|
|
32
24
|
sig do
|
|
33
25
|
override
|
|
34
26
|
.params(
|
|
@@ -40,7 +32,6 @@ module XTwitterScraper
|
|
|
40
32
|
def coerce(value, state:)
|
|
41
33
|
end
|
|
42
34
|
|
|
43
|
-
# @api private
|
|
44
35
|
sig do
|
|
45
36
|
override
|
|
46
37
|
.params(
|
|
@@ -52,7 +43,6 @@ module XTwitterScraper
|
|
|
52
43
|
def dump(value, state:)
|
|
53
44
|
end
|
|
54
45
|
|
|
55
|
-
# @api private
|
|
56
46
|
sig { returns(T.anything) }
|
|
57
47
|
def to_sorbet_type
|
|
58
48
|
end
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# Hash of items of a given type.
|
|
13
10
|
class HashOf
|
|
14
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
15
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
@@ -46,7 +43,6 @@ module XTwitterScraper
|
|
|
46
43
|
def hash
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
# @api private
|
|
50
46
|
sig do
|
|
51
47
|
override
|
|
52
48
|
.params(
|
|
@@ -58,7 +54,6 @@ module XTwitterScraper
|
|
|
58
54
|
def coerce(value, state:)
|
|
59
55
|
end
|
|
60
56
|
|
|
61
|
-
# @api private
|
|
62
57
|
sig do
|
|
63
58
|
override
|
|
64
59
|
.params(
|
|
@@ -70,22 +65,18 @@ module XTwitterScraper
|
|
|
70
65
|
def dump(value, state:)
|
|
71
66
|
end
|
|
72
67
|
|
|
73
|
-
# @api private
|
|
74
68
|
sig { returns(T.anything) }
|
|
75
69
|
def to_sorbet_type
|
|
76
70
|
end
|
|
77
71
|
|
|
78
|
-
# @api private
|
|
79
72
|
sig { returns(Elem) }
|
|
80
73
|
protected def item_type
|
|
81
74
|
end
|
|
82
75
|
|
|
83
|
-
# @api private
|
|
84
76
|
sig { returns(T::Boolean) }
|
|
85
77
|
protected def nilable?
|
|
86
78
|
end
|
|
87
79
|
|
|
88
|
-
# @api private
|
|
89
80
|
sig do
|
|
90
81
|
params(
|
|
91
82
|
type_info:
|
|
@@ -102,7 +93,6 @@ module XTwitterScraper
|
|
|
102
93
|
def initialize(type_info, spec = {})
|
|
103
94
|
end
|
|
104
95
|
|
|
105
|
-
# @api private
|
|
106
96
|
sig { params(depth: Integer).returns(String) }
|
|
107
97
|
def inspect(depth: 0)
|
|
108
98
|
end
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
10
|
module RequestParameters
|
|
12
|
-
# Options to specify HTTP behaviour for this request.
|
|
13
11
|
sig { returns(XTwitterScraper::RequestOptions) }
|
|
14
12
|
attr_reader :request_options
|
|
15
13
|
|
|
@@ -18,9 +16,7 @@ module XTwitterScraper
|
|
|
18
16
|
end
|
|
19
17
|
attr_writer :request_options
|
|
20
18
|
|
|
21
|
-
# @api private
|
|
22
19
|
module Converter
|
|
23
|
-
# @api private
|
|
24
20
|
sig do
|
|
25
21
|
params(params: T.anything).returns(
|
|
26
22
|
[T.anything, XTwitterScraper::Internal::AnyHash]
|
|
@@ -7,14 +7,10 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
10
|
module Union
|
|
12
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
13
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
14
13
|
|
|
15
|
-
# @api private
|
|
16
|
-
#
|
|
17
|
-
# All of the specified variant info for this union.
|
|
18
14
|
sig do
|
|
19
15
|
returns(
|
|
20
16
|
T::Array[
|
|
@@ -31,7 +27,6 @@ module XTwitterScraper
|
|
|
31
27
|
private def known_variants
|
|
32
28
|
end
|
|
33
29
|
|
|
34
|
-
# @api private
|
|
35
30
|
sig do
|
|
36
31
|
returns(
|
|
37
32
|
T::Array[
|
|
@@ -46,17 +41,14 @@ module XTwitterScraper
|
|
|
46
41
|
protected def derefed_variants
|
|
47
42
|
end
|
|
48
43
|
|
|
49
|
-
# All of the specified variants for this union.
|
|
50
44
|
sig { overridable.returns(T::Array[T.anything]) }
|
|
51
45
|
def variants
|
|
52
46
|
end
|
|
53
47
|
|
|
54
|
-
# @api private
|
|
55
48
|
sig { params(property: Symbol).void }
|
|
56
49
|
private def discriminator(property)
|
|
57
50
|
end
|
|
58
51
|
|
|
59
|
-
# @api private
|
|
60
52
|
sig do
|
|
61
53
|
params(
|
|
62
54
|
key:
|
|
@@ -77,7 +69,6 @@ module XTwitterScraper
|
|
|
77
69
|
private def variant(key, spec = nil)
|
|
78
70
|
end
|
|
79
71
|
|
|
80
|
-
# @api private
|
|
81
72
|
sig { params(value: T.anything).returns(T.nilable(T.anything)) }
|
|
82
73
|
private def resolve_variant(value)
|
|
83
74
|
end
|
|
@@ -94,12 +85,6 @@ module XTwitterScraper
|
|
|
94
85
|
def hash
|
|
95
86
|
end
|
|
96
87
|
|
|
97
|
-
# @api private
|
|
98
|
-
#
|
|
99
|
-
# Tries to efficiently coerce the given value to one of the known variants.
|
|
100
|
-
#
|
|
101
|
-
# If the value cannot match any of the known variants, the coercion is considered
|
|
102
|
-
# non-viable and returns the original value.
|
|
103
88
|
sig do
|
|
104
89
|
override
|
|
105
90
|
.params(
|
|
@@ -111,7 +96,6 @@ module XTwitterScraper
|
|
|
111
96
|
def coerce(value, state:)
|
|
112
97
|
end
|
|
113
98
|
|
|
114
|
-
# @api private
|
|
115
99
|
sig do
|
|
116
100
|
override
|
|
117
101
|
.params(
|
|
@@ -123,12 +107,10 @@ module XTwitterScraper
|
|
|
123
107
|
def dump(value, state:)
|
|
124
108
|
end
|
|
125
109
|
|
|
126
|
-
# @api private
|
|
127
110
|
sig { returns(T.anything) }
|
|
128
111
|
def to_sorbet_type
|
|
129
112
|
end
|
|
130
113
|
|
|
131
|
-
# @api private
|
|
132
114
|
sig { params(depth: Integer).returns(String) }
|
|
133
115
|
def inspect(depth: 0)
|
|
134
116
|
end
|
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# When we don't know what to expect for the value.
|
|
13
10
|
class Unknown
|
|
14
11
|
extend XTwitterScraper::Internal::Type::Converter
|
|
15
12
|
extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
@@ -25,9 +22,6 @@ module XTwitterScraper
|
|
|
25
22
|
end
|
|
26
23
|
|
|
27
24
|
class << self
|
|
28
|
-
# @api private
|
|
29
|
-
#
|
|
30
|
-
# No coercion needed for Unknown type.
|
|
31
25
|
sig do
|
|
32
26
|
override
|
|
33
27
|
.params(
|
|
@@ -39,7 +33,6 @@ module XTwitterScraper
|
|
|
39
33
|
def coerce(value, state:)
|
|
40
34
|
end
|
|
41
35
|
|
|
42
|
-
# @api private
|
|
43
36
|
sig do
|
|
44
37
|
override
|
|
45
38
|
.params(
|
|
@@ -51,7 +44,6 @@ module XTwitterScraper
|
|
|
51
44
|
def dump(value, state:)
|
|
52
45
|
end
|
|
53
46
|
|
|
54
|
-
# @api private
|
|
55
47
|
sig { returns(T.anything) }
|
|
56
48
|
def to_sorbet_type
|
|
57
49
|
end
|