Class: XTwitterScraper::Resources::Draws
- Inherits:
-
Object
- Object
- XTwitterScraper::Resources::Draws
- Defined in:
- lib/x_twitter_scraper/resources/draws.rb,
sig/x_twitter_scraper/resources/draws.rbs
Overview
Giveaway draws from tweet replies
Instance Method Summary collapse
-
#export(id, format_:, type: nil, request_options: {}) ⇒ StringIO
Export draw data.
-
#initialize(client:) ⇒ Draws
constructor
private
A new instance of Draws.
-
#list(cursor: nil, limit: nil, request_options: {}) ⇒ XTwitterScraper::Models::DrawListResponse
Some parameter documentations has been truncated, see Models::DrawListParams for more details.
-
#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::DrawRetrieveResponse
Get draw details.
-
#run(tweet_url:, backup_count: nil, filter_account_age_days: nil, filter_language: nil, filter_min_followers: nil, must_follow_username: nil, must_retweet: nil, required_hashtags: nil, required_keywords: nil, required_mentions: nil, unique_authors_only: nil, winner_count: nil, request_options: {}) ⇒ XTwitterScraper::Models::DrawRunResponse
Runs a giveaway draw from a source tweet.
Constructor Details
#initialize(client:) ⇒ Draws
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Draws.
121 122 123 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 121 def initialize(client:) @client = client end |
Instance Method Details
#export(id, format_:, type: nil, request_options: {}) ⇒ StringIO
Export draw data
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 70 def export(id, params) parsed, = XTwitterScraper::DrawExportParams.dump_request(params) query = XTwitterScraper::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["draws/%1$s/export", id], query: query.transform_keys(format_: "format"), headers: {"accept" => "application/octet-stream"}, model: StringIO, options: ) end |
#list(cursor: nil, limit: nil, request_options: {}) ⇒ XTwitterScraper::Models::DrawListResponse
Some parameter documentations has been truncated, see Models::DrawListParams for more details.
List draws
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 43 def list(params = {}) parsed, = XTwitterScraper::DrawListParams.dump_request(params) query = XTwitterScraper::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "draws", query: query, model: XTwitterScraper::Models::DrawListResponse, options: ) end |
#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::DrawRetrieveResponse
Get draw details
18 19 20 21 22 23 24 25 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 18 def retrieve(id, params = {}) @client.request( method: :get, path: ["draws/%1$s", id], model: XTwitterScraper::Models::DrawRetrieveResponse, options: params[:request_options] ) end |
#run(tweet_url:, backup_count: nil, filter_account_age_days: nil, filter_language: nil, filter_min_followers: nil, must_follow_username: nil, must_retweet: nil, required_hashtags: nil, required_keywords: nil, required_mentions: nil, unique_authors_only: nil, winner_count: nil, request_options: {}) ⇒ XTwitterScraper::Models::DrawRunResponse
Runs a giveaway draw from a source tweet. The draw first checks the minimum credits needed to inspect the source tweet and at least one candidate. Remaining credits cap how many replies and retweeters can be inspected before filters and winner selection run.
107 108 109 110 111 112 113 114 115 116 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 107 def run(params) parsed, = XTwitterScraper::DrawRunParams.dump_request(params) @client.request( method: :post, path: "draws", body: parsed, model: XTwitterScraper::Models::DrawRunResponse, options: ) end |