Module: Twitter::Client::Accounts

Included in:
Twitter::Client
Defined in:
lib/twitter/client/accounts.rb

Overview

Defines methods related to a user's account

Instance Method Summary collapse

Instance Method Details

#end_session(options = {}) ⇒ Hash

Ends the session of the authenticating user

Examples:

End the session of the authenticating user

Twitter.end_session

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



52
53
54
# File 'lib/twitter/client/accounts.rb', line 52

def end_session(options={})
  post("/1/account/end_session.json", options)
end

#rate_limit_status(options = {}) ⇒ Twitter::RateLimitStatus

Returns the remaining number of API requests available to the requesting user

Examples:

Return the remaining number of API requests available to the requesting user

Twitter.rate_limit_status

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • No

    This will return the requesting IP's rate limit status. If you want the authenticating user's rate limit status you must authenticate.



21
22
23
24
# File 'lib/twitter/client/accounts.rb', line 21

def rate_limit_status(options={})
  rate_limit_status = get("/1/account/rate_limit_status.json", options)
  Twitter::RateLimitStatus.new(rate_limit_status)
end

#settings(options = {}) ⇒ Twitter::Settings

Updates the authenticating user's settings. Or, if no options supplied, returns settings (including current trend, geo and sleep time information) for the authenticating user.

Examples:

Return the settings for the authenticating user.

Twitter.settings

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :trend_location_woeid (Integer)

    The Yahoo! Where On Earth ID to use as the user's default trend location. Global information is available by using 1 as the WOEID. The woeid must be one of the locations returned by GET trends/available.

  • :sleep_time_enabled (Boolean, String, Integer)

    When set to true, 't' or 1, will enable sleep time for the user. Sleep time is the time when push or SMS notifications should not be sent to the user.

  • :start_sleep_time (Integer)

    The hour that sleep time should begin if it is enabled. The value for this parameter should be provided in ISO8601 format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.

  • :end_sleep_time (Integer)

    The hour that sleep time should end if it is enabled. The value for this parameter should be provided in ISO8601 format (i.e. 00-23). The time is considered to be in the same timezone as the user's time_zone setting.

  • :time_zone (String)

    The timezone dates and times should be displayed in for the user. The timezone must be one of the Rails TimeZone names.

  • :lang (String)

    The language which Twitter should render in for this user. The language must be specified by the appropriate two letter ISO 639-1 representation. Currently supported languages are provided by GET help/languages.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



169
170
171
172
173
174
175
176
# File 'lib/twitter/client/accounts.rb', line 169

def settings(options={})
  settings = if options.size.zero?
    get("/1/account/settings.json", options)
  else
    post("/1/account/settings.json", options)
  end
  Twitter::Settings.new(settings)
end

#update_delivery_device(device, options = {}) ⇒ Twitter::User

Sets which device Twitter delivers updates to for the authenticating user

Examples:

Turn SMS updates on for the authenticating user

Twitter.update_delivery_device('sms')

Parameters:

  • device (String)

    Must be one of: 'sms', 'none'.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



68
69
70
71
# File 'lib/twitter/client/accounts.rb', line 68

def update_delivery_device(device, options={})
  user = post("/1/account/update_delivery_device.json", options.merge(:device => device))
  Twitter::User.new(user)
end

#update_profile(options = {}) ⇒ Twitter::User

Note:

Only the options specified will be updated.

Sets values that users are able to set under the "Account" tab of their settings page

Examples:

Set authenticating user's name to Erik Michaels-Ober

Twitter.update_profile(:name => "Erik Michaels-Ober")

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :name (String)

    Full name associated with the profile. Maximum of 20 characters.

  • :url (String)

    URL associated with the profile. Will be prepended with "http://" if not present. Maximum of 100 characters.

  • :location (String)

    The city or country describing where the user of the account is located. The contents are not normalized or geocoded in any way. Maximum of 30 characters.

  • :description (String)

    A description of the user owning the account. Maximum of 160 characters.

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



89
90
91
92
# File 'lib/twitter/client/accounts.rb', line 89

def update_profile(options={})
  user = post("/1/account/update_profile.json", options)
  Twitter::User.new(user)
end

#update_profile_background_image(image, options = {}) ⇒ Twitter::User

Updates the authenticating user's profile background image

Examples:

Update the authenticating user's profile background image

Twitter.update_profile_background_image(File.new("we_concept_bg2.png"))

Parameters:

  • image (String)

    The background image for the profile. Must be a valid GIF, JPG, or PNG image of less than 800 kilobytes in size. Images with width larger than 2048 pixels will be scaled down.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :tile (Boolean)

    Whether or not to tile the background image. If set to true the background image will be displayed tiled. The image will not be tiled otherwise.

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



107
108
109
110
# File 'lib/twitter/client/accounts.rb', line 107

def update_profile_background_image(image, options={})
  user = post("/1/account/update_profile_background_image.json", options.merge(:image => image))
  Twitter::User.new(user)
end

#update_profile_colors(options = {}) ⇒ Twitter::User

Sets one or more hex values that control the color scheme of the authenticating user's profile

Examples:

Set authenticating user's profile background to black

Twitter.update_profile_colors(:profile_background_color => '000000')

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :profile_background_color (String)

    Profile background color.

  • :profile_text_color (String)

    Profile text color.

  • :profile_link_color (String)

    Profile link color.

  • :profile_sidebar_fill_color (String)

    Profile sidebar's background color.

  • :profile_sidebar_border_color (String)

    Profile sidebar's border color.

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



128
129
130
131
# File 'lib/twitter/client/accounts.rb', line 128

def update_profile_colors(options={})
  user = post("/1/account/update_profile_colors.json", options)
  Twitter::User.new(user)
end

#update_profile_image(image, options = {}) ⇒ Twitter::User

Note:

This method asynchronously processes the uploaded file before updating the user's profile image URL. You can either update your local cache the next time you request the user's information, or, at least 5 seconds after uploading the image, ask for the updated URL using User#profile_image.

Updates the authenticating user's profile image

Examples:

Update the authenticating user's profile image

Twitter.update_profile_image(File.new("me.jpeg"))

Parameters:

  • image (String)

    The avatar image for the profile. Must be a valid GIF, JPG, or PNG image of less than 700 kilobytes in size. Images with width larger than 500 pixels will be scaled down. Animated GIFs will be converted to a static GIF of the first frame, removing the animation.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Requires Authentication?:

  • Yes



146
147
148
149
# File 'lib/twitter/client/accounts.rb', line 146

def update_profile_image(image, options={})
  user = post("/1/account/update_profile_image.json", options.merge(:image => image))
  Twitter::User.new(user)
end

#verify_credentials(options = {}) ⇒ Twitter::User

Returns the requesting user if authentication was successful, otherwise raises Error::Unauthorized

Examples:

Return the requesting user if authentication was successful

Twitter.verify_credentials

Parameters:

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :include_entities (Boolean, String, Integer)

    Include Tweet Entities when set to true, 't' or 1.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Requires Authentication?:

  • Yes



37
38
39
40
# File 'lib/twitter/client/accounts.rb', line 37

def verify_credentials(options={})
  user = get("/1/account/verify_credentials.json", options)
  Twitter::User.new(user)
end