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,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
@@ -7,17 +7,11 @@
7
7
  module XTwitterScraper
8
8
  module Internal
9
9
  module Type
10
- # @api private
11
- #
12
- # @abstract
13
- #
14
- # When we don't know what to expect for the value.
15
10
  class Unknown
16
11
  extend XTwitterScraper::Internal::Type::Converter
17
12
  extend XTwitterScraper::Internal::Util::SorbetRuntimeSupport
18
13
 
19
14
  # rubocop:disable Lint/UnusedMethodArgument
20
-
21
15
  private_class_method :new
22
16
 
23
17
  # @api public
@@ -35,49 +29,15 @@ module XTwitterScraper
35
29
  def self.==(other) = other.is_a?(Class) && other <= XTwitterScraper::Internal::Type::Unknown
36
30
 
37
31
  class << self
38
- # @api private
39
- #
40
- # No coercion needed for Unknown type.
41
- #
42
- # @param value [Object]
43
- #
44
- # @param state [Hash{Symbol=>Object}] .
45
- #
46
- # @option state [Boolean] :translate_names
47
- #
48
- # @option state [Boolean] :strictness
49
- #
50
- # @option state [Hash{Symbol=>Object}] :exactness
51
- #
52
- # @option state [Class<StandardError>] :error
53
- #
54
- # @option state [Integer] :branched
55
- #
56
- # @return [Object]
57
32
  def coerce(value, state:)
58
33
  state.fetch(:exactness)[:yes] += 1
59
34
  value
60
35
  end
61
36
 
62
- # @!method dump(value, state:)
63
- # @api private
64
- #
65
- # @param value [Object]
66
- #
67
- # @param state [Hash{Symbol=>Object}] .
68
- #
69
- # @option state [Boolean] :can_retry
70
- #
71
- # @return [Object]
72
-
73
- # @api private
74
- #
75
- # @return [Object]
76
37
  def to_sorbet_type
77
38
  T.anything
78
39
  end
79
40
  end
80
-
81
41
  # rubocop:enable Lint/UnusedMethodArgument
82
42
  end
83
43
  end