x-twitter-scraper 0.10.5 → 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.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +49 -17
  4. data/lib/x_twitter_scraper/client.rb +0 -13
  5. data/lib/x_twitter_scraper/file_part.rb +0 -3
  6. data/lib/x_twitter_scraper/internal/transport/base_client.rb +3 -211
  7. data/lib/x_twitter_scraper/internal/transport/pooled_net_requester.rb +2 -56
  8. data/lib/x_twitter_scraper/internal/type/array_of.rb +1 -77
  9. data/lib/x_twitter_scraper/internal/type/base_model.rb +3 -133
  10. data/lib/x_twitter_scraper/internal/type/base_page.rb +0 -13
  11. data/lib/x_twitter_scraper/internal/type/boolean.rb +0 -38
  12. data/lib/x_twitter_scraper/internal/type/converter.rb +0 -136
  13. data/lib/x_twitter_scraper/internal/type/enum.rb +1 -80
  14. data/lib/x_twitter_scraper/internal/type/file_input.rb +0 -39
  15. data/lib/x_twitter_scraper/internal/type/hash_of.rb +1 -77
  16. data/lib/x_twitter_scraper/internal/type/request_parameters.rb +0 -13
  17. data/lib/x_twitter_scraper/internal/type/union.rb +0 -101
  18. data/lib/x_twitter_scraper/internal/type/unknown.rb +0 -40
  19. data/lib/x_twitter_scraper/internal/util.rb +2 -307
  20. data/lib/x_twitter_scraper/models/account_retrieve_response.rb +0 -3
  21. data/lib/x_twitter_scraper/models/compose_create_params.rb +0 -4
  22. data/lib/x_twitter_scraper/models/compose_create_response.rb +0 -4
  23. data/lib/x_twitter_scraper/models/credit_retrieve_balance_response.rb +0 -3
  24. data/lib/x_twitter_scraper/models/credit_topup_balance_response.rb +0 -3
  25. data/lib/x_twitter_scraper/models/draft_list_params.rb +0 -3
  26. data/lib/x_twitter_scraper/models/draw_export_params.rb +0 -3
  27. data/lib/x_twitter_scraper/models/draw_list_params.rb +0 -3
  28. data/lib/x_twitter_scraper/models/draw_run_response.rb +0 -3
  29. data/lib/x_twitter_scraper/models/embedded_tweet.rb +0 -3
  30. data/lib/x_twitter_scraper/models/event.rb +0 -3
  31. data/lib/x_twitter_scraper/models/event_list_params.rb +0 -3
  32. data/lib/x_twitter_scraper/models/extraction_estimate_cost_params.rb +0 -3
  33. data/lib/x_twitter_scraper/models/extraction_list_params.rb +0 -3
  34. data/lib/x_twitter_scraper/models/extraction_run_params.rb +0 -3
  35. data/lib/x_twitter_scraper/models/guest_wallet_create_response.rb +0 -3
  36. data/lib/x_twitter_scraper/models/guest_wallet_retrieve_status_response.rb +0 -3
  37. data/lib/x_twitter_scraper/models/guest_wallet_topup_response.rb +0 -3
  38. data/lib/x_twitter_scraper/models/radar_item.rb +0 -3
  39. data/lib/x_twitter_scraper/models/radar_retrieve_trending_topics_params.rb +0 -3
  40. data/lib/x_twitter_scraper/models/search_tweet.rb +0 -3
  41. data/lib/x_twitter_scraper/models/trend_list_params.rb +0 -3
  42. data/lib/x_twitter_scraper/models/webhook.rb +0 -3
  43. data/lib/x_twitter_scraper/models/x/communities/join_create_response.rb +0 -3
  44. data/lib/x_twitter_scraper/models/x/communities/join_delete_all_response.rb +0 -4
  45. data/lib/x_twitter_scraper/models/x/communities/tweet_list_by_community_params.rb +0 -4
  46. data/lib/x_twitter_scraper/models/x/communities/tweet_list_params.rb +0 -3
  47. data/lib/x_twitter_scraper/models/x/community_create_response.rb +0 -3
  48. data/lib/x_twitter_scraper/models/x/community_delete_response.rb +0 -3
  49. data/lib/x_twitter_scraper/models/x/community_retrieve_members_params.rb +0 -3
  50. data/lib/x_twitter_scraper/models/x/community_retrieve_moderators_params.rb +0 -4
  51. data/lib/x_twitter_scraper/models/x/community_retrieve_search_params.rb +0 -3
  52. data/lib/x_twitter_scraper/models/x/dm_retrieve_history_params.rb +0 -3
  53. data/lib/x_twitter_scraper/models/x/dm_retrieve_history_response.rb +0 -4
  54. data/lib/x_twitter_scraper/models/x/dm_send_response.rb +0 -3
  55. data/lib/x_twitter_scraper/models/x/list_retrieve_followers_params.rb +0 -3
  56. data/lib/x_twitter_scraper/models/x/list_retrieve_members_params.rb +0 -3
  57. data/lib/x_twitter_scraper/models/x/list_retrieve_tweets_params.rb +0 -3
  58. data/lib/x_twitter_scraper/models/x/media_upload_response.rb +0 -3
  59. data/lib/x_twitter_scraper/models/x/profile_update_avatar_response.rb +0 -3
  60. data/lib/x_twitter_scraper/models/x/profile_update_banner_response.rb +0 -3
  61. data/lib/x_twitter_scraper/models/x/profile_update_response.rb +0 -3
  62. data/lib/x_twitter_scraper/models/x/tweet_create_params.rb +0 -3
  63. data/lib/x_twitter_scraper/models/x/tweet_create_response.rb +0 -3
  64. data/lib/x_twitter_scraper/models/x/tweet_delete_response.rb +0 -3
  65. data/lib/x_twitter_scraper/models/x/tweet_detail.rb +0 -3
  66. data/lib/x_twitter_scraper/models/x/tweet_get_favoriters_params.rb +0 -3
  67. data/lib/x_twitter_scraper/models/x/tweet_get_quotes_params.rb +0 -3
  68. data/lib/x_twitter_scraper/models/x/tweet_get_replies_params.rb +0 -3
  69. data/lib/x_twitter_scraper/models/x/tweet_get_retweeters_params.rb +0 -3
  70. data/lib/x_twitter_scraper/models/x/tweet_get_thread_params.rb +0 -3
  71. data/lib/x_twitter_scraper/models/x/tweet_retrieve_response.rb +0 -3
  72. data/lib/x_twitter_scraper/models/x/tweet_search_params.rb +0 -3
  73. data/lib/x_twitter_scraper/models/x/tweets/like_create_response.rb +0 -3
  74. data/lib/x_twitter_scraper/models/x/tweets/like_delete_response.rb +0 -3
  75. data/lib/x_twitter_scraper/models/x/tweets/retweet_create_response.rb +0 -3
  76. data/lib/x_twitter_scraper/models/x/tweets/retweet_delete_response.rb +0 -3
  77. data/lib/x_twitter_scraper/models/x/user_remove_follower_response.rb +0 -3
  78. data/lib/x_twitter_scraper/models/x/user_retrieve_batch_params.rb +0 -3
  79. data/lib/x_twitter_scraper/models/x/user_retrieve_batch_response.rb +0 -3
  80. data/lib/x_twitter_scraper/models/x/user_retrieve_followers_params.rb +0 -3
  81. data/lib/x_twitter_scraper/models/x/user_retrieve_followers_you_know_params.rb +0 -4
  82. data/lib/x_twitter_scraper/models/x/user_retrieve_following_params.rb +0 -3
  83. data/lib/x_twitter_scraper/models/x/user_retrieve_likes_params.rb +0 -3
  84. data/lib/x_twitter_scraper/models/x/user_retrieve_media_params.rb +0 -3
  85. data/lib/x_twitter_scraper/models/x/user_retrieve_mentions_params.rb +0 -3
  86. data/lib/x_twitter_scraper/models/x/user_retrieve_replies_params.rb +0 -3
  87. data/lib/x_twitter_scraper/models/x/user_retrieve_search_params.rb +0 -3
  88. data/lib/x_twitter_scraper/models/x/user_retrieve_tweets_params.rb +0 -3
  89. data/lib/x_twitter_scraper/models/x/user_retrieve_verified_followers_params.rb +0 -4
  90. data/lib/x_twitter_scraper/models/x/users/follow_create_response.rb +0 -3
  91. data/lib/x_twitter_scraper/models/x/users/follow_delete_all_response.rb +0 -3
  92. data/lib/x_twitter_scraper/models/x/write_action_retrieve_response.rb +0 -3
  93. data/lib/x_twitter_scraper/models/x/x_account.rb +0 -3
  94. data/lib/x_twitter_scraper/models/x_get_article_response.rb +0 -4
  95. data/lib/x_twitter_scraper/request_options.rb +0 -2
  96. data/lib/x_twitter_scraper/resources/drafts.rb +0 -3
  97. data/lib/x_twitter_scraper/resources/draws.rb +0 -6
  98. data/lib/x_twitter_scraper/resources/events.rb +0 -3
  99. data/lib/x_twitter_scraper/resources/extractions.rb +0 -9
  100. data/lib/x_twitter_scraper/resources/guest_wallets.rb +0 -6
  101. data/lib/x_twitter_scraper/resources/radar.rb +0 -3
  102. data/lib/x_twitter_scraper/resources/support/tickets.rb +0 -6
  103. data/lib/x_twitter_scraper/resources/trends.rb +0 -3
  104. data/lib/x_twitter_scraper/resources/x/communities/join.rb +0 -6
  105. data/lib/x_twitter_scraper/resources/x/communities/tweets.rb +0 -7
  106. data/lib/x_twitter_scraper/resources/x/communities.rb +0 -16
  107. data/lib/x_twitter_scraper/resources/x/dm.rb +0 -6
  108. data/lib/x_twitter_scraper/resources/x/lists.rb +0 -9
  109. data/lib/x_twitter_scraper/resources/x/media.rb +0 -3
  110. data/lib/x_twitter_scraper/resources/x/profile.rb +0 -9
  111. data/lib/x_twitter_scraper/resources/x/tweets/like.rb +0 -6
  112. data/lib/x_twitter_scraper/resources/x/tweets/retweet.rb +0 -6
  113. data/lib/x_twitter_scraper/resources/x/tweets.rb +0 -24
  114. data/lib/x_twitter_scraper/resources/x/users/follow.rb +0 -6
  115. data/lib/x_twitter_scraper/resources/x/users.rb +0 -38
  116. data/lib/x_twitter_scraper/resources/x.rb +0 -3
  117. data/lib/x_twitter_scraper/version.rb +1 -1
  118. data/lib/x_twitter_scraper.rb +0 -5
  119. data/rbi/x_twitter_scraper/client.rbi +0 -4
  120. data/rbi/x_twitter_scraper/file_part.rbi +0 -1
  121. data/rbi/x_twitter_scraper/internal/transport/base_client.rbi +0 -19
  122. data/rbi/x_twitter_scraper/internal/transport/pooled_net_requester.rbi +0 -9
  123. data/rbi/x_twitter_scraper/internal/type/array_of.rbi +0 -10
  124. data/rbi/x_twitter_scraper/internal/type/base_model.rbi +0 -47
  125. data/rbi/x_twitter_scraper/internal/type/base_page.rbi +0 -4
  126. data/rbi/x_twitter_scraper/internal/type/boolean.rbi +0 -8
  127. data/rbi/x_twitter_scraper/internal/type/converter.rbi +0 -36
  128. data/rbi/x_twitter_scraper/internal/type/enum.rbi +0 -20
  129. data/rbi/x_twitter_scraper/internal/type/file_input.rbi +0 -10
  130. data/rbi/x_twitter_scraper/internal/type/hash_of.rbi +0 -10
  131. data/rbi/x_twitter_scraper/internal/type/request_parameters.rbi +0 -4
  132. data/rbi/x_twitter_scraper/internal/type/union.rbi +0 -18
  133. data/rbi/x_twitter_scraper/internal/type/unknown.rbi +0 -8
  134. data/rbi/x_twitter_scraper/internal/util.rbi +0 -75
  135. data/rbi/x_twitter_scraper/internal.rbi +0 -2
  136. data/rbi/x_twitter_scraper/request_options.rbi +0 -1
  137. data/sig/x_twitter_scraper/internal/transport/base_client.rbs +0 -1
  138. metadata +2 -2
@@ -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
- # Array of items of a given type.
17
10
  class ArrayOf
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
@@ -50,9 +28,8 @@ module XTwitterScraper
50
28
  #
51
29
  # @return [Boolean]
52
30
  def ==(other)
53
- # rubocop:disable Layout/LineLength
31
+ # rubocop:disable-next Layout/LineLength
54
32
  other.is_a?(XTwitterScraper::Internal::Type::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
55
- # rubocop:enable Layout/LineLength
56
33
  end
57
34
 
58
35
  # @api public
@@ -60,23 +37,6 @@ module XTwitterScraper
60
37
  # @return [Integer]
61
38
  def hash = [self.class, item_type].hash
62
39
 
63
- # @api private
64
- #
65
- # @param value [Array<Object>, Object]
66
- #
67
- # @param state [Hash{Symbol=>Object}] .
68
- #
69
- # @option state [Boolean] :translate_names
70
- #
71
- # @option state [Boolean] :strictness
72
- #
73
- # @option state [Hash{Symbol=>Object}] :exactness
74
- #
75
- # @option state [Class<StandardError>] :error
76
- #
77
- # @option state [Integer] :branched
78
- #
79
- # @return [Array<Object>, Object]
80
40
  def coerce(value, state:)
81
41
  exactness = state.fetch(:exactness)
82
42
 
@@ -100,15 +60,6 @@ module XTwitterScraper
100
60
  end
101
61
  end
102
62
 
103
- # @api private
104
- #
105
- # @param value [Array<Object>, Object]
106
- #
107
- # @param state [Hash{Symbol=>Object}] .
108
- #
109
- # @option state [Boolean] :can_retry
110
- #
111
- # @return [Array<Object>, Object]
112
63
  def dump(value, state:)
113
64
  target = item_type
114
65
  if value.is_a?(Array)
@@ -120,47 +71,20 @@ module XTwitterScraper
120
71
  end
121
72
  end
122
73
 
123
- # @api private
124
- #
125
- # @return [Object]
126
74
  def to_sorbet_type
127
75
  T::Array[XTwitterScraper::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
128
76
  end
129
77
 
130
- # @api private
131
- #
132
- # @return [generic<Elem>]
133
78
  protected def item_type = @item_type_fn.call
134
79
 
135
- # @api private
136
- #
137
- # @return [Boolean]
138
80
  protected def nilable? = @nilable
139
81
 
140
- # @api private
141
- #
142
- # @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
143
- #
144
- # @param spec [Hash{Symbol=>Object}] .
145
- #
146
- # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
147
- #
148
- # @option spec [Proc] :enum
149
- #
150
- # @option spec [Proc] :union
151
- #
152
- # @option spec [Boolean] :"nil?"
153
82
  def initialize(type_info, spec = {})
154
83
  @item_type_fn = XTwitterScraper::Internal::Type::Converter.type_info(type_info || spec)
155
84
  @meta = XTwitterScraper::Internal::Type::Converter.meta_info(type_info, spec)
156
85
  @nilable = spec.fetch(:nil?, false)
157
86
  end
158
87
 
159
- # @api private
160
- #
161
- # @param depth [Integer]
162
- #
163
- # @return [String]
164
88
  def inspect(depth: 0)
165
89
  items = XTwitterScraper::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
166
90
 
@@ -7,54 +7,24 @@
7
7
  module XTwitterScraper
8
8
  module Internal
9
9
  module Type
10
- # @abstract
11
10
  class BaseModel
12
11
  extend XTwitterScraper::Internal::Type::Converter
13
12
  extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
14
13
 
15
14
  class << self
16
- # @api private
17
- #
18
- # Assumes superclass fields are totally defined before fields are accessed /
19
- # defined on subclasses.
20
- #
21
- # @param child [Class<XTwitterScraper::Internal::Type::BaseModel>]
22
15
  def inherited(child)
23
16
  super
24
17
  child.known_fields.replace(known_fields.dup)
25
18
  end
26
19
 
27
- # @api private
28
- #
29
- # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
30
20
  def known_fields = @known_fields ||= {}
31
21
 
32
- # @api private
33
- #
34
- # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
35
22
  def fields
36
23
  known_fields.transform_values do |field|
37
24
  {**field.except(:type_fn), type: field.fetch(:type_fn).call}
38
25
  end
39
26
  end
40
27
 
41
- # @api private
42
- #
43
- # @param name_sym [Symbol]
44
- #
45
- # @param required [Boolean]
46
- #
47
- # @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
48
- #
49
- # @param spec [Hash{Symbol=>Object}] .
50
- #
51
- # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
52
- #
53
- # @option spec [Proc] :enum
54
- #
55
- # @option spec [Proc] :union
56
- #
57
- # @option spec [Boolean] :"nil?"
58
28
  private def add_field(name_sym, required:, type_info:, spec:)
59
29
  meta = XTwitterScraper::Internal::Type::Converter.meta_info(type_info, spec)
60
30
  type_fn, info =
@@ -99,7 +69,7 @@ module XTwitterScraper
99
69
  end
100
70
 
101
71
  # rubocop:disable Style/CaseEquality
102
- # rubocop:disable Metrics/BlockLength
72
+ # rubocop:disable-next Metrics/BlockLength
103
73
  define_method(name_sym) do
104
74
  target = type_fn.call
105
75
 
@@ -136,54 +106,17 @@ module XTwitterScraper
136
106
  end
137
107
  end
138
108
  end
139
- # rubocop:enable Metrics/BlockLength
140
109
  # rubocop:enable Style/CaseEquality
141
110
  end
142
111
 
143
- # @api private
144
- #
145
- # @param name_sym [Symbol]
146
- #
147
- # @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
148
- #
149
- # @param spec [Hash{Symbol=>Object}] .
150
- #
151
- # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
152
- #
153
- # @option spec [Proc] :enum
154
- #
155
- # @option spec [Proc] :union
156
- #
157
- # @option spec [Boolean] :"nil?"
158
112
  def required(name_sym, type_info, spec = {})
159
113
  add_field(name_sym, required: true, type_info: type_info, spec: spec)
160
114
  end
161
115
 
162
- # @api private
163
- #
164
- # @param name_sym [Symbol]
165
- #
166
- # @param type_info [Hash{Symbol=>Object}, Proc, XTwitterScraper::Internal::Type::Converter, Class]
167
- #
168
- # @param spec [Hash{Symbol=>Object}] .
169
- #
170
- # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
171
- #
172
- # @option spec [Proc] :enum
173
- #
174
- # @option spec [Proc] :union
175
- #
176
- # @option spec [Boolean] :"nil?"
177
116
  def optional(name_sym, type_info, spec = {})
178
117
  add_field(name_sym, required: false, type_info: type_info, spec: spec)
179
118
  end
180
119
 
181
- # @api private
182
- #
183
- # `request_only` attributes not excluded from `.#coerce` when receiving responses
184
- # even if well behaved servers should not send them
185
- #
186
- # @param blk [Proc]
187
120
  private def request_only(&blk)
188
121
  @mode = :dump
189
122
  blk.call
@@ -191,11 +124,6 @@ module XTwitterScraper
191
124
  @mode = nil
192
125
  end
193
126
 
194
- # @api private
195
- #
196
- # `response_only` attributes are omitted from `.#dump` when making requests
197
- #
198
- # @param blk [Proc]
199
127
  private def response_only(&blk)
200
128
  @mode = :coerce
201
129
  blk.call
@@ -209,9 +137,8 @@ module XTwitterScraper
209
137
  #
210
138
  # @return [Boolean]
211
139
  def ==(other)
212
- # rubocop:disable Layout/LineLength
140
+ # rubocop:disable-next Layout/LineLength
213
141
  other.is_a?(Class) && other <= XTwitterScraper::Internal::Type::BaseModel && other.fields == fields
214
- # rubocop:enable Layout/LineLength
215
142
  end
216
143
 
217
144
  # @api public
@@ -233,23 +160,6 @@ module XTwitterScraper
233
160
  def hash = [self.class, @data].hash
234
161
 
235
162
  class << self
236
- # @api private
237
- #
238
- # @param value [XTwitterScraper::Internal::Type::BaseModel, Hash{Object=>Object}, Object]
239
- #
240
- # @param state [Hash{Symbol=>Object}] .
241
- #
242
- # @option state [Boolean] :translate_names
243
- #
244
- # @option state [Boolean] :strictness
245
- #
246
- # @option state [Hash{Symbol=>Object}] :exactness
247
- #
248
- # @option state [Class<StandardError>] :error
249
- #
250
- # @option state [Integer] :branched
251
- #
252
- # @return [self, Object]
253
163
  def coerce(value, state:)
254
164
  exactness = state.fetch(:exactness)
255
165
 
@@ -270,7 +180,7 @@ module XTwitterScraper
270
180
  data = instance.to_h
271
181
  status = instance.instance_variable_get(:@coerced)
272
182
 
273
- # rubocop:disable Metrics/BlockLength
183
+ # rubocop:disable-next Metrics/BlockLength
274
184
  fields.each do |name, field|
275
185
  mode, required, target = field.fetch_values(:mode, :required, :type)
276
186
  api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)
@@ -306,21 +216,11 @@ module XTwitterScraper
306
216
  status.store(name, state.fetch(:error) || true)
307
217
  data.store(name, converted)
308
218
  end
309
- # rubocop:enable Metrics/BlockLength
310
219
 
311
220
  keys.each { data.store(_1, val.fetch(_1)) }
312
221
  instance
313
222
  end
314
223
 
315
- # @api private
316
- #
317
- # @param value [self, Object]
318
- #
319
- # @param state [Hash{Symbol=>Object}] .
320
- #
321
- # @option state [Boolean] :can_retry
322
- #
323
- # @return [Hash{Object=>Object}, Object]
324
224
  def dump(value, state:)
325
225
  unless (coerced = XTwitterScraper::Internal::Util.coerce_hash(value)).is_a?(Hash)
326
226
  return super
@@ -357,21 +257,12 @@ module XTwitterScraper
357
257
  acc
358
258
  end
359
259
 
360
- # @api private
361
- #
362
- # @return [Object]
363
260
  def to_sorbet_type
364
261
  self
365
262
  end
366
263
  end
367
264
 
368
265
  class << self
369
- # @api private
370
- #
371
- # @param model [XTwitterScraper::Internal::Type::BaseModel]
372
- # @param convert [Boolean]
373
- #
374
- # @return [Hash{Symbol=>Object}]
375
266
  def recursively_to_h(model, convert:)
376
267
  rec = ->(x) do
377
268
  case x
@@ -442,16 +333,6 @@ module XTwitterScraper
442
333
  # @return [Hash{Symbol=>Object}]
443
334
  def deep_to_h = self.class.recursively_to_h(@data, convert: false)
444
335
 
445
- # @param keys [Array<Symbol>, nil]
446
- #
447
- # @return [Hash{Symbol=>Object}]
448
- #
449
- # @example
450
- # # `content_disclosure` is a `XTwitterScraper::ContentDisclosure`
451
- # content_disclosure => {
452
- # advertising: advertising,
453
- # ai_generated: ai_generated
454
- # }
455
336
  def deconstruct_keys(keys)
456
337
  (keys || self.class.known_fields.keys)
457
338
  .filter_map do |k|
@@ -478,9 +359,6 @@ module XTwitterScraper
478
359
  # @return [String]
479
360
  def to_yaml(*a) = XTwitterScraper::Internal::Type::Converter.dump(self.class, self).to_yaml(*a)
480
361
 
481
- # Create a new instance of a model.
482
- #
483
- # @param data [Hash{Symbol=>Object}, self]
484
362
  def initialize(data = {})
485
363
  @data = {}
486
364
  @coerced = {}
@@ -495,11 +373,6 @@ module XTwitterScraper
495
373
  end
496
374
 
497
375
  class << self
498
- # @api private
499
- #
500
- # @param depth [Integer]
501
- #
502
- # @return [String]
503
376
  def inspect(depth: 0)
504
377
  return super() if depth.positive?
505
378
 
@@ -522,9 +395,6 @@ module XTwitterScraper
522
395
  # @return [String]
523
396
  def to_s = deep_to_h.to_s
524
397
 
525
- # @api private
526
- #
527
- # @return [String]
528
398
  def inspect
529
399
  converted = self.class.recursively_to_h(self, convert: true)
530
400
  "#<#{self.class}:0x#{object_id.to_s(16)} #{converted}>"
@@ -7,11 +7,6 @@
7
7
  module XTwitterScraper
8
8
  module Internal
9
9
  module Type
10
- # @api private
11
- #
12
- # @generic Elem
13
- #
14
- # This module provides a base implementation for paginated responses in the SDK.
15
10
  module BasePage
16
11
  # rubocop:disable Lint/UnusedMethodArgument
17
12
 
@@ -34,24 +29,16 @@ module XTwitterScraper
34
29
  # @return [void]
35
30
  def auto_paging_each(&blk) = (raise NotImplementedError)
36
31
 
37
- # @return [Enumerable<generic<Elem>>]
38
32
  def to_enum = super(:auto_paging_each)
39
33
 
40
34
  alias_method :enum_for, :to_enum
41
35
 
42
- # @api private
43
- #
44
- # @param client [XTwitterScraper::Internal::Transport::BaseClient]
45
- # @param req [Hash{Symbol=>Object}]
46
- # @param headers [Hash{String=>String}]
47
- # @param page_data [Object]
48
36
  def initialize(client:, req:, headers:, page_data:)
49
37
  @client = client
50
38
  @req = req
51
39
  @model = req.fetch(:model)
52
40
  super()
53
41
  end
54
-
55
42
  # rubocop:enable Lint/UnusedMethodArgument
56
43
  end
57
44
  end
@@ -7,11 +7,6 @@
7
7
  module XTwitterScraper
8
8
  module Internal
9
9
  module Type
10
- # @api private
11
- #
12
- # @abstract
13
- #
14
- # Ruby has no Boolean class; this is something for models to refer to.
15
10
  class Boolean
16
11
  extend XTwitterScraper::Internal::Type::Converter
17
12
  extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
@@ -33,44 +28,11 @@ module XTwitterScraper
33
28
  def self.==(other) = other.is_a?(Class) && other <= XTwitterScraper::Internal::Type::Boolean
34
29
 
35
30
  class << self
36
- # @api private
37
- #
38
- # Coerce value to Boolean if possible, otherwise return the original value.
39
- #
40
- # @param value [Boolean, Object]
41
- #
42
- # @param state [Hash{Symbol=>Object}] .
43
- #
44
- # @option state [Boolean] :translate_names
45
- #
46
- # @option state [Boolean] :strictness
47
- #
48
- # @option state [Hash{Symbol=>Object}] :exactness
49
- #
50
- # @option state [Class<StandardError>] :error
51
- #
52
- # @option state [Integer] :branched
53
- #
54
- # @return [Boolean, Object]
55
31
  def coerce(value, state:)
56
32
  state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1
57
33
  value
58
34
  end
59
35
 
60
- # @!method dump(value, state:)
61
- # @api private
62
- #
63
- # @param value [Boolean, Object]
64
- #
65
- # @param state [Hash{Symbol=>Object}] .
66
- #
67
- # @option state [Boolean] :can_retry
68
- #
69
- # @return [Boolean, Object]
70
-
71
- # @api private
72
- #
73
- # @return [Object]
74
36
  def to_sorbet_type
75
37
  T::Boolean
76
38
  end
@@ -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