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:



148
149
150
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 148

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:



108
109
110
111
112
113
114
115
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 108

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:



29
30
31
32
33
34
35
36
37
38
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 29

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:



89
90
91
92
93
94
95
96
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 89

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:



69
70
71
72
73
74
75
76
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 69

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:



134
135
136
137
138
139
140
141
142
143
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 134

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:



51
52
53
54
55
56
57
58
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 51

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