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.
125 126 127 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 125 def initialize(client:) @client = client end |
Instance Method Details
#export(id, format_:, type: nil, request_options: {}) ⇒ StringIO
Export draw data
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 74 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
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 47 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
22 23 24 25 26 27 28 29 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 22 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.
111 112 113 114 115 116 117 118 119 120 |
# File 'lib/x_twitter_scraper/resources/draws.rb', line 111 def run(params) parsed, = XTwitterScraper::DrawRunParams.dump_request(params) @client.request( method: :post, path: "draws", body: parsed, model: XTwitterScraper::Models::DrawRunResponse, options: ) end |