Class: XTwitterScraper::Resources::Drafts

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/drafts.rb,
sig/x_twitter_scraper/resources/drafts.rbs

Overview

AI tweet composition, drafts, writing styles, and radar

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Drafts

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 Drafts.

Parameters:



105
106
107
# File 'lib/x_twitter_scraper/resources/drafts.rb', line 105

def initialize(client:)
  @client = client
end

Instance Method Details

#create(text:, goal: nil, topic: nil, request_options: {}) ⇒ XTwitterScraper::Models::DraftDetail

Save a tweet draft

Parameters:

Returns:

See Also:



23
24
25
26
27
28
29
30
31
32
# File 'lib/x_twitter_scraper/resources/drafts.rb', line 23

def create(params)
  parsed, options = XTwitterScraper::DraftCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "drafts",
    body: parsed,
    model: XTwitterScraper::DraftDetail,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Delete a draft

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

  • (nil)

See Also:



93
94
95
96
97
98
99
100
# File 'lib/x_twitter_scraper/resources/drafts.rb', line 93

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["drafts/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(after_cursor: nil, limit: nil, request_options: {}) ⇒ XTwitterScraper::Models::DraftListResponse

Some parameter documentations has been truncated, see Models::DraftListParams for more details.

List saved drafts

Parameters:

  • after_cursor (String)

    Cursor for pagination

  • 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:



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/x_twitter_scraper/resources/drafts.rb', line 70

def list(params = {})
  parsed, options = XTwitterScraper::DraftListParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "drafts",
    query: query.transform_keys(after_cursor: "afterCursor"),
    model: XTwitterScraper::Models::DraftListResponse,
    options: options
  )
end

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

Get draft by ID

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



45
46
47
48
49
50
51
52
# File 'lib/x_twitter_scraper/resources/drafts.rb', line 45

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["drafts/%1$s", id],
    model: XTwitterScraper::DraftDetail,
    options: params[:request_options]
  )
end