forked from moomerman/twitter_oauth
/
account.rb
42 lines (35 loc) · 1.67 KB
/
account.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
module TwitterOAuth
class Client
# Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful;
# returns a 401 status code and an error message if not.
def authorized?
oauth_response = access_token.get('/account/verify_credentials.json')
return oauth_response.class == Net::HTTPOK
end
# Returns client info
def info
get('/account/verify_credentials.json')
end
# Returns the remaining number of API requests available to the requesting user before the API limit is reached for the current hour.
def rate_limit_status
get('/account/rate_limit_status.json')
end
# Updates profile background image. Takes a File object and optional tile argument.
# Returns extended user info object.
def update_profile_background_image(image, tile = false)
body, headers = http_multipart_data({:image => image, :tile => tile})
post('/account/update_profile_background_image.json', body, headers)
end
# Updates profile avatar image. Takes a File object which should be an image.
# Returns extended user info object.
def update_profile_image(image)
body, headers = http_multipart_data({:image => image})
post('/account/update_profile_image.json', body, headers)
end
# colors hash must contain at least one or more of the following keys :profile_background_color, :profile_text_color, :profile_link_color, :profile_sidebar_fill_color, :profile_sidebar_border_color
# returns extended user info object.
def update_profile_colors(colors)
post('/account/update_profile_colors.json', colors)
end
end
end