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

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

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:



150
151
152
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 150

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:



110
111
112
113
114
115
116
117
118
# File 'lib/x_twitter_scraper/resources/x/accounts.rb', line 110

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

#create(email:, password:, username:, proxy_country: nil, 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

  • proxy_country (String)

    Proxy country code

  • totp_secret (String)

    TOTP secret for 2FA

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

Returns:

See Also:



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

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,
    security: {auth_api_key: true},
    options: options
  )
end

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

Disconnect X account

Parameters:

Returns:

See Also:



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

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["x/accounts/%1$s", id],
    model: XTwitterScraper::Models::X::AccountDeleteResponse,
    security: {auth_api_key: true},
    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
77
# 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,
    security: {auth_api_key: true},
    options: params[:request_options]
  )
end

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

Re-authenticate X account

Parameters:

  • id (String)

    Resource ID (stringified bigint)

  • password (String)

    Updated account password

  • totp_secret (String)

    TOTP secret for 2FA re-authentication

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

Returns:

See Also:



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

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,
    security: {auth_api_key: true},
    options: options
  )
end

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

Get X account details

Parameters:

Returns:

See Also:



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

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