Class: XTwitterScraper::Resources::Styles

Inherits:
Object
  • Object
show all
Defined in:
lib/x_twitter_scraper/resources/styles.rb

Overview

Tweet composition, drafts, writing styles & radar

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Styles

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

Parameters:



161
162
163
# File 'lib/x_twitter_scraper/resources/styles.rb', line 161

def initialize(client:)
  @client = client
end

Instance Method Details

#analyze(username:, request_options: {}) ⇒ XTwitterScraper::Models::StyleProfile

Analyze writing style from recent tweets

Parameters:

Returns:

See Also:



102
103
104
105
106
107
108
109
110
111
# File 'lib/x_twitter_scraper/resources/styles.rb', line 102

def analyze(params)
  parsed, options = XTwitterScraper::StyleAnalyzeParams.dump_request(params)
  @client.request(
    method: :post,
    path: "styles",
    body: parsed,
    model: XTwitterScraper::StyleProfile,
    options: options
  )
end

#compare(username1:, username2:, request_options: {}) ⇒ XTwitterScraper::Models::StyleCompareResponse

Compare two style profiles

Parameters:

  • username1 (String)

    First username to compare

  • username2 (String)

    Second username to compare

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

Returns:

See Also:



126
127
128
129
130
131
132
133
134
135
136
# File 'lib/x_twitter_scraper/resources/styles.rb', line 126

def compare(params)
  parsed, options = XTwitterScraper::StyleCompareParams.dump_request(params)
  query = XTwitterScraper::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "styles/compare",
    query: query,
    model: XTwitterScraper::Models::StyleCompareResponse,
    options: options
  )
end

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

Delete a style profile

Parameters:

Returns:

  • (nil)

See Also:



82
83
84
85
86
87
88
89
# File 'lib/x_twitter_scraper/resources/styles.rb', line 82

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

#get_performance(id, request_options: {}) ⇒ XTwitterScraper::Models::StyleGetPerformanceResponse

Get engagement metrics for style tweets

Parameters:

Returns:

See Also:



149
150
151
152
153
154
155
156
# File 'lib/x_twitter_scraper/resources/styles.rb', line 149

def get_performance(id, params = {})
  @client.request(
    method: :get,
    path: ["styles/%1$s/performance", id],
    model: XTwitterScraper::Models::StyleGetPerformanceResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ XTwitterScraper::Models::StyleListResponse

List cached style profiles

Parameters:

Returns:

See Also:



62
63
64
65
66
67
68
69
# File 'lib/x_twitter_scraper/resources/styles.rb', line 62

def list(params = {})
  @client.request(
    method: :get,
    path: "styles",
    model: XTwitterScraper::Models::StyleListResponse,
    options: params[:request_options]
  )
end

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

Get cached style profile

Parameters:

Returns:

See Also:



18
19
20
21
22
23
24
25
# File 'lib/x_twitter_scraper/resources/styles.rb', line 18

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

#update(id, label:, tweets:, request_options: {}) ⇒ XTwitterScraper::Models::StyleProfile

Save style profile with custom tweets

Parameters:

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
# File 'lib/x_twitter_scraper/resources/styles.rb', line 42

def update(id, params)
  parsed, options = XTwitterScraper::StyleUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["styles/%1$s", id],
    body: parsed,
    model: XTwitterScraper::StyleProfile,
    options: options
  )
end