Class: XTwitterScraper::Resources::X::Profile

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

Overview

X write actions (tweets, likes, follows, DMs)

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Profile

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

Parameters:



124
125
126
# File 'lib/x_twitter_scraper/resources/x/profile.rb', line 124

def initialize(client:)
  @client = client
end

Instance Method Details

#update(account:, idempotency_key:, description: nil, location: nil, name: nil, url: nil, request_options: {}) ⇒ XTwitterScraper::Models::X::ProfileUpdateResponse

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

Update X profile

Parameters:

  • account (String)

    Body param: X account (@username or ID) to update profile

  • idempotency_key (String)

    Header param: Generate one unique value for each intended write. Reuse it only w

  • description (String)

    Body param: Bio description

  • location (String)

    Body param

  • name (String)

    Body param: Display name

  • url (String)

    Body param: Website URL

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

Returns:

See Also:



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/x_twitter_scraper/resources/x/profile.rb', line 36

def update(params)
  parsed, options = XTwitterScraper::X::ProfileUpdateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :patch,
    path: "x/profile",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::X::ProfileUpdateResponse,
    options: options
  )
end

#update_avatar(account:, url:, idempotency_key:, request_options: {}) ⇒ XTwitterScraper::Models::X::ProfileUpdateAvatarResponse

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

Update profile avatar

Parameters:

  • account (String)

    Body param: X account (@username or ID) receiving avatar from URL

  • url (String)

    Body param: HTTPS URL to the avatar image to download

  • idempotency_key (String)

    Header param: Generate one unique value for each intended write. Reuse it only w

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

Returns:

See Also:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/x_twitter_scraper/resources/x/profile.rb', line 67

def update_avatar(params)
  parsed, options = XTwitterScraper::X::ProfileUpdateAvatarParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :patch,
    path: "x/profile/avatar",
    headers: {
      "content-type" => "multipart/form-data",
      **parsed.slice(*header_params.keys)
    }.transform_keys(
      header_params
    ),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::X::ProfileUpdateAvatarResponse,
    options: options
  )
end

#update_banner(account:, url:, idempotency_key:, request_options: {}) ⇒ XTwitterScraper::Models::X::ProfileUpdateBannerResponse

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

Update profile banner

Parameters:

  • account (String)

    Body param: X account (@username or ID) receiving banner from URL

  • url (String)

    Body param: HTTPS URL to the banner image to download

  • idempotency_key (String)

    Header param: Generate one unique value for each intended write. Reuse it only w

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

Returns:

See Also:



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/x_twitter_scraper/resources/x/profile.rb', line 103

def update_banner(params)
  parsed, options = XTwitterScraper::X::ProfileUpdateBannerParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @client.request(
    method: :patch,
    path: "x/profile/banner",
    headers: {
      "content-type" => "multipart/form-data",
      **parsed.slice(*header_params.keys)
    }.transform_keys(
      header_params
    ),
    body: parsed.except(*header_params.keys),
    model: XTwitterScraper::Models::X::ProfileUpdateBannerResponse,
    options: options
  )
end