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
|
@@ -7,40 +7,12 @@
|
|
|
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
|
|
|
14
13
|
# rubocop:disable Lint/UnusedMethodArgument
|
|
15
|
-
|
|
16
|
-
# @api private
|
|
17
|
-
#
|
|
18
|
-
# @param value [Object]
|
|
19
|
-
#
|
|
20
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
21
|
-
#
|
|
22
|
-
# @option state [Boolean] :translate_names
|
|
23
|
-
#
|
|
24
|
-
# @option state [Boolean] :strictness
|
|
25
|
-
#
|
|
26
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
27
|
-
#
|
|
28
|
-
# @option state [Class<StandardError>] :error
|
|
29
|
-
#
|
|
30
|
-
# @option state [Integer] :branched
|
|
31
|
-
#
|
|
32
|
-
# @return [Object]
|
|
33
14
|
def coerce(value, state:) = (raise NotImplementedError)
|
|
34
15
|
|
|
35
|
-
# @api private
|
|
36
|
-
#
|
|
37
|
-
# @param value [Object]
|
|
38
|
-
#
|
|
39
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
40
|
-
#
|
|
41
|
-
# @option state [Boolean] :can_retry
|
|
42
|
-
#
|
|
43
|
-
# @return [Object]
|
|
44
16
|
def dump(value, state:)
|
|
45
17
|
case value
|
|
46
18
|
in Array
|
|
@@ -62,31 +34,12 @@ module XTwitterScraper
|
|
|
62
34
|
end
|
|
63
35
|
end
|
|
64
36
|
|
|
65
|
-
# @api private
|
|
66
|
-
#
|
|
67
|
-
# @param depth [Integer]
|
|
68
|
-
#
|
|
69
|
-
# @return [String]
|
|
70
37
|
def inspect(depth: 0)
|
|
71
38
|
super()
|
|
72
39
|
end
|
|
73
40
|
|
|
74
41
|
# rubocop:enable Lint/UnusedMethodArgument
|
|
75
|
-
|
|
76
42
|
class << self
|
|
77
|
-
# @api private
|
|
78
|
-
#
|
|
79
|
-
# @param spec [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class] .
|
|
80
|
-
#
|
|
81
|
-
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
82
|
-
#
|
|
83
|
-
# @option spec [Proc] :enum
|
|
84
|
-
#
|
|
85
|
-
# @option spec [Proc] :union
|
|
86
|
-
#
|
|
87
|
-
# @option spec [Boolean] :"nil?"
|
|
88
|
-
#
|
|
89
|
-
# @return [Proc]
|
|
90
43
|
def type_info(spec)
|
|
91
44
|
case spec
|
|
92
45
|
in Proc
|
|
@@ -102,38 +55,10 @@ module XTwitterScraper
|
|
|
102
55
|
end
|
|
103
56
|
end
|
|
104
57
|
|
|
105
|
-
# @api private
|
|
106
|
-
#
|
|
107
|
-
# @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class] .
|
|
108
|
-
#
|
|
109
|
-
# @option type_info [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
110
|
-
#
|
|
111
|
-
# @option type_info [Proc] :enum
|
|
112
|
-
#
|
|
113
|
-
# @option type_info [Proc] :union
|
|
114
|
-
#
|
|
115
|
-
# @option type_info [Boolean] :"nil?"
|
|
116
|
-
#
|
|
117
|
-
# @param spec [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class] .
|
|
118
|
-
#
|
|
119
|
-
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
120
|
-
#
|
|
121
|
-
# @option spec [Proc] :enum
|
|
122
|
-
#
|
|
123
|
-
# @option spec [Proc] :union
|
|
124
|
-
#
|
|
125
|
-
# @option spec [Boolean] :"nil?"
|
|
126
|
-
#
|
|
127
|
-
# @return [Hash{Symbol=>Object}]
|
|
128
58
|
def meta_info(type_info, spec)
|
|
129
59
|
[spec, type_info].grep(Hash).first.to_h.except(:const, :enum, :union, :nil?)
|
|
130
60
|
end
|
|
131
61
|
|
|
132
|
-
# @api private
|
|
133
|
-
#
|
|
134
|
-
# @param translate_names [Boolean]
|
|
135
|
-
#
|
|
136
|
-
# @return [Hash{Symbol=>Object}]
|
|
137
62
|
def new_coerce_state(translate_names: true)
|
|
138
63
|
{
|
|
139
64
|
translate_names: translate_names,
|
|
@@ -144,50 +69,6 @@ module XTwitterScraper
|
|
|
144
69
|
}
|
|
145
70
|
end
|
|
146
71
|
|
|
147
|
-
# @api private
|
|
148
|
-
#
|
|
149
|
-
# Based on `target`, transform `value` into `target`, to the extent possible:
|
|
150
|
-
#
|
|
151
|
-
# 1. if the given `value` conforms to `target` already, return the given `value`
|
|
152
|
-
# 2. if it's possible and safe to convert the given `value` to `target`, then the
|
|
153
|
-
# converted value
|
|
154
|
-
# 3. otherwise, the given `value` unaltered
|
|
155
|
-
#
|
|
156
|
-
# The coercion process is subject to improvement between minor release versions.
|
|
157
|
-
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
|
|
158
|
-
#
|
|
159
|
-
# @param target [XTwitterScraper::Internal::Type::Converter, Class]
|
|
160
|
-
#
|
|
161
|
-
# @param value [Object]
|
|
162
|
-
#
|
|
163
|
-
# @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy
|
|
164
|
-
# when we have to decide between multiple possible conversion targets:
|
|
165
|
-
#
|
|
166
|
-
# - `true`: the conversion must be exact, with minimum coercion.
|
|
167
|
-
# - `false`: the conversion can be approximate, with some coercion.
|
|
168
|
-
#
|
|
169
|
-
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
|
170
|
-
# any given conversion attempt, the exactness will be updated based on how closely
|
|
171
|
-
# the value recursively matches the target type:
|
|
172
|
-
#
|
|
173
|
-
# - `yes`: the value can be converted to the target type with minimum coercion.
|
|
174
|
-
# - `maybe`: the value can be converted to the target type with some reasonable
|
|
175
|
-
# coercion.
|
|
176
|
-
# - `no`: the value cannot be converted to the target type.
|
|
177
|
-
#
|
|
178
|
-
# See implementation below for more details.
|
|
179
|
-
#
|
|
180
|
-
# @option state [Boolean] :translate_names
|
|
181
|
-
#
|
|
182
|
-
# @option state [Boolean] :strictness
|
|
183
|
-
#
|
|
184
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
185
|
-
#
|
|
186
|
-
# @option state [Class<StandardError>] :error
|
|
187
|
-
#
|
|
188
|
-
# @option state [Integer] :branched
|
|
189
|
-
#
|
|
190
|
-
# @return [Object]
|
|
191
72
|
def coerce(target, value, state: XTwitterScraper::Internal::Type::Converter.new_coerce_state)
|
|
192
73
|
# rubocop:disable Metrics/BlockNesting
|
|
193
74
|
exactness = state.fetch(:exactness)
|
|
@@ -272,17 +153,6 @@ module XTwitterScraper
|
|
|
272
153
|
# rubocop:enable Metrics/BlockNesting
|
|
273
154
|
end
|
|
274
155
|
|
|
275
|
-
# @api private
|
|
276
|
-
#
|
|
277
|
-
# @param target [XTwitterScraper::Internal::Type::Converter, Class]
|
|
278
|
-
#
|
|
279
|
-
# @param value [Object]
|
|
280
|
-
#
|
|
281
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
282
|
-
#
|
|
283
|
-
# @option state [Boolean] :can_retry
|
|
284
|
-
#
|
|
285
|
-
# @return [Object]
|
|
286
156
|
def dump(target, value, state: {can_retry: true})
|
|
287
157
|
case target
|
|
288
158
|
in XTwitterScraper::Internal::Type::Converter
|
|
@@ -292,12 +162,6 @@ module XTwitterScraper
|
|
|
292
162
|
end
|
|
293
163
|
end
|
|
294
164
|
|
|
295
|
-
# @api private
|
|
296
|
-
#
|
|
297
|
-
# @param target [Object]
|
|
298
|
-
# @param depth [Integer]
|
|
299
|
-
#
|
|
300
|
-
# @return [String]
|
|
301
165
|
def inspect(target, depth:)
|
|
302
166
|
case target
|
|
303
167
|
in XTwitterScraper::Internal::Type::Converter
|
|
@@ -7,50 +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
|
-
#
|
|
23
|
-
# @example
|
|
24
|
-
# # `event_type` is a `XTwitterScraper::EventType`
|
|
25
|
-
# case event_type
|
|
26
|
-
# when XTwitterScraper::EventType::TWEET_NEW
|
|
27
|
-
# # ...
|
|
28
|
-
# when XTwitterScraper::EventType::TWEET_REPLY
|
|
29
|
-
# # ...
|
|
30
|
-
# when XTwitterScraper::EventType::TWEET_RETWEET
|
|
31
|
-
# # ...
|
|
32
|
-
# else
|
|
33
|
-
# puts(event_type)
|
|
34
|
-
# end
|
|
35
|
-
#
|
|
36
|
-
# @example
|
|
37
|
-
# case event_type
|
|
38
|
-
# in :"tweet.new"
|
|
39
|
-
# # ...
|
|
40
|
-
# in :"tweet.reply"
|
|
41
|
-
# # ...
|
|
42
|
-
# in :"tweet.retweet"
|
|
43
|
-
# # ...
|
|
44
|
-
# else
|
|
45
|
-
# puts(event_type)
|
|
46
|
-
# end
|
|
47
10
|
module Enum
|
|
48
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
49
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
50
13
|
|
|
51
|
-
# All of the valid Symbol values for this enum.
|
|
52
|
-
#
|
|
53
|
-
# @return [Array<NilClass, Boolean, Integer, Float, Symbol>]
|
|
54
14
|
def values = constants.map { const_get(_1) }
|
|
55
15
|
|
|
56
16
|
# @api public
|
|
@@ -66,9 +26,8 @@ module XTwitterScraper
|
|
|
66
26
|
#
|
|
67
27
|
# @return [Boolean]
|
|
68
28
|
def ==(other)
|
|
69
|
-
# rubocop:disable Style/CaseEquality
|
|
29
|
+
# rubocop:disable-next Style/CaseEquality
|
|
70
30
|
XTwitterScraper::Internal::Type::Enum === other && other.values.to_set == values.to_set
|
|
71
|
-
# rubocop:enable Style/CaseEquality
|
|
72
31
|
end
|
|
73
32
|
|
|
74
33
|
# @api public
|
|
@@ -76,25 +35,6 @@ module XTwitterScraper
|
|
|
76
35
|
# @return [Integer]
|
|
77
36
|
def hash = values.to_set.hash
|
|
78
37
|
|
|
79
|
-
# @api private
|
|
80
|
-
#
|
|
81
|
-
# Unlike primitives, `Enum` validates membership.
|
|
82
|
-
#
|
|
83
|
-
# @param value [String, Symbol, Object]
|
|
84
|
-
#
|
|
85
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
86
|
-
#
|
|
87
|
-
# @option state [Boolean] :translate_names
|
|
88
|
-
#
|
|
89
|
-
# @option state [Boolean] :strictness
|
|
90
|
-
#
|
|
91
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
92
|
-
#
|
|
93
|
-
# @option state [Class<StandardError>] :error
|
|
94
|
-
#
|
|
95
|
-
# @option state [Integer] :branched
|
|
96
|
-
#
|
|
97
|
-
# @return [Symbol, Object]
|
|
98
38
|
def coerce(value, state:)
|
|
99
39
|
exactness = state.fetch(:exactness)
|
|
100
40
|
val = value.is_a?(String) ? value.to_sym : value
|
|
@@ -112,20 +52,6 @@ module XTwitterScraper
|
|
|
112
52
|
end
|
|
113
53
|
end
|
|
114
54
|
|
|
115
|
-
# @!method dump(value, state:)
|
|
116
|
-
# @api private
|
|
117
|
-
#
|
|
118
|
-
# @param value [Symbol, Object]
|
|
119
|
-
#
|
|
120
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
121
|
-
#
|
|
122
|
-
# @option state [Boolean] :can_retry
|
|
123
|
-
#
|
|
124
|
-
# @return [Symbol, Object]
|
|
125
|
-
|
|
126
|
-
# @api private
|
|
127
|
-
#
|
|
128
|
-
# @return [Object]
|
|
129
55
|
def to_sorbet_type
|
|
130
56
|
types = values.map { XTwitterScraper::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
|
|
131
57
|
case types
|
|
@@ -138,11 +64,6 @@ module XTwitterScraper
|
|
|
138
64
|
end
|
|
139
65
|
end
|
|
140
66
|
|
|
141
|
-
# @api private
|
|
142
|
-
#
|
|
143
|
-
# @param depth [Integer]
|
|
144
|
-
#
|
|
145
|
-
# @return [String]
|
|
146
67
|
def inspect(depth: 0)
|
|
147
68
|
if depth.positive?
|
|
148
69
|
return is_a?(Module) ? super() : self.class.name
|
|
@@ -7,15 +7,6 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# @abstract
|
|
13
|
-
#
|
|
14
|
-
# Either `Pathname` or `StringIO`, or `IO`, or
|
|
15
|
-
# `XTwitterScraper::Internal::Type::FileInput`.
|
|
16
|
-
#
|
|
17
|
-
# Note: when `IO` is used, all retries are disabled, since many IO` streams are
|
|
18
|
-
# not rewindable.
|
|
19
10
|
class FileInput
|
|
20
11
|
extend XTwitterScraper::Internal::Type::Converter
|
|
21
12
|
|
|
@@ -43,23 +34,6 @@ module XTwitterScraper
|
|
|
43
34
|
def self.==(other) = other.is_a?(Class) && other <= XTwitterScraper::Internal::Type::FileInput
|
|
44
35
|
|
|
45
36
|
class << self
|
|
46
|
-
# @api private
|
|
47
|
-
#
|
|
48
|
-
# @param value [StringIO, String, Object]
|
|
49
|
-
#
|
|
50
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
51
|
-
#
|
|
52
|
-
# @option state [Boolean] :translate_names
|
|
53
|
-
#
|
|
54
|
-
# @option state [Boolean] :strictness
|
|
55
|
-
#
|
|
56
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
57
|
-
#
|
|
58
|
-
# @option state [Class<StandardError>] :error
|
|
59
|
-
#
|
|
60
|
-
# @option state [Integer] :branched
|
|
61
|
-
#
|
|
62
|
-
# @return [StringIO, Object]
|
|
63
37
|
def coerce(value, state:)
|
|
64
38
|
exactness = state.fetch(:exactness)
|
|
65
39
|
case value
|
|
@@ -76,20 +50,10 @@ module XTwitterScraper
|
|
|
76
50
|
end
|
|
77
51
|
end
|
|
78
52
|
|
|
79
|
-
# @api private
|
|
80
|
-
#
|
|
81
|
-
# @param value [Pathname, StringIO, IO, String, Object]
|
|
82
|
-
#
|
|
83
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
84
|
-
#
|
|
85
|
-
# @option state [Boolean] :can_retry
|
|
86
|
-
#
|
|
87
|
-
# @return [Pathname, StringIO, IO, String, Object]
|
|
88
53
|
def dump(value, state:)
|
|
89
54
|
case value
|
|
90
55
|
in StringIO | String
|
|
91
56
|
# https://datatracker.ietf.org/doc/html/rfc7578#section-4.2
|
|
92
|
-
# while not required, a filename is recommended, and in practice many servers do expect this
|
|
93
57
|
XTwitterScraper::FilePart.new(value, filename: "upload")
|
|
94
58
|
in IO
|
|
95
59
|
state[:can_retry] = false
|
|
@@ -102,9 +66,6 @@ module XTwitterScraper
|
|
|
102
66
|
end
|
|
103
67
|
end
|
|
104
68
|
|
|
105
|
-
# @api private
|
|
106
|
-
#
|
|
107
|
-
# @return [Object]
|
|
108
69
|
def to_sorbet_type
|
|
109
70
|
T.any(Pathname, StringIO, IO, String, XTwitterScraper::FilePart)
|
|
110
71
|
end
|
|
@@ -7,34 +7,12 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# @abstract
|
|
13
|
-
#
|
|
14
|
-
# @generic Elem
|
|
15
|
-
#
|
|
16
|
-
# Hash of items of a given type.
|
|
17
10
|
class HashOf
|
|
18
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
19
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
20
13
|
|
|
21
14
|
private_class_method :new
|
|
22
15
|
|
|
23
|
-
# @overload [](type_info, spec = {})
|
|
24
|
-
#
|
|
25
|
-
# @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
|
|
26
|
-
#
|
|
27
|
-
# @param spec [Hash{Symbol=>Object}] .
|
|
28
|
-
#
|
|
29
|
-
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
30
|
-
#
|
|
31
|
-
# @option spec [Proc] :enum
|
|
32
|
-
#
|
|
33
|
-
# @option spec [Proc] :union
|
|
34
|
-
#
|
|
35
|
-
# @option spec [Boolean] :"nil?"
|
|
36
|
-
#
|
|
37
|
-
# @return [self]
|
|
38
16
|
def self.[](...) = new(...)
|
|
39
17
|
|
|
40
18
|
# @api public
|
|
@@ -65,9 +43,8 @@ module XTwitterScraper
|
|
|
65
43
|
#
|
|
66
44
|
# @return [Boolean]
|
|
67
45
|
def ==(other)
|
|
68
|
-
# rubocop:disable Layout/LineLength
|
|
46
|
+
# rubocop:disable-next Layout/LineLength
|
|
69
47
|
other.is_a?(XTwitterScraper::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type
|
|
70
|
-
# rubocop:enable Layout/LineLength
|
|
71
48
|
end
|
|
72
49
|
|
|
73
50
|
# @api public
|
|
@@ -75,23 +52,6 @@ module XTwitterScraper
|
|
|
75
52
|
# @return [Integer]
|
|
76
53
|
def hash = [self.class, item_type].hash
|
|
77
54
|
|
|
78
|
-
# @api private
|
|
79
|
-
#
|
|
80
|
-
# @param value [Hash{Object=>Object}, Object]
|
|
81
|
-
#
|
|
82
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
83
|
-
#
|
|
84
|
-
# @option state [Boolean] :translate_names
|
|
85
|
-
#
|
|
86
|
-
# @option state [Boolean] :strictness
|
|
87
|
-
#
|
|
88
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
89
|
-
#
|
|
90
|
-
# @option state [Class<StandardError>] :error
|
|
91
|
-
#
|
|
92
|
-
# @option state [Integer] :branched
|
|
93
|
-
#
|
|
94
|
-
# @return [Hash{Symbol=>Object}, Object]
|
|
95
55
|
def coerce(value, state:)
|
|
96
56
|
exactness = state.fetch(:exactness)
|
|
97
57
|
|
|
@@ -120,15 +80,6 @@ module XTwitterScraper
|
|
|
120
80
|
end
|
|
121
81
|
end
|
|
122
82
|
|
|
123
|
-
# @api private
|
|
124
|
-
#
|
|
125
|
-
# @param value [Hash{Object=>Object}, Object]
|
|
126
|
-
#
|
|
127
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
128
|
-
#
|
|
129
|
-
# @option state [Boolean] :can_retry
|
|
130
|
-
#
|
|
131
|
-
# @return [Hash{Symbol=>Object}, Object]
|
|
132
83
|
def dump(value, state:)
|
|
133
84
|
target = item_type
|
|
134
85
|
if value.is_a?(Hash)
|
|
@@ -140,47 +91,20 @@ module XTwitterScraper
|
|
|
140
91
|
end
|
|
141
92
|
end
|
|
142
93
|
|
|
143
|
-
# @api private
|
|
144
|
-
#
|
|
145
|
-
# @return [Object]
|
|
146
94
|
def to_sorbet_type
|
|
147
95
|
T::Hash[XTwitterScraper::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
|
|
148
96
|
end
|
|
149
97
|
|
|
150
|
-
# @api private
|
|
151
|
-
#
|
|
152
|
-
# @return [generic<Elem>]
|
|
153
98
|
protected def item_type = @item_type_fn.call
|
|
154
99
|
|
|
155
|
-
# @api private
|
|
156
|
-
#
|
|
157
|
-
# @return [Boolean]
|
|
158
100
|
protected def nilable? = @nilable
|
|
159
101
|
|
|
160
|
-
# @api private
|
|
161
|
-
#
|
|
162
|
-
# @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
|
|
163
|
-
#
|
|
164
|
-
# @param spec [Hash{Symbol=>Object}] .
|
|
165
|
-
#
|
|
166
|
-
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
167
|
-
#
|
|
168
|
-
# @option spec [Proc] :enum
|
|
169
|
-
#
|
|
170
|
-
# @option spec [Proc] :union
|
|
171
|
-
#
|
|
172
|
-
# @option spec [Boolean] :"nil?"
|
|
173
102
|
def initialize(type_info, spec = {})
|
|
174
103
|
@item_type_fn = XTwitterScraper::Internal::Type::Converter.type_info(type_info || spec)
|
|
175
104
|
@meta = XTwitterScraper::Internal::Type::Converter.meta_info(type_info, spec)
|
|
176
105
|
@nilable = spec.fetch(:nil?, false)
|
|
177
106
|
end
|
|
178
107
|
|
|
179
|
-
# @api private
|
|
180
|
-
#
|
|
181
|
-
# @param depth [Integer]
|
|
182
|
-
#
|
|
183
|
-
# @return [String]
|
|
184
108
|
def inspect(depth: 0)
|
|
185
109
|
items = XTwitterScraper::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
|
|
186
110
|
|
|
@@ -7,27 +7,14 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
10
|
module RequestParameters
|
|
12
|
-
# @!attribute request_options
|
|
13
|
-
# Options to specify HTTP behaviour for this request.
|
|
14
|
-
#
|
|
15
|
-
# @return [XTwitterScraper::RequestOptions, Hash{Symbol=>Object}]
|
|
16
|
-
|
|
17
|
-
# @param mod [Module]
|
|
18
11
|
def self.included(mod)
|
|
19
12
|
raise ArgumentError.new(mod) unless mod <= XTwitterScraper::Internal::Type::BaseModel
|
|
20
13
|
|
|
21
14
|
mod.optional(:request_options, XTwitterScraper::RequestOptions)
|
|
22
15
|
end
|
|
23
16
|
|
|
24
|
-
# @api private
|
|
25
17
|
module Converter
|
|
26
|
-
# @api private
|
|
27
|
-
#
|
|
28
|
-
# @param params [Object]
|
|
29
|
-
#
|
|
30
|
-
# @return [Array(Object, Hash{Symbol=>Object})]
|
|
31
18
|
def dump_request(params)
|
|
32
19
|
state = {can_retry: true}
|
|
33
20
|
case (dumped = dump(params, state: state))
|
|
@@ -7,62 +7,18 @@
|
|
|
7
7
|
module XTwitterScraper
|
|
8
8
|
module Internal
|
|
9
9
|
module Type
|
|
10
|
-
# @api private
|
|
11
|
-
#
|
|
12
|
-
# @example
|
|
13
|
-
# # `account_connection_attempt_retrieve_response` is a `XTwitterScraper::Models::X::AccountConnectionAttemptRetrieveResponse`
|
|
14
|
-
# case account_connection_attempt_retrieve_response
|
|
15
|
-
# when XTwitterScraper::Models::X::AccountConnectionAttemptRetrieveResponse::Pending
|
|
16
|
-
# puts(account_connection_attempt_retrieve_response.id)
|
|
17
|
-
# when XTwitterScraper::Models::X::AccountConnectionAttemptRetrieveResponse::Success
|
|
18
|
-
# puts(account_connection_attempt_retrieve_response.object)
|
|
19
|
-
# when XTwitterScraper::Models::X::AccountConnectionAttemptRetrieveResponse::Failed
|
|
20
|
-
# puts(account_connection_attempt_retrieve_response.error)
|
|
21
|
-
# when XTwitterScraper::Models::X::AccountConnectionAttemptRetrieveResponse::RequiresEmailCode
|
|
22
|
-
# puts(account_connection_attempt_retrieve_response.message)
|
|
23
|
-
# else
|
|
24
|
-
# puts(account_connection_attempt_retrieve_response)
|
|
25
|
-
# end
|
|
26
|
-
#
|
|
27
|
-
# @example
|
|
28
|
-
# case account_connection_attempt_retrieve_response
|
|
29
|
-
# in {status: :pending, id: id, object: object, poll_after_ms: poll_after_ms}
|
|
30
|
-
# puts(id)
|
|
31
|
-
# in {status: :success, id: id, object: object}
|
|
32
|
-
# puts(object)
|
|
33
|
-
# in {status: :failed, id: id, error: error, object: object}
|
|
34
|
-
# puts(error)
|
|
35
|
-
# in {status: :requires_email_code, id: id, message: message}
|
|
36
|
-
# puts(message)
|
|
37
|
-
# else
|
|
38
|
-
# puts(account_connection_attempt_retrieve_response)
|
|
39
|
-
# end
|
|
40
10
|
module Union
|
|
41
11
|
include XTwitterScraper::Internal::Type::Converter
|
|
42
12
|
include XTwitterScraper::Internal::Util::SorbetRuntimeSupport
|
|
43
13
|
|
|
44
|
-
# @api private
|
|
45
|
-
#
|
|
46
|
-
# All of the specified variant info for this union.
|
|
47
|
-
#
|
|
48
|
-
# @return [Array<Array(Symbol, Proc, Hash{Symbol=>Object})>]
|
|
49
14
|
private def known_variants = (@known_variants ||= [])
|
|
50
15
|
|
|
51
|
-
# @api private
|
|
52
|
-
#
|
|
53
|
-
# @return [Array<Array(Symbol, Object, Hash{Symbol=>Object})>]
|
|
54
16
|
protected def derefed_variants
|
|
55
17
|
known_variants.map { |key, variant_fn, meta| [key, variant_fn.call, meta] }
|
|
56
18
|
end
|
|
57
19
|
|
|
58
|
-
# All of the specified variants for this union.
|
|
59
|
-
#
|
|
60
|
-
# @return [Array<Object>]
|
|
61
20
|
def variants = derefed_variants.map { _2 }
|
|
62
21
|
|
|
63
|
-
# @api private
|
|
64
|
-
#
|
|
65
|
-
# @param property [Symbol]
|
|
66
22
|
private def discriminator(property)
|
|
67
23
|
case property
|
|
68
24
|
in Symbol
|
|
@@ -70,19 +26,6 @@ module XTwitterScraper
|
|
|
70
26
|
end
|
|
71
27
|
end
|
|
72
28
|
|
|
73
|
-
# @api private
|
|
74
|
-
#
|
|
75
|
-
# @param key [Symbol, Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
|
|
76
|
-
#
|
|
77
|
-
# @param spec [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class] .
|
|
78
|
-
#
|
|
79
|
-
# @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
|
|
80
|
-
#
|
|
81
|
-
# @option spec [Proc] :enum
|
|
82
|
-
#
|
|
83
|
-
# @option spec [Proc] :union
|
|
84
|
-
#
|
|
85
|
-
# @option spec [Boolean] :"nil?"
|
|
86
29
|
private def variant(key, spec = nil)
|
|
87
30
|
meta = XTwitterScraper::Internal::Type::Converter.meta_info(nil, spec)
|
|
88
31
|
variant_info =
|
|
@@ -96,11 +39,6 @@ module XTwitterScraper
|
|
|
96
39
|
known_variants << variant_info
|
|
97
40
|
end
|
|
98
41
|
|
|
99
|
-
# @api private
|
|
100
|
-
#
|
|
101
|
-
# @param value [Object]
|
|
102
|
-
#
|
|
103
|
-
# @return [XTwitterScraper::Internal::Type::Converter, Class, nil]
|
|
104
42
|
private def resolve_variant(value)
|
|
105
43
|
case [@discriminator, value]
|
|
106
44
|
in [_, XTwitterScraper::Internal::Type::BaseModel]
|
|
@@ -148,28 +86,6 @@ module XTwitterScraper
|
|
|
148
86
|
# @return [Integer]
|
|
149
87
|
def hash = variants.hash
|
|
150
88
|
|
|
151
|
-
# @api private
|
|
152
|
-
#
|
|
153
|
-
# Tries to efficiently coerce the given value to one of the known variants.
|
|
154
|
-
#
|
|
155
|
-
# If the value cannot match any of the known variants, the coercion is considered
|
|
156
|
-
# non-viable and returns the original value.
|
|
157
|
-
#
|
|
158
|
-
# @param value [Object]
|
|
159
|
-
#
|
|
160
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
161
|
-
#
|
|
162
|
-
# @option state [Boolean] :translate_names
|
|
163
|
-
#
|
|
164
|
-
# @option state [Boolean] :strictness
|
|
165
|
-
#
|
|
166
|
-
# @option state [Hash{Symbol=>Object}] :exactness
|
|
167
|
-
#
|
|
168
|
-
# @option state [Class<StandardError>] :error
|
|
169
|
-
#
|
|
170
|
-
# @option state [Integer] :branched
|
|
171
|
-
#
|
|
172
|
-
# @return [Object]
|
|
173
89
|
def coerce(value, state:)
|
|
174
90
|
if (target = resolve_variant(value))
|
|
175
91
|
return XTwitterScraper::Internal::Type::Converter.coerce(target, value, state: state)
|
|
@@ -209,15 +125,6 @@ module XTwitterScraper
|
|
|
209
125
|
state[:strictness] = strictness
|
|
210
126
|
end
|
|
211
127
|
|
|
212
|
-
# @api private
|
|
213
|
-
#
|
|
214
|
-
# @param value [Object]
|
|
215
|
-
#
|
|
216
|
-
# @param state [Hash{Symbol=>Object}] .
|
|
217
|
-
#
|
|
218
|
-
# @option state [Boolean] :can_retry
|
|
219
|
-
#
|
|
220
|
-
# @return [Object]
|
|
221
128
|
def dump(value, state:)
|
|
222
129
|
if (target = resolve_variant(value))
|
|
223
130
|
return XTwitterScraper::Internal::Type::Converter.dump(target, value, state: state)
|
|
@@ -237,9 +144,6 @@ module XTwitterScraper
|
|
|
237
144
|
super
|
|
238
145
|
end
|
|
239
146
|
|
|
240
|
-
# @api private
|
|
241
|
-
#
|
|
242
|
-
# @return [Object]
|
|
243
147
|
def to_sorbet_type
|
|
244
148
|
types = variants.map do
|
|
245
149
|
XTwitterScraper::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1)
|
|
@@ -257,11 +161,6 @@ module XTwitterScraper
|
|
|
257
161
|
# rubocop:enable Style/CaseEquality
|
|
258
162
|
# rubocop:enable Style/HashEachMethods
|
|
259
163
|
|
|
260
|
-
# @api private
|
|
261
|
-
#
|
|
262
|
-
# @param depth [Integer]
|
|
263
|
-
#
|
|
264
|
-
# @return [String]
|
|
265
164
|
def inspect(depth: 0)
|
|
266
165
|
if depth.positive?
|
|
267
166
|
return is_a?(Module) ? super() : self.class.name
|