ifttt-twitter 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/.yardopts +8 -0
- data/Gemfile +7 -0
- data/HISTORY.md +520 -0
- data/LICENSE.md +20 -0
- data/README.md +251 -0
- data/Rakefile +13 -0
- data/lib/twitter.rb +24 -0
- data/lib/twitter/action.rb +9 -0
- data/lib/twitter/action_factory.rb +28 -0
- data/lib/twitter/authenticatable.rb +24 -0
- data/lib/twitter/base.rb +40 -0
- data/lib/twitter/client.rb +126 -0
- data/lib/twitter/client/accounts.rb +180 -0
- data/lib/twitter/client/activity.rb +48 -0
- data/lib/twitter/client/block.rb +104 -0
- data/lib/twitter/client/direct_messages.rb +110 -0
- data/lib/twitter/client/favorites.rb +82 -0
- data/lib/twitter/client/friends_and_followers.rb +293 -0
- data/lib/twitter/client/help.rb +38 -0
- data/lib/twitter/client/legal.rb +32 -0
- data/lib/twitter/client/lists.rb +643 -0
- data/lib/twitter/client/local_trends.rb +46 -0
- data/lib/twitter/client/notification.rb +49 -0
- data/lib/twitter/client/places_and_geo.rb +113 -0
- data/lib/twitter/client/saved_searches.rb +73 -0
- data/lib/twitter/client/search.rb +94 -0
- data/lib/twitter/client/spam_reporting.rb +30 -0
- data/lib/twitter/client/suggested_users.rb +60 -0
- data/lib/twitter/client/timelines.rb +265 -0
- data/lib/twitter/client/trends.rb +55 -0
- data/lib/twitter/client/tweets.rb +191 -0
- data/lib/twitter/client/urls.rb +26 -0
- data/lib/twitter/client/users.rb +203 -0
- data/lib/twitter/config.rb +106 -0
- data/lib/twitter/configuration.rb +20 -0
- data/lib/twitter/connection.rb +43 -0
- data/lib/twitter/core_ext/hash.rb +81 -0
- data/lib/twitter/creatable.rb +14 -0
- data/lib/twitter/cursor.rb +44 -0
- data/lib/twitter/direct_message.rb +27 -0
- data/lib/twitter/error.rb +37 -0
- data/lib/twitter/error/bad_gateway.rb +7 -0
- data/lib/twitter/error/bad_request.rb +7 -0
- data/lib/twitter/error/client_error.rb +7 -0
- data/lib/twitter/error/enhance_your_calm.rb +13 -0
- data/lib/twitter/error/forbidden.rb +7 -0
- data/lib/twitter/error/internal_server_error.rb +7 -0
- data/lib/twitter/error/not_acceptable.rb +7 -0
- data/lib/twitter/error/not_found.rb +7 -0
- data/lib/twitter/error/server_error.rb +7 -0
- data/lib/twitter/error/service_unavailable.rb +7 -0
- data/lib/twitter/error/unauthorized.rb +7 -0
- data/lib/twitter/favorite.rb +28 -0
- data/lib/twitter/follow.rb +27 -0
- data/lib/twitter/geo_factory.rb +22 -0
- data/lib/twitter/language.rb +7 -0
- data/lib/twitter/list.rb +22 -0
- data/lib/twitter/list_member_added.rb +36 -0
- data/lib/twitter/media_factory.rb +21 -0
- data/lib/twitter/mention.rb +43 -0
- data/lib/twitter/metadata.rb +7 -0
- data/lib/twitter/oembed.rb +8 -0
- data/lib/twitter/photo.rb +24 -0
- data/lib/twitter/place.rb +36 -0
- data/lib/twitter/point.rb +27 -0
- data/lib/twitter/polygon.rb +14 -0
- data/lib/twitter/rate_limit_status.rb +15 -0
- data/lib/twitter/relationship.rb +18 -0
- data/lib/twitter/reply.rb +36 -0
- data/lib/twitter/request.rb +38 -0
- data/lib/twitter/request/gateway.rb +20 -0
- data/lib/twitter/request/multipart_with_file.rb +37 -0
- data/lib/twitter/request/oauth.rb +26 -0
- data/lib/twitter/request/phoenix.rb +22 -0
- data/lib/twitter/response/parse_json.rb +28 -0
- data/lib/twitter/response/raise_client_error.rb +49 -0
- data/lib/twitter/response/raise_server_error.rb +23 -0
- data/lib/twitter/retweet.rb +36 -0
- data/lib/twitter/saved_search.rb +16 -0
- data/lib/twitter/settings.rb +17 -0
- data/lib/twitter/size.rb +16 -0
- data/lib/twitter/status.rb +80 -0
- data/lib/twitter/suggestion.rb +22 -0
- data/lib/twitter/trend.rb +14 -0
- data/lib/twitter/user.rb +65 -0
- data/lib/twitter/version.rb +30 -0
- data/spec/faraday/request_spec.rb +25 -0
- data/spec/faraday/response_spec.rb +68 -0
- data/spec/fixtures/about_me.json +1 -0
- data/spec/fixtures/all.json +1 -0
- data/spec/fixtures/bad_gateway.json +1 -0
- data/spec/fixtures/bad_request.json +1 -0
- data/spec/fixtures/by_friends.json +1 -0
- data/spec/fixtures/category.json +1 -0
- data/spec/fixtures/configuration.json +1 -0
- data/spec/fixtures/contributees.json +1 -0
- data/spec/fixtures/contributors.json +1 -0
- data/spec/fixtures/direct_message.json +1 -0
- data/spec/fixtures/direct_messages.json +1 -0
- data/spec/fixtures/end_session.json +1 -0
- data/spec/fixtures/enhance_your_calm.text +11 -0
- data/spec/fixtures/false.json +1 -0
- data/spec/fixtures/favorites.json +1 -0
- data/spec/fixtures/forbidden.json +1 -0
- data/spec/fixtures/friendships.json +1 -0
- data/spec/fixtures/id_list.json +1 -0
- data/spec/fixtures/ids.json +1 -0
- data/spec/fixtures/image_facets.json +1 -0
- data/spec/fixtures/internal_server_error.json +1 -0
- data/spec/fixtures/languages.json +1 -0
- data/spec/fixtures/list.json +1 -0
- data/spec/fixtures/lists.json +1 -0
- data/spec/fixtures/locations.json +1 -0
- data/spec/fixtures/matching_trends.json +1 -0
- data/spec/fixtures/me.jpeg +0 -0
- data/spec/fixtures/media_timeline.json +1 -0
- data/spec/fixtures/members.json +1 -0
- data/spec/fixtures/n605431196_2079896_558_normal.jpg +0 -0
- data/spec/fixtures/no_user_matches.json +1 -0
- data/spec/fixtures/not_acceptable.json +1 -0
- data/spec/fixtures/not_found.json +1 -0
- data/spec/fixtures/oembed.json +1 -0
- data/spec/fixtures/pengwynn.json +1 -0
- data/spec/fixtures/phoenix_search.phoenix +1 -0
- data/spec/fixtures/place.json +1 -0
- data/spec/fixtures/places.json +1 -0
- data/spec/fixtures/privacy.json +1 -0
- data/spec/fixtures/profile_image.text +24 -0
- data/spec/fixtures/rate_limit_status.json +1 -0
- data/spec/fixtures/recommendations.json +1 -0
- data/spec/fixtures/relationship.json +1 -0
- data/spec/fixtures/resolve.json +1 -0
- data/spec/fixtures/retweet.json +1 -0
- data/spec/fixtures/retweeters_of.json +1 -0
- data/spec/fixtures/retweets.json +1 -0
- data/spec/fixtures/saved_search.json +1 -0
- data/spec/fixtures/saved_searches.json +1 -0
- data/spec/fixtures/search.json +1 -0
- data/spec/fixtures/service_unavailable.json +1 -0
- data/spec/fixtures/settings.json +1 -0
- data/spec/fixtures/sferik.json +1 -0
- data/spec/fixtures/status.json +1 -0
- data/spec/fixtures/status_with_media.json +104 -0
- data/spec/fixtures/statuses.json +1 -0
- data/spec/fixtures/suggestions.json +1 -0
- data/spec/fixtures/tos.json +1 -0
- data/spec/fixtures/totals.json +1 -0
- data/spec/fixtures/trends.json +1 -0
- data/spec/fixtures/trends_current.json +1 -0
- data/spec/fixtures/trends_daily.json +1 -0
- data/spec/fixtures/trends_weekly.json +1 -0
- data/spec/fixtures/true.json +1 -0
- data/spec/fixtures/unauthorized.json +1 -0
- data/spec/fixtures/user_search.json +1 -0
- data/spec/fixtures/user_timeline.json +1 -0
- data/spec/fixtures/users.json +1 -0
- data/spec/fixtures/users_list.json +1 -0
- data/spec/fixtures/video_facets.json +1 -0
- data/spec/fixtures/we_concept_bg2.png +0 -0
- data/spec/helper.rb +49 -0
- data/spec/twitter/action_factory_spec.rb +37 -0
- data/spec/twitter/action_spec.rb +16 -0
- data/spec/twitter/base_spec.rb +29 -0
- data/spec/twitter/client/accounts_spec.rb +181 -0
- data/spec/twitter/client/activity_spec.rb +43 -0
- data/spec/twitter/client/block_spec.rb +106 -0
- data/spec/twitter/client/direct_messages_spec.rb +98 -0
- data/spec/twitter/client/favorites_spec.rb +80 -0
- data/spec/twitter/client/friends_and_followers_spec.rb +478 -0
- data/spec/twitter/client/help_spec.rb +44 -0
- data/spec/twitter/client/legal_spec.rb +41 -0
- data/spec/twitter/client/lists_spec.rb +1104 -0
- data/spec/twitter/client/local_trends_spec.rb +58 -0
- data/spec/twitter/client/notification_spec.rb +47 -0
- data/spec/twitter/client/places_and_geo_spec.rb +100 -0
- data/spec/twitter/client/saved_searches_spec.rb +80 -0
- data/spec/twitter/client/search_spec.rb +92 -0
- data/spec/twitter/client/spam_reporting_spec.rb +28 -0
- data/spec/twitter/client/suggested_users_spec.rb +65 -0
- data/spec/twitter/client/timelines_spec.rb +231 -0
- data/spec/twitter/client/trends_spec.rb +51 -0
- data/spec/twitter/client/tweets_spec.rb +189 -0
- data/spec/twitter/client/urls_spec.rb +31 -0
- data/spec/twitter/client/users_spec.rb +323 -0
- data/spec/twitter/client_spec.rb +94 -0
- data/spec/twitter/configuration_spec.rb +17 -0
- data/spec/twitter/cursor_spec.rb +43 -0
- data/spec/twitter/direct_message_spec.rb +56 -0
- data/spec/twitter/favorite_spec.rb +29 -0
- data/spec/twitter/follow_spec.rb +29 -0
- data/spec/twitter/geo_factory_spec.rb +21 -0
- data/spec/twitter/list_spec.rb +34 -0
- data/spec/twitter/media_factory_spec.rb +17 -0
- data/spec/twitter/mention_spec.rb +52 -0
- data/spec/twitter/oembed_spec.rb +145 -0
- data/spec/twitter/photo_spec.rb +35 -0
- data/spec/twitter/place_spec.rb +75 -0
- data/spec/twitter/point_spec.rb +32 -0
- data/spec/twitter/polygon_spec.rb +18 -0
- data/spec/twitter/rate_limit_status_spec.rb +16 -0
- data/spec/twitter/relationship_spec.rb +27 -0
- data/spec/twitter/reply_spec.rb +41 -0
- data/spec/twitter/retweet_spec.rb +41 -0
- data/spec/twitter/saved_search_spec.rb +34 -0
- data/spec/twitter/settings_spec.rb +16 -0
- data/spec/twitter/size_spec.rb +18 -0
- data/spec/twitter/status_spec.rb +148 -0
- data/spec/twitter/suggestion_spec.rb +20 -0
- data/spec/twitter/trend_spec.rb +20 -0
- data/spec/twitter/user_spec.rb +50 -0
- data/spec/twitter_spec.rb +91 -0
- data/twitter.gemspec +42 -0
- metadata +564 -0
@@ -0,0 +1,293 @@
|
|
1
|
+
require 'twitter/core_ext/hash'
|
2
|
+
require 'twitter/cursor'
|
3
|
+
require 'twitter/relationship'
|
4
|
+
require 'twitter/user'
|
5
|
+
|
6
|
+
module Twitter
|
7
|
+
class Client
|
8
|
+
# Defines methods related to friends and followers
|
9
|
+
module FriendsAndFollowers
|
10
|
+
|
11
|
+
# @see https://dev.twitter.com/docs/api/1/get/followers/ids
|
12
|
+
# @rate_limited Yes
|
13
|
+
# @requires_authentication No unless requesting it from a protected user
|
14
|
+
#
|
15
|
+
# If getting this data of a protected user, you must authenticate (and be allowed to see that user).
|
16
|
+
# @overload follower_ids(options={})
|
17
|
+
# Returns an array of numeric IDs for every user following the authenticated user
|
18
|
+
#
|
19
|
+
# @param options [Hash] A customizable set of options.
|
20
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
21
|
+
# @return [Twitter::Cursor]
|
22
|
+
# @example Return the authenticated user's followers' IDs
|
23
|
+
# Twitter.follower_ids
|
24
|
+
# @overload follower_ids(user, options={})
|
25
|
+
# Returns an array of numeric IDs for every user following the specified user
|
26
|
+
#
|
27
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
28
|
+
# @param options [Hash] A customizable set of options.
|
29
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
|
30
|
+
# @return [Twitter::Cursor]
|
31
|
+
# @example Return @sferik's followers' IDs
|
32
|
+
# Twitter.follower_ids("sferik")
|
33
|
+
# Twitter.follower_ids(7505382) # Same as above
|
34
|
+
def follower_ids(*args)
|
35
|
+
options = {:cursor => -1}
|
36
|
+
options.merge!(args.last.is_a?(Hash) ? args.pop : {})
|
37
|
+
user = args.first
|
38
|
+
options.merge_user!(user)
|
39
|
+
cursor = get("/1/followers/ids.json", options)
|
40
|
+
Twitter::Cursor.new(cursor, 'ids')
|
41
|
+
end
|
42
|
+
|
43
|
+
# @see https://dev.twitter.com/docs/api/1/get/friends/ids
|
44
|
+
# @rate_limited Yes
|
45
|
+
# @requires_authentication No unless requesting it from a protected user
|
46
|
+
#
|
47
|
+
# If getting this data of a protected user, you must authenticate (and be allowed to see that user).
|
48
|
+
# @overload friend_ids(options={})
|
49
|
+
# Returns an array of numeric IDs for every user the authenticated user is following
|
50
|
+
#
|
51
|
+
# @param options [Hash] A customizable set of options.
|
52
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. This is recommended for users who are following many users. Provide a value of -1 to begin paging. Provide values as returned in the response body's next_cursor and previous_cursor attributes to page back and forth in the list.
|
53
|
+
# @return [Twitter::Cursor]
|
54
|
+
# @example Return the authenticated user's friends' IDs
|
55
|
+
# Twitter.friend_ids
|
56
|
+
# @overload friend_ids(user, options={})
|
57
|
+
# Returns an array of numeric IDs for every user the specified user is following
|
58
|
+
#
|
59
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
60
|
+
# @param options [Hash] A customizable set of options.
|
61
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
62
|
+
# @return [Twitter::Cursor]
|
63
|
+
# @example Return @sferik's friends' IDs
|
64
|
+
# Twitter.friend_ids("sferik")
|
65
|
+
# Twitter.friend_ids(7505382) # Same as above
|
66
|
+
def friend_ids(*args)
|
67
|
+
options = {:cursor => -1}
|
68
|
+
options.merge!(args.last.is_a?(Hash) ? args.pop : {})
|
69
|
+
user = args.first
|
70
|
+
options.merge_user!(user)
|
71
|
+
cursor = get("/1/friends/ids.json", options)
|
72
|
+
Twitter::Cursor.new(cursor, 'ids')
|
73
|
+
end
|
74
|
+
|
75
|
+
# Test for the existence of friendship between two users
|
76
|
+
#
|
77
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/exists
|
78
|
+
# @note Consider using {Twitter::Client::FriendsAndFollowers#friendship} instead of this method.
|
79
|
+
# @rate_limited Yes
|
80
|
+
# @requires_authentication No unless user_a or user_b is protected
|
81
|
+
# @param user_a [Integer, String] The ID or screen_name of the subject user.
|
82
|
+
# @param user_b [Integer, String] The ID or screen_name of the user to test for following.
|
83
|
+
# @param options [Hash] A customizable set of options.
|
84
|
+
# @return [Boolean] true if user_a follows user_b, otherwise false.
|
85
|
+
# @example Return true if @sferik follows @pengwynn
|
86
|
+
# Twitter.friendship?("sferik", "pengwynn")
|
87
|
+
def friendship?(user_a, user_b, options={})
|
88
|
+
get("/1/friendships/exists.json", options.merge(:user_a => user_a, :user_b => user_b))
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
|
92
|
+
#
|
93
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/incoming
|
94
|
+
# @rate_limited Yes
|
95
|
+
# @requires_authentication Yes
|
96
|
+
# @param options [Hash] A customizable set of options.
|
97
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
98
|
+
# @return [Twitter::Cursor]
|
99
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
100
|
+
# @example Return an array of numeric IDs for every user who has a pending request to follow the authenticating user
|
101
|
+
# Twitter.friendships_incoming
|
102
|
+
def friendships_incoming(options={})
|
103
|
+
options = {:cursor => -1}.merge(options)
|
104
|
+
cursor = get("/1/friendships/incoming.json", options)
|
105
|
+
Twitter::Cursor.new(cursor, 'ids')
|
106
|
+
end
|
107
|
+
|
108
|
+
# Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
|
109
|
+
#
|
110
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/outgoing
|
111
|
+
# @rate_limited Yes
|
112
|
+
# @requires_authentication Yes
|
113
|
+
# @param options [Hash] A customizable set of options.
|
114
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
115
|
+
# @return [Twitter::Cursor]
|
116
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
117
|
+
# @example Return an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
|
118
|
+
# Twitter.friendships_outgoing
|
119
|
+
def friendships_outgoing(options={})
|
120
|
+
options = {:cursor => -1}.merge(options)
|
121
|
+
cursor = get("/1/friendships/outgoing.json", options)
|
122
|
+
Twitter::Cursor.new(cursor, 'ids')
|
123
|
+
end
|
124
|
+
|
125
|
+
# Returns detailed information about the relationship between two users
|
126
|
+
#
|
127
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/show
|
128
|
+
# @rate_limited Yes
|
129
|
+
# @requires_authentication No
|
130
|
+
# @param options [Hash] A customizable set of options.
|
131
|
+
# @return [Twitter::Relationship]
|
132
|
+
# @example Return the relationship between @sferik and @pengwynn
|
133
|
+
# Twitter.friendship("sferik", "pengwynn")
|
134
|
+
# Twitter.friendship(7505382, 14100886)
|
135
|
+
def friendship(source, target, options={})
|
136
|
+
case source
|
137
|
+
when Integer
|
138
|
+
options[:source_id] = source
|
139
|
+
when String
|
140
|
+
options[:source_screen_name] = source
|
141
|
+
end
|
142
|
+
case target
|
143
|
+
when Integer
|
144
|
+
options[:target_id] = target
|
145
|
+
when String
|
146
|
+
options[:target_screen_name] = target
|
147
|
+
end
|
148
|
+
relationship = get("/1/friendships/show.json", options)['relationship']
|
149
|
+
Twitter::Relationship.new(relationship)
|
150
|
+
end
|
151
|
+
alias :friendship_show :friendship
|
152
|
+
alias :relationship :friendship
|
153
|
+
|
154
|
+
# Allows the authenticating user to follow the specified user
|
155
|
+
#
|
156
|
+
# @see https://dev.twitter.com/docs/api/1/post/friendships/create
|
157
|
+
# @rate_limited No
|
158
|
+
# @requires_authentication Yes
|
159
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
160
|
+
# @param options [Hash] A customizable set of options.
|
161
|
+
# @option options [Boolean] :follow (false) Enable notifications for the target user.
|
162
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
163
|
+
# @return [Twitter::User] The followed user.
|
164
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
165
|
+
# @example Follow @sferik
|
166
|
+
# Twitter.follow("sferik")
|
167
|
+
def follow(user, options={})
|
168
|
+
options.merge_user!(user)
|
169
|
+
# Twitter always turns on notifications if the "follow" option is present, even if it's set to false
|
170
|
+
# so only send follow if it's true
|
171
|
+
options.merge!(:follow => true) if options.delete(:follow)
|
172
|
+
user = post("/1/friendships/create.json", options)
|
173
|
+
Twitter::User.new(user)
|
174
|
+
end
|
175
|
+
alias :friendship_create :follow
|
176
|
+
|
177
|
+
# Allows the authenticating user to unfollow the specified user
|
178
|
+
#
|
179
|
+
# @see https://dev.twitter.com/docs/api/1/post/friendships/destroy
|
180
|
+
# @rate_limited No
|
181
|
+
# @requires_authentication Yes
|
182
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
183
|
+
# @param options [Hash] A customizable set of options.
|
184
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
185
|
+
# @return [Twitter::User] The unfollowed user.
|
186
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
187
|
+
# @example Unfollow @sferik
|
188
|
+
# Twitter.unfollow("sferik")
|
189
|
+
def unfollow(user, options={})
|
190
|
+
options.merge_user!(user)
|
191
|
+
user = delete("/1/friendships/destroy.json", options)
|
192
|
+
Twitter::User.new(user)
|
193
|
+
end
|
194
|
+
alias :friendship_destroy :unfollow
|
195
|
+
|
196
|
+
# Returns the relationship of the authenticating user to the comma separated list of up to 100 screen_names or user_ids provided. Values for connections can be: following, following_requested, followed_by, none.
|
197
|
+
#
|
198
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/lookup
|
199
|
+
# @rate_limited Yes
|
200
|
+
# @requires_authentication Yes
|
201
|
+
# @param options [Hash] A customizable set of options.
|
202
|
+
# @return [Twitter::Relationship]
|
203
|
+
# @overload friendships(*users, options={})
|
204
|
+
# @param users [Array<Integer, String>, Set<Integer, String>] Twitter user IDs or screen names.
|
205
|
+
# @param options [Hash] A customizable set of options.
|
206
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet
|
207
|
+
# @return [Array<Twitter::User>] The requested users.
|
208
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
209
|
+
# @example Return extended information for @sferik and @pengwynn
|
210
|
+
# Twitter.friendships("sferik", "pengwynn")
|
211
|
+
# Twitter.friendships("sferik", 14100886) # Same as above
|
212
|
+
# Twitter.friendships(7505382, 14100886) # Same as above
|
213
|
+
def friendships(*args)
|
214
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
215
|
+
users = args
|
216
|
+
options.merge_users!(Array(users))
|
217
|
+
get("/1/friendships/lookup.json", options).map do |user|
|
218
|
+
Twitter::User.new(user)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# Allows one to enable or disable retweets and device notifications from the specified user.
|
223
|
+
#
|
224
|
+
# @see https://dev.twitter.com/docs/api/1/post/friendships/update
|
225
|
+
# @rate_limited No
|
226
|
+
# @requires_authentication Yes
|
227
|
+
# @param user [Integer, String] Twitter user ID or screen name.
|
228
|
+
# @param options [Hash] A customizable set of options.
|
229
|
+
# @option options [Boolean] :device Enable/disable device notifications from the target user.
|
230
|
+
# @option options [Boolean] :retweets Enable/disable retweets from the target user.
|
231
|
+
# @return [Twitter::Relationship]
|
232
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
233
|
+
# @example Enable rewteets and devise notifications for @sferik
|
234
|
+
# Twitter.friendship_update("sferik", :device => true, :retweets => true)
|
235
|
+
def friendship_update(user, options={})
|
236
|
+
options.merge_user!(user)
|
237
|
+
relationship = post("/1/friendships/update.json", options)['relationship']
|
238
|
+
Twitter::Relationship.new(relationship)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Returns an array of user_ids that the currently authenticated user does not want to see retweets from.
|
242
|
+
#
|
243
|
+
# @see https://dev.twitter.com/docs/api/1/get/friendships/no_retweet_ids
|
244
|
+
# @rate_limited Yes
|
245
|
+
# @requires_authentication Yes
|
246
|
+
# @param user [Integer, String] Twitter user ID or screen name.
|
247
|
+
# @param options [Hash] A customizable set of options.
|
248
|
+
# @option options [Boolean] :stringify_ids Many programming environments will not consume our ids due to their size. Provide this option to have ids returned as strings instead. Read more about Twitter IDs, JSON and Snowflake.
|
249
|
+
# @return [Array<Integer>]
|
250
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
251
|
+
# @example Enable rewteets and devise notifications for @sferik
|
252
|
+
# Twitter.no_retweet_ids
|
253
|
+
def no_retweet_ids(options={})
|
254
|
+
get("/1/friendships/no_retweet_ids.json", options, :phoenix => true)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Allows the authenticating user to accept the specified user's follow request
|
258
|
+
#
|
259
|
+
# @note Undocumented
|
260
|
+
# @rate_limited No
|
261
|
+
# @requires_authentication Yes
|
262
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
263
|
+
# @param options [Hash] A customizable set of options.
|
264
|
+
# @return [Twitter::User] The accepted user.
|
265
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
266
|
+
# @example Accept @sferik's follow request
|
267
|
+
# Twitter.accept("sferik")
|
268
|
+
def accept(user, options={})
|
269
|
+
options.merge_user!(user)
|
270
|
+
user = post("/1/friendships/accept.json", options)
|
271
|
+
Twitter::User.new(user)
|
272
|
+
end
|
273
|
+
|
274
|
+
# Allows the authenticating user to deny the specified user's follow request
|
275
|
+
#
|
276
|
+
# @note Undocumented
|
277
|
+
# @rate_limited No
|
278
|
+
# @requires_authentication Yes
|
279
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
280
|
+
# @param options [Hash] A customizable set of options.
|
281
|
+
# @return [Twitter::User] The denied user.
|
282
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
283
|
+
# @example Deny @sferik's follow request
|
284
|
+
# Twitter.deny("sferik")
|
285
|
+
def deny(user, options={})
|
286
|
+
options.merge_user!(user)
|
287
|
+
user = post("/1/friendships/deny.json", options)
|
288
|
+
Twitter::User.new(user)
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'twitter/configuration'
|
2
|
+
require 'twitter/language'
|
3
|
+
|
4
|
+
module Twitter
|
5
|
+
class Client
|
6
|
+
# Defines methods related twitter's supported features and configuration
|
7
|
+
module Help
|
8
|
+
|
9
|
+
# Returns the current configuration used by Twitter
|
10
|
+
#
|
11
|
+
# @see https://dev.twitter.com/docs/api/1/get/help/configuration
|
12
|
+
# @rate_limited Yes
|
13
|
+
# @requires_authentication No
|
14
|
+
# @return [Twitter::Configuration] Twitter's configuration.
|
15
|
+
# @example Return the current configuration used by Twitter
|
16
|
+
# Twitter.configuration
|
17
|
+
def configuration(options={})
|
18
|
+
configuration = get("/1/help/configuration.json", options)
|
19
|
+
Twitter::Configuration.new(configuration)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the list of languages supported by Twitter
|
23
|
+
#
|
24
|
+
# @see https://dev.twitter.com/docs/api/1/get/help/languages
|
25
|
+
# @rate_limited Yes
|
26
|
+
# @requires_authentication No
|
27
|
+
# @return [Array<Twitter::Language>]
|
28
|
+
# @example Return the list of languages Twitter supports
|
29
|
+
# Twitter.languages
|
30
|
+
def languages(options={})
|
31
|
+
get("/1/help/languages.json", options).map do |language|
|
32
|
+
Twitter::Language.new(language)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Twitter
|
2
|
+
class Client
|
3
|
+
# Defines methods related to legal documents
|
4
|
+
module Legal
|
5
|
+
|
6
|
+
# Returns {https://twitter.com/privacy Twitter's Privacy Policy}
|
7
|
+
#
|
8
|
+
# @see https://dev.twitter.com/docs/api/1/get/legal/privacy
|
9
|
+
# @rate_limited Yes
|
10
|
+
# @requires_authentication No
|
11
|
+
# @return [String]
|
12
|
+
# @example Return {https://twitter.com/privacy Twitter's Privacy Policy}
|
13
|
+
# Twitter.privacy
|
14
|
+
def privacy(options={})
|
15
|
+
get("/1/legal/privacy.json", options)['privacy']
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns {https://twitter.com/tos Twitter's Terms of Service}
|
19
|
+
#
|
20
|
+
# @see https://dev.twitter.com/docs/api/1/get/legal/tos
|
21
|
+
# @rate_limited Yes
|
22
|
+
# @requires_authentication No
|
23
|
+
# @return [String]
|
24
|
+
# @example Return {https://twitter.com/tos Twitter's Terms of Service}
|
25
|
+
# Twitter.tos
|
26
|
+
def tos(options={})
|
27
|
+
get("/1/legal/tos.json", options)['tos']
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,643 @@
|
|
1
|
+
require 'twitter/core_ext/hash'
|
2
|
+
require 'twitter/cursor'
|
3
|
+
require 'twitter/error/forbidden'
|
4
|
+
require 'twitter/error/not_found'
|
5
|
+
require 'twitter/list'
|
6
|
+
require 'twitter/status'
|
7
|
+
require 'twitter/user'
|
8
|
+
|
9
|
+
module Twitter
|
10
|
+
class Client
|
11
|
+
module Lists
|
12
|
+
|
13
|
+
# Returns all lists the authenticating or specified user subscribes to, including their own
|
14
|
+
#
|
15
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/all
|
16
|
+
# @rate_limited Yes
|
17
|
+
# @requires_authentication Supported
|
18
|
+
# @overload lists_subscribed_to(options={})
|
19
|
+
# @param options [Hash] A customizable set of options.
|
20
|
+
# @return [Array<Twitter::Status>]
|
21
|
+
# @example Return all lists the authenticating user subscribes to
|
22
|
+
# Twitter.lists_subscribed_to
|
23
|
+
# @overload lists_subscribed_to(user, options={})
|
24
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
25
|
+
# @param options [Hash] A customizable set of options.
|
26
|
+
# @return [Array<Twitter::List>]
|
27
|
+
# @example Return all lists the specified user subscribes to
|
28
|
+
# Twitter.lists_subscribed_to("sferik")
|
29
|
+
# Twitter.lists_subscribed_to(8863586)
|
30
|
+
def lists_subscribed_to(*args)
|
31
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
32
|
+
if user = args.pop
|
33
|
+
options.merge_user!(user)
|
34
|
+
end
|
35
|
+
get("/1/lists/all.json", options).map do |list|
|
36
|
+
Twitter::List.new(list)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Show tweet timeline for members of the specified list
|
41
|
+
#
|
42
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/statuses
|
43
|
+
# @rate_limited Yes
|
44
|
+
# @requires_authentication No
|
45
|
+
# @overload list_timeline(list, options={})
|
46
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
47
|
+
# @param options [Hash] A customizable set of options.
|
48
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
49
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
50
|
+
# @option options [Integer] :per_page The number of results to retrieve.
|
51
|
+
# @option options [Integer] :page Specifies the page of results to retrieve.
|
52
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
53
|
+
# @return [Array<Twitter::Status>]
|
54
|
+
# @example Show tweet timeline for members of the authenticated user's "presidents" list
|
55
|
+
# Twitter.list_timeline("presidents")
|
56
|
+
# Twitter.list_timeline(8863586)
|
57
|
+
# @overload list_timeline(user, list, options={})
|
58
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
59
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
60
|
+
# @param options [Hash] A customizable set of options.
|
61
|
+
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
62
|
+
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
63
|
+
# @option options [Integer] :per_page The number of results to retrieve.
|
64
|
+
# @option options [Integer] :page Specifies the page of results to retrieve.
|
65
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
66
|
+
# @return [Array<Twitter::Status>]
|
67
|
+
# @example Show tweet timeline for members of @sferik's "presidents" list
|
68
|
+
# Twitter.list_timeline("sferik", "presidents")
|
69
|
+
# Twitter.list_timeline("sferik", 8863586)
|
70
|
+
# Twitter.list_timeline(7505382, "presidents")
|
71
|
+
# Twitter.list_timeline(7505382, 8863586)
|
72
|
+
def list_timeline(*args)
|
73
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
74
|
+
list = args.pop
|
75
|
+
options.merge_list!(list)
|
76
|
+
owner = args.pop || self.current_user.screen_name
|
77
|
+
options.merge_owner!(owner)
|
78
|
+
get("/1/lists/statuses.json", options).map do |status|
|
79
|
+
Twitter::Status.new(status)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
# Removes the specified member from the list
|
84
|
+
#
|
85
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/members/destroy
|
86
|
+
# @rate_limited No
|
87
|
+
# @requires_authentication Yes
|
88
|
+
# @overload list_remove_member(list, user_to_remove, options={})
|
89
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
90
|
+
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
|
91
|
+
# @param options [Hash] A customizable set of options.
|
92
|
+
# @return [Twitter::List] The list.
|
93
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
94
|
+
# @example Remove @BarackObama from the authenticated user's "presidents" list
|
95
|
+
# Twitter.list_remove_member("presidents", 813286)
|
96
|
+
# Twitter.list_remove_member("presidents", 'BarackObama')
|
97
|
+
# Twitter.list_remove_member(8863586, 'BarackObama')
|
98
|
+
# @overload list_remove_member(user, list, user_to_remove, options={})
|
99
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
100
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
101
|
+
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
|
102
|
+
# @param options [Hash] A customizable set of options.
|
103
|
+
# @return [Twitter::List] The list.
|
104
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
105
|
+
# @example Remove @BarackObama from @sferik's "presidents" list
|
106
|
+
# Twitter.list_remove_member("sferik", "presidents", 813286)
|
107
|
+
# Twitter.list_remove_member("sferik", "presidents", 'BarackObama')
|
108
|
+
# Twitter.list_remove_member('sferik', 8863586, 'BarackObama')
|
109
|
+
# Twitter.list_remove_member(7505382, "presidents", 813286)
|
110
|
+
def list_remove_member(*args)
|
111
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
112
|
+
user_to_remove = args.pop
|
113
|
+
options.merge_user!(user_to_remove)
|
114
|
+
list = args.pop
|
115
|
+
options.merge_list!(list)
|
116
|
+
owner = args.pop || self.current_user.screen_name
|
117
|
+
options.merge_owner!(owner)
|
118
|
+
list = post("/1/lists/members/destroy.json", options)
|
119
|
+
Twitter::List.new(list)
|
120
|
+
end
|
121
|
+
|
122
|
+
# List the lists the specified user has been added to
|
123
|
+
#
|
124
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/memberships
|
125
|
+
# @rate_limited Yes
|
126
|
+
# @requires_authentication Supported
|
127
|
+
# @overload memberships(options={})
|
128
|
+
# @param options [Hash] A customizable set of options.
|
129
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
130
|
+
# @return [Twitter::Cursor]
|
131
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
132
|
+
# @example List the lists the authenticated user has been added to
|
133
|
+
# Twitter.memberships
|
134
|
+
# @overload memberships(user, options={})
|
135
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
136
|
+
# @param options [Hash] A customizable set of options.
|
137
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
138
|
+
# @return [Twitter::Cursor]
|
139
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
140
|
+
# @example List the lists that @sferik has been added to
|
141
|
+
# Twitter.memberships("sferik")
|
142
|
+
# Twitter.memberships(7505382)
|
143
|
+
def memberships(*args)
|
144
|
+
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
|
145
|
+
if user = args.pop
|
146
|
+
options.merge_user!(user)
|
147
|
+
end
|
148
|
+
cursor = get("/1/lists/memberships.json", options)
|
149
|
+
Twitter::Cursor.new(cursor, 'lists', Twitter::List)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Returns the subscribers of the specified list
|
153
|
+
#
|
154
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/subscribers
|
155
|
+
# @rate_limited Yes
|
156
|
+
# @requires_authentication Supported
|
157
|
+
# @overload list_subscribers(list, options={})
|
158
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
159
|
+
# @param options [Hash] A customizable set of options.
|
160
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
161
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
162
|
+
# @return [Twitter::Cursor] The subscribers of the specified list.
|
163
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
164
|
+
# @example Return the subscribers of the authenticated user's "presidents" list
|
165
|
+
# Twitter.list_subscribers('presidents')
|
166
|
+
# Twitter.list_subscribers(8863586)
|
167
|
+
# @overload list_subscribers(user, list, options={})
|
168
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
169
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
170
|
+
# @param options [Hash] A customizable set of options.
|
171
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
172
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
173
|
+
# @return [Twitter::Cursor] The subscribers of the specified list.
|
174
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
175
|
+
# @example Return the subscribers of @sferik's "presidents" list
|
176
|
+
# Twitter.list_subscribers("sferik", 'presidents')
|
177
|
+
# Twitter.list_subscribers("sferik", 8863586)
|
178
|
+
# Twitter.list_subscribers(7505382, 'presidents')
|
179
|
+
def list_subscribers(*args)
|
180
|
+
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
|
181
|
+
list = args.pop
|
182
|
+
options.merge_list!(list)
|
183
|
+
owner = args.pop || self.current_user.screen_name
|
184
|
+
options.merge_owner!(owner)
|
185
|
+
cursor = get("/1/lists/subscribers.json", options)
|
186
|
+
Twitter::Cursor.new(cursor, 'users', Twitter::User)
|
187
|
+
end
|
188
|
+
|
189
|
+
# List the lists the specified user follows
|
190
|
+
#
|
191
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/subscriptions
|
192
|
+
# @rate_limited Yes
|
193
|
+
# @requires_authentication Supported
|
194
|
+
# @overload subscriptions(options={})
|
195
|
+
# @param options [Hash] A customizable set of options.
|
196
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
197
|
+
# @return [Twitter::Cursor]
|
198
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
199
|
+
# @example List the lists the authenticated user follows
|
200
|
+
# Twitter.subscriptions
|
201
|
+
# @overload subscriptions(user, options={})
|
202
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
203
|
+
# @param options [Hash] A customizable set of options.
|
204
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
205
|
+
# @return [Twitter::Cursor]
|
206
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
207
|
+
# @example List the lists that @sferik follows
|
208
|
+
# Twitter.subscriptions("sferik")
|
209
|
+
# Twitter.subscriptions(7505382)
|
210
|
+
def subscriptions(*args)
|
211
|
+
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
|
212
|
+
if user = args.pop
|
213
|
+
options.merge_user!(user)
|
214
|
+
end
|
215
|
+
cursor = get("/1/lists/subscriptions.json", options)
|
216
|
+
Twitter::Cursor.new(cursor, 'lists', Twitter::List)
|
217
|
+
end
|
218
|
+
|
219
|
+
# Make the authenticated user follow the specified list
|
220
|
+
#
|
221
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/subscribers/create
|
222
|
+
# @rate_limited No
|
223
|
+
# @requires_authentication Yes
|
224
|
+
# @overload list_subscribe(list, options={})
|
225
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
226
|
+
# @param options [Hash] A customizable set of options.
|
227
|
+
# @return [Twitter::List] The specified list.
|
228
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
229
|
+
# @example Subscribe to the authenticated user's "presidents" list
|
230
|
+
# Twitter.list_subscribe('presidents')
|
231
|
+
# Twitter.list_subscribe(8863586)
|
232
|
+
# @overload list_subscribe(user, list, options={})
|
233
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
234
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
235
|
+
# @param options [Hash] A customizable set of options.
|
236
|
+
# @return [Twitter::List] The specified list.
|
237
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
238
|
+
# @example Subscribe to @sferik's "presidents" list
|
239
|
+
# Twitter.list_subscribe("sferik", 'presidents')
|
240
|
+
# Twitter.list_subscribe("sferik", 8863586)
|
241
|
+
# Twitter.list_subscribe(7505382, 'presidents')
|
242
|
+
def list_subscribe(*args)
|
243
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
244
|
+
list = args.pop
|
245
|
+
options.merge_list!(list)
|
246
|
+
owner = args.pop || self.current_user.screen_name
|
247
|
+
options.merge_owner!(owner)
|
248
|
+
list = post("/1/lists/subscribers/create.json", options)
|
249
|
+
Twitter::List.new(list)
|
250
|
+
end
|
251
|
+
|
252
|
+
# Check if a user is a subscriber of the specified list
|
253
|
+
#
|
254
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/subscribers/show
|
255
|
+
# @rate_limited Yes
|
256
|
+
# @requires_authentication Yes
|
257
|
+
# @overload list_subscriber?(list, user_to_check, options={})
|
258
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
259
|
+
# @param user_to_check [Integer, String] The user ID or screen_name of the list member.
|
260
|
+
# @param options [Hash] A customizable set of options.
|
261
|
+
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
262
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
263
|
+
# @example Check if @BarackObama is a subscriber of the authenticated user's "presidents" list
|
264
|
+
# Twitter.list_subscriber?('presidents', 813286)
|
265
|
+
# Twitter.list_subscriber?(8863586, 813286)
|
266
|
+
# Twitter.list_subscriber?('presidents', 'BarackObama')
|
267
|
+
# @overload list_subscriber?(user, list, user_to_check, options={})
|
268
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
269
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
270
|
+
# @param user_to_check [Integer, String] The user ID or screen_name of the list member.
|
271
|
+
# @param options [Hash] A customizable set of options.
|
272
|
+
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
273
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
274
|
+
# @example Check if @BarackObama is a subscriber of @sferik's "presidents" list
|
275
|
+
# Twitter.list_subscriber?("sferik", 'presidents', 813286)
|
276
|
+
# Twitter.list_subscriber?("sferik", 8863586, 813286)
|
277
|
+
# Twitter.list_subscriber?(7505382, 'presidents', 813286)
|
278
|
+
# Twitter.list_subscriber?("sferik", 'presidents', 'BarackObama')
|
279
|
+
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
280
|
+
def list_subscriber?(*args)
|
281
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
282
|
+
user_to_check = args.pop
|
283
|
+
options.merge_user!(user_to_check)
|
284
|
+
list = args.pop
|
285
|
+
options.merge_list!(list)
|
286
|
+
owner = args.pop || self.current_user.screen_name
|
287
|
+
options.merge_owner!(owner)
|
288
|
+
get("/1/lists/subscribers/show.json", options, :raw => true)
|
289
|
+
true
|
290
|
+
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
|
291
|
+
false
|
292
|
+
end
|
293
|
+
|
294
|
+
# Unsubscribes the authenticated user form the specified list
|
295
|
+
#
|
296
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/subscribers/destroy
|
297
|
+
# @rate_limited No
|
298
|
+
# @requires_authentication Yes
|
299
|
+
# @overload list_unsubscribe(list, options={})
|
300
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
301
|
+
# @param options [Hash] A customizable set of options.
|
302
|
+
# @return [Twitter::List] The specified list.
|
303
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
304
|
+
# @example Unsubscribe from the authenticated user's "presidents" list
|
305
|
+
# Twitter.list_unsubscribe('presidents')
|
306
|
+
# Twitter.list_unsubscribe(8863586)
|
307
|
+
# @overload list_unsubscribe(user, list, options={})
|
308
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
309
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
310
|
+
# @param options [Hash] A customizable set of options.
|
311
|
+
# @return [Twitter::List] The specified list.
|
312
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
313
|
+
# @example Unsubscribe from @sferik's "presidents" list
|
314
|
+
# Twitter.list_unsubscribe("sferik", 'presidents')
|
315
|
+
# Twitter.list_unsubscribe("sferik", 8863586)
|
316
|
+
# Twitter.list_unsubscribe(7505382, 'presidents')
|
317
|
+
def list_unsubscribe(*args)
|
318
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
319
|
+
list = args.pop
|
320
|
+
options.merge_list!(list)
|
321
|
+
owner = args.pop || self.current_user.screen_name
|
322
|
+
options.merge_owner!(owner)
|
323
|
+
list = post("/1/lists/subscribers/destroy.json", options)
|
324
|
+
Twitter::List.new(list)
|
325
|
+
end
|
326
|
+
|
327
|
+
# Adds multiple members to a list
|
328
|
+
#
|
329
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/members/create_all
|
330
|
+
# @note Lists are limited to having 500 members, and you are limited to adding up to 100 members to a list at a time with this method.
|
331
|
+
# @rate_limited No
|
332
|
+
# @requires_authentication Yes
|
333
|
+
# @overload list_add_members(list, users_to_add, options={})
|
334
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
335
|
+
# @param users_to_add [Array] The user IDs and/or screen names to add.
|
336
|
+
# @param options [Hash] A customizable set of options.
|
337
|
+
# @return [Twitter::List] The list.
|
338
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
339
|
+
# @example Add @BarackObama and @pengwynn to the authenticated user's "presidents" list
|
340
|
+
# Twitter.list_add_members("presidents", [813286, 18755393])
|
341
|
+
# Twitter.list_add_members('presidents', [813286, 'pengwynn'])
|
342
|
+
# Twitter.list_add_members(8863586, [813286, 18755393])
|
343
|
+
# @overload list_add_members(user, list, users_to_add, options={})
|
344
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
345
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
346
|
+
# @param users_to_add [Array] The user IDs and/or screen names to add.
|
347
|
+
# @param options [Hash] A customizable set of options.
|
348
|
+
# @return [Twitter::List] The list.
|
349
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
350
|
+
# @example Add @BarackObama and @pengwynn to @sferik's "presidents" list
|
351
|
+
# Twitter.list_add_members("sferik", "presidents", [813286, 18755393])
|
352
|
+
# Twitter.list_add_members('sferik', 'presidents', [813286, 'pengwynn'])
|
353
|
+
# Twitter.list_add_members('sferik', 8863586, [813286, 18755393])
|
354
|
+
# Twitter.list_add_members(7505382, "presidents", [813286, 18755393])
|
355
|
+
# Twitter.list_add_members(7505382, 8863586, [813286, 18755393])
|
356
|
+
def list_add_members(*args)
|
357
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
358
|
+
users_to_add = args.pop
|
359
|
+
options.merge_users!(Array(users_to_add))
|
360
|
+
list = args.pop
|
361
|
+
options.merge_list!(list)
|
362
|
+
owner = args.pop || self.current_user.screen_name
|
363
|
+
options.merge_owner!(owner)
|
364
|
+
list = post("/1/lists/members/create_all.json", options)
|
365
|
+
Twitter::List.new(list)
|
366
|
+
end
|
367
|
+
|
368
|
+
# Check if a user is a member of the specified list
|
369
|
+
#
|
370
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/members/show
|
371
|
+
# @requires_authentication Yes
|
372
|
+
# @rate_limited Yes
|
373
|
+
# @overload list_member?(list, user_to_check, options={})
|
374
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
375
|
+
# @param user_to_check [Integer, String] The user ID or screen name of the list member.
|
376
|
+
# @param options [Hash] A customizable set of options.
|
377
|
+
# @return [Boolean] true if user is a member of the specified list, otherwise false.
|
378
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
379
|
+
# @example Check if @BarackObama is a member of the authenticated user's "presidents" list
|
380
|
+
# Twitter.list_member?("presidents", 813286)
|
381
|
+
# Twitter.list_member?(8863586, 'BarackObama')
|
382
|
+
# @overload list_member?(user, list, user_to_check, options={})
|
383
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
384
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
385
|
+
# @param user_to_check [Integer, String] The user ID or screen name of the list member.
|
386
|
+
# @param options [Hash] A customizable set of options.
|
387
|
+
# @return [Boolean] true if user is a member of the specified list, otherwise false.
|
388
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
389
|
+
# @example Check if @BarackObama is a member of @sferik's "presidents" list
|
390
|
+
# Twitter.list_member?("sferik", "presidents", 813286)
|
391
|
+
# Twitter.list_member?('sferik', 8863586, 'BarackObama')
|
392
|
+
# Twitter.list_member?(7505382, "presidents", 813286)
|
393
|
+
def list_member?(*args)
|
394
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
395
|
+
user_to_check = args.pop
|
396
|
+
options.merge_user!(user_to_check)
|
397
|
+
list = args.pop
|
398
|
+
options.merge_list!(list)
|
399
|
+
owner = args.pop || self.current_user.screen_name
|
400
|
+
options.merge_owner!(owner)
|
401
|
+
get("/1/lists/members/show.json", options, :raw => true)
|
402
|
+
true
|
403
|
+
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
|
404
|
+
false
|
405
|
+
end
|
406
|
+
|
407
|
+
# Returns the members of the specified list
|
408
|
+
#
|
409
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/members
|
410
|
+
# @rate_limited Yes
|
411
|
+
# @requires_authentication Yes
|
412
|
+
# @overload list_members(list, options={})
|
413
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
414
|
+
# @param options [Hash] A customizable set of options.
|
415
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
416
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
417
|
+
# @return [Twitter::Cursor]
|
418
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
419
|
+
# @example Return the members of the authenticated user's "presidents" list
|
420
|
+
# Twitter.list_members("presidents")
|
421
|
+
# Twitter.list_members(8863586)
|
422
|
+
# @overload list_members(user, list, options={})
|
423
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
424
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
425
|
+
# @param options [Hash] A customizable set of options.
|
426
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
427
|
+
# @option options [Boolean, String, Integer] :include_entities Include {https://dev.twitter.com/docs/tweet-entities Tweet Entities} when set to true, 't' or 1.
|
428
|
+
# @return [Twitter::Cursor]
|
429
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
430
|
+
# @example Return the members of @sferik's "presidents" list
|
431
|
+
# Twitter.list_members("sferik", "presidents")
|
432
|
+
# Twitter.list_members("sferik", 8863586)
|
433
|
+
# Twitter.list_members(7505382, "presidents")
|
434
|
+
# Twitter.list_members(7505382, 8863586)
|
435
|
+
def list_members(*args)
|
436
|
+
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
|
437
|
+
list = args.pop
|
438
|
+
options.merge_list!(list)
|
439
|
+
owner = args.pop || self.current_user.screen_name
|
440
|
+
options.merge_owner!(owner)
|
441
|
+
cursor = get("/1/lists/members.json", options)
|
442
|
+
Twitter::Cursor.new(cursor, 'users', Twitter::User)
|
443
|
+
end
|
444
|
+
|
445
|
+
# Add a member to a list
|
446
|
+
#
|
447
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/members/create
|
448
|
+
# @note Lists are limited to having 500 members.
|
449
|
+
# @rate_limited No
|
450
|
+
# @requires_authentication Yes
|
451
|
+
# @overload list_add_member(list, user_to_add, options={})
|
452
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
453
|
+
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
|
454
|
+
# @param options [Hash] A customizable set of options.
|
455
|
+
# @return [Twitter::List] The list.
|
456
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
457
|
+
# @example Add @BarackObama to the authenticated user's "presidents" list
|
458
|
+
# Twitter.list_add_member("presidents", 813286)
|
459
|
+
# Twitter.list_add_member(8863586, 813286)
|
460
|
+
# @overload list_add_member(user, list, user_to_add, options={})
|
461
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
462
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
463
|
+
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
|
464
|
+
# @param options [Hash] A customizable set of options.
|
465
|
+
# @return [Twitter::List] The list.
|
466
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
467
|
+
# @example Add @BarackObama to @sferik's "presidents" list
|
468
|
+
# Twitter.list_add_member("sferik", "presidents", 813286)
|
469
|
+
# Twitter.list_add_member('sferik', 8863586, 813286)
|
470
|
+
# Twitter.list_add_member(7505382, "presidents", 813286)
|
471
|
+
# Twitter.list_add_member(7505382, 8863586, 813286)
|
472
|
+
def list_add_member(*args)
|
473
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
474
|
+
user_to_add = args.pop
|
475
|
+
options.merge_user!(user_to_add)
|
476
|
+
list = args.pop
|
477
|
+
options.merge_list!(list)
|
478
|
+
owner = args.pop || self.current_user.screen_name
|
479
|
+
options.merge_owner!(owner)
|
480
|
+
list = post("/1/lists/members/create.json", options)
|
481
|
+
Twitter::List.new(list)
|
482
|
+
end
|
483
|
+
|
484
|
+
# Deletes the specified list
|
485
|
+
#
|
486
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/destroy
|
487
|
+
# @note Must be owned by the authenticated user.
|
488
|
+
# @rate_limited No
|
489
|
+
# @requires_authentication Yes
|
490
|
+
# @overload list_destroy(list, options={})
|
491
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
492
|
+
# @param options [Hash] A customizable set of options.
|
493
|
+
# @return [Twitter::List] The deleted list.
|
494
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
495
|
+
# @example Delete the authenticated user's "presidents" list
|
496
|
+
# Twitter.list_destroy("presidents")
|
497
|
+
# Twitter.list_destroy(8863586)
|
498
|
+
# @overload list_destroy(user, list, options={})
|
499
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
500
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
501
|
+
# @param options [Hash] A customizable set of options.
|
502
|
+
# @return [Twitter::List] The deleted list.
|
503
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
504
|
+
# @example Delete @sferik's "presidents" list
|
505
|
+
# Twitter.list_destroy("sferik", "presidents")
|
506
|
+
# Twitter.list_destroy("sferik", 8863586)
|
507
|
+
# Twitter.list_destroy(7505382, "presidents")
|
508
|
+
# Twitter.list_destroy(7505382, 8863586)
|
509
|
+
def list_destroy(*args)
|
510
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
511
|
+
list = args.pop
|
512
|
+
options.merge_list!(list)
|
513
|
+
owner = args.pop || self.current_user.screen_name
|
514
|
+
options.merge_owner!(owner)
|
515
|
+
list = delete("/1/lists/destroy.json", options)
|
516
|
+
Twitter::List.new(list)
|
517
|
+
end
|
518
|
+
|
519
|
+
# Updates the specified list
|
520
|
+
#
|
521
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/update
|
522
|
+
# @rate_limited No
|
523
|
+
# @requires_authentication Yes
|
524
|
+
# @overload list_update(list, options={})
|
525
|
+
# @param list [Integer, String] The list_id or slug for the list.
|
526
|
+
# @param options [Hash] A customizable set of options.
|
527
|
+
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
528
|
+
# @option options [String] :description The description to give the list.
|
529
|
+
# @return [Twitter::List] The created list.
|
530
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
531
|
+
# @example Update the authenticated user's "presidents" list to have the description "Presidents of the United States of America"
|
532
|
+
# Twitter.list_update("presidents", :description => "Presidents of the United States of America")
|
533
|
+
# Twitter.list_update(8863586, :description => "Presidents of the United States of America")
|
534
|
+
# @overload list_update(user, list, options={})
|
535
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
536
|
+
# @param list [Integer, String] The list_id or slug for the list.
|
537
|
+
# @param options [Hash] A customizable set of options.
|
538
|
+
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
539
|
+
# @option options [String] :description The description to give the list.
|
540
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
541
|
+
# @return [Twitter::List] The created list.
|
542
|
+
# @example Update the @sferik's "presidents" list to have the description "Presidents of the United States of America"
|
543
|
+
# Twitter.list_update("sferik", "presidents", :description => "Presidents of the United States of America")
|
544
|
+
# Twitter.list_update(7505382, "presidents", :description => "Presidents of the United States of America")
|
545
|
+
# Twitter.list_update("sferik", 8863586, :description => "Presidents of the United States of America")
|
546
|
+
# Twitter.list_update(7505382, 8863586, :description => "Presidents of the United States of America")
|
547
|
+
def list_update(*args)
|
548
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
549
|
+
list = args.pop
|
550
|
+
options.merge_list!(list)
|
551
|
+
owner = args.pop || self.current_user.screen_name
|
552
|
+
options.merge_owner!(owner)
|
553
|
+
list = post("/1/lists/update.json", options)
|
554
|
+
Twitter::List.new(list)
|
555
|
+
end
|
556
|
+
|
557
|
+
# Creates a new list for the authenticated user
|
558
|
+
#
|
559
|
+
# @see https://dev.twitter.com/docs/api/1/post/lists/create
|
560
|
+
# @note Accounts are limited to 20 lists.
|
561
|
+
# @rate_limited No
|
562
|
+
# @requires_authentication Yes
|
563
|
+
# @param name [String] The name for the list.
|
564
|
+
# @param options [Hash] A customizable set of options.
|
565
|
+
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
566
|
+
# @option options [String] :description The description to give the list.
|
567
|
+
# @return [Twitter::List] The created list.
|
568
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
569
|
+
# @example Create a list named "presidents"
|
570
|
+
# Twitter.list_create("presidents")
|
571
|
+
def list_create(name, options={})
|
572
|
+
list = post("/1/lists/create.json", options.merge(:name => name))
|
573
|
+
Twitter::List.new(list)
|
574
|
+
end
|
575
|
+
|
576
|
+
# List the lists of the specified user
|
577
|
+
#
|
578
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists
|
579
|
+
# @note Private lists will be included if the authenticated user is the same as the user whose lists are being returned.
|
580
|
+
# @rate_limited Yes
|
581
|
+
# @requires_authentication Yes
|
582
|
+
# @overload lists(options={})
|
583
|
+
# @param options [Hash] A customizable set of options.
|
584
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
585
|
+
# @return [Twitter::Cursor]
|
586
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
587
|
+
# @example List the authenticated user's lists
|
588
|
+
# Twitter.lists
|
589
|
+
# @overload lists(user, options={})
|
590
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
591
|
+
# @param options [Hash] A customizable set of options.
|
592
|
+
# @option options [Integer] :cursor (-1) Breaks the results into pages. Provide values as returned in the response objects's next_cursor and previous_cursor attributes to page back and forth in the list.
|
593
|
+
# @return [Twitter::Cursor]
|
594
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
595
|
+
# @example List @sferik's lists
|
596
|
+
# Twitter.lists("sferik")
|
597
|
+
# Twitter.lists(7505382)
|
598
|
+
def lists(*args)
|
599
|
+
options = {:cursor => -1}.merge(args.last.is_a?(Hash) ? args.pop : {})
|
600
|
+
user = args.first
|
601
|
+
options.merge_user!(user) if user
|
602
|
+
cursor = get("/1/lists.json", options)
|
603
|
+
Twitter::Cursor.new(cursor, 'lists', Twitter::List)
|
604
|
+
end
|
605
|
+
|
606
|
+
# Show the specified list
|
607
|
+
#
|
608
|
+
# @see https://dev.twitter.com/docs/api/1/get/lists/show
|
609
|
+
# @note Private lists will only be shown if the authenticated user owns the specified list.
|
610
|
+
# @rate_limited Yes
|
611
|
+
# @requires_authentication Yes
|
612
|
+
# @overload list(list, options={})
|
613
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
614
|
+
# @param options [Hash] A customizable set of options.
|
615
|
+
# @return [Twitter::List] The specified list.
|
616
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
617
|
+
# @example Show the authenticated user's "presidents" list
|
618
|
+
# Twitter.list("presidents")
|
619
|
+
# Twitter.list(8863586)
|
620
|
+
# @overload list(user, list, options={})
|
621
|
+
# @param user [Integer, String] A Twitter user ID or screen name.
|
622
|
+
# @param list [Integer, String] The list_id or slug of the list.
|
623
|
+
# @param options [Hash] A customizable set of options.
|
624
|
+
# @return [Twitter::List] The specified list.
|
625
|
+
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
626
|
+
# @example Show @sferik's "presidents" list
|
627
|
+
# Twitter.list("sferik", "presidents")
|
628
|
+
# Twitter.list("sferik", 8863586)
|
629
|
+
# Twitter.list(7505382, "presidents")
|
630
|
+
# Twitter.list(7505382, 8863586)
|
631
|
+
def list(*args)
|
632
|
+
options = args.last.is_a?(Hash) ? args.pop : {}
|
633
|
+
list = args.pop
|
634
|
+
options.merge_list!(list)
|
635
|
+
owner = args.pop || self.current_user.screen_name
|
636
|
+
options.merge_owner!(owner)
|
637
|
+
list = get("/1/lists/show.json", options)
|
638
|
+
Twitter::List.new(list)
|
639
|
+
end
|
640
|
+
|
641
|
+
end
|
642
|
+
end
|
643
|
+
end
|