Class: XTwitterScraper::Resources::Draws

Inherits:
Object
  • Object
show all
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

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.

Parameters:



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

Parameters:

Returns:

  • (StringIO)

See Also:



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, options = 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: 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

Parameters:

  • cursor (String)

    Cursor for keyset pagination from prior response next_cursor

  • limit (Integer)

    Maximum number of items to return (1-100, default 50). For paid per-result endpo

  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



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, options = 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: options
  )
end

#retrieve(id, request_options: {}) ⇒ XTwitterScraper::Models::DrawRetrieveResponse

Get draw details

Parameters:

Returns:

See Also:



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.

Parameters:

  • tweet_url (String)
  • backup_count (Integer)
  • filter_account_age_days (Integer)
  • filter_language (String)
  • filter_min_followers (Integer)
  • must_follow_username (String)
  • must_retweet (Boolean)
  • required_hashtags (Array<String>)
  • required_keywords (Array<String>)
  • required_mentions (Array<String>)
  • unique_authors_only (Boolean)
  • winner_count (Integer)
  • request_options (XTwitterScraper::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



107
108
109
110
111
112
113
114
115
116
# File 'lib/x_twitter_scraper/resources/draws.rb', line 107

def run(params)
  parsed, options = XTwitterScraper::DrawRunParams.dump_request(params)
  @client.request(
    method: :post,
    path: "draws",
    body: parsed,
    model: XTwitterScraper::Models::DrawRunResponse,
    options: options
  )
end