Class: XTwitterScraper::Resources::X::Accounts

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

Overview

Connected X account management

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Accounts

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

Parameters:



144
145
146
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 144

def initialize(client:)
  @client = client
end

Instance Method Details

#bulk_retry(request_options: {}) ⇒ XTwitterScraper::Models::X::AccountBulkRetryResponse

Clears loginFailedAt and loginFailureReason for all accounts with transient or automated failure reasons, making them eligible for retry on next use.

Parameters:

Returns:

See Also:



104
105
106
107
108
109
110
111
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 104

def bulk_retry(params = {})
  @client.request(
    method: :post,
    path: "x/accounts/bulk-retry",
    model: XTwitterScraper::Models::X::AccountBulkRetryResponse,
    options: params[:request_options]
  )
end

#create(email:, password:, username:, totp_secret: nil, request_options: {}) ⇒ XTwitterScraper::Models::X::AccountCreateResponse

Connect X account

Parameters:

  • email (String)

    Account email

  • password (String)

    Account password

  • username (String)

    X username

  • totp_secret (String)

    TOTP secret for 2FA

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

Returns:

See Also:



25
26
27
28
29
30
31
32
33
34
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 25

def create(params)
  parsed, options = XTwitterScraper::X::AccountCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "x/accounts",
    body: parsed,
    model: XTwitterScraper::Models::X::AccountCreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ XTwitterScraper::Models::X::AccountDeleteResponse

Disconnect X account

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



85
86
87
88
89
90
91
92
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 85

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["x/accounts/%1$s", id],
    model: XTwitterScraper::Models::X::AccountDeleteResponse,
    options: params[:request_options]
  )
end

#list(request_options: {}) ⇒ XTwitterScraper::Models::X::AccountListResponse

List connected X accounts

Parameters:

Returns:

See Also:



65
66
67
68
69
70
71
72
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 65

def list(params = {})
  @client.request(
    method: :get,
    path: "x/accounts",
    model: XTwitterScraper::Models::X::AccountListResponse,
    options: params[:request_options]
  )
end

#reauth(id, password:, email: nil, totp_secret: nil, request_options: {}) ⇒ XTwitterScraper::Models::X::AccountReauthResponse

Re-authenticate X account

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

  • password (String)

    Updated account password

  • email (String)

    Email for the X account (updates stored email)

  • totp_secret (String)

    TOTP secret for 2FA re-authentication

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

Returns:

See Also:



130
131
132
133
134
135
136
137
138
139
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 130

def reauth(id, params)
  parsed, options = XTwitterScraper::X::AccountReauthParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["x/accounts/%1$s/reauth", id],
    body: parsed,
    model: XTwitterScraper::Models::X::AccountReauthResponse,
    options: options
  )
end

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

Get X account details

Parameters:

  • id (String)

    Resource ID returned by the matching create or list endpoint.

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

Returns:

See Also:



47
48
49
50
51
52
53
54
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 47

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