twitter 4.8.1 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +36 -0
- data/CONTRIBUTING.md +13 -15
- data/LICENSE.md +1 -1
- data/README.md +401 -261
- data/Rakefile +6 -0
- data/lib/twitter/arguments.rb +14 -0
- data/lib/twitter/base.rb +109 -89
- data/lib/twitter/client.rb +38 -115
- data/lib/twitter/configuration.rb +5 -2
- data/lib/twitter/core_ext/kernel.rb +5 -1
- data/lib/twitter/creatable.rb +7 -4
- data/lib/twitter/cursor.rb +57 -45
- data/lib/twitter/direct_message.rb +2 -11
- data/lib/twitter/entity/uri.rb +14 -0
- data/lib/twitter/enumerable.rb +15 -0
- data/lib/twitter/error/already_favorited.rb +1 -1
- data/lib/twitter/error/already_posted.rb +10 -0
- data/lib/twitter/error/already_retweeted.rb +1 -1
- data/lib/twitter/error/bad_gateway.rb +2 -3
- data/lib/twitter/error/bad_request.rb +2 -2
- data/lib/twitter/error/forbidden.rb +2 -2
- data/lib/twitter/error/gateway_timeout.rb +2 -3
- data/lib/twitter/error/internal_server_error.rb +2 -3
- data/lib/twitter/error/not_acceptable.rb +2 -2
- data/lib/twitter/error/not_found.rb +2 -2
- data/lib/twitter/error/service_unavailable.rb +2 -3
- data/lib/twitter/error/too_many_requests.rb +2 -2
- data/lib/twitter/error/unauthorized.rb +2 -2
- data/lib/twitter/error/unprocessable_entity.rb +2 -2
- data/lib/twitter/error.rb +65 -14
- data/lib/twitter/factory.rb +13 -12
- data/lib/twitter/geo.rb +2 -7
- data/lib/twitter/geo_factory.rb +11 -7
- data/lib/twitter/geo_results.rb +40 -0
- data/lib/twitter/identity.rb +4 -34
- data/lib/twitter/list.rb +21 -4
- data/lib/twitter/media/photo.rb +6 -4
- data/lib/twitter/media_factory.rb +11 -7
- data/lib/twitter/null_object.rb +25 -0
- data/lib/twitter/oembed.rb +3 -2
- data/lib/twitter/place.rb +15 -15
- data/lib/twitter/profile_banner.rb +3 -2
- data/lib/twitter/rate_limit.rb +4 -17
- data/lib/twitter/relationship.rb +2 -19
- data/lib/twitter/rest/api/direct_messages.rb +138 -0
- data/lib/twitter/rest/api/favorites.rb +115 -0
- data/lib/twitter/rest/api/friends_and_followers.rb +287 -0
- data/lib/twitter/rest/api/help.rb +58 -0
- data/lib/twitter/rest/api/lists.rb +498 -0
- data/lib/twitter/rest/api/oauth.rb +62 -0
- data/lib/twitter/rest/api/places_and_geo.rb +86 -0
- data/lib/twitter/rest/api/saved_searches.rb +93 -0
- data/lib/twitter/rest/api/search.rb +37 -0
- data/lib/twitter/rest/api/spam_reporting.rb +29 -0
- data/lib/twitter/rest/api/suggested_users.rb +51 -0
- data/lib/twitter/rest/api/timelines.rb +202 -0
- data/lib/twitter/rest/api/trends.rb +58 -0
- data/lib/twitter/rest/api/tweets.rb +291 -0
- data/lib/twitter/rest/api/undocumented.rb +52 -0
- data/lib/twitter/rest/api/users.rb +383 -0
- data/lib/twitter/rest/api/utils.rb +246 -0
- data/lib/twitter/rest/client.rb +175 -0
- data/lib/twitter/rest/request/multipart_with_file.rb +36 -0
- data/lib/twitter/rest/response/parse_error_json.rb +15 -0
- data/lib/twitter/rest/response/parse_json.rb +31 -0
- data/lib/twitter/{response → rest/response}/raise_error.rb +8 -11
- data/lib/twitter/search_results.rb +37 -21
- data/lib/twitter/settings.rb +1 -6
- data/lib/twitter/size.rb +2 -15
- data/lib/twitter/streaming/client.rb +89 -0
- data/lib/twitter/streaming/connection.rb +22 -0
- data/lib/twitter/streaming/event.rb +35 -0
- data/lib/twitter/streaming/friend_list.rb +13 -0
- data/lib/twitter/streaming/message_parser.rb +18 -0
- data/lib/twitter/streaming/response.rb +34 -0
- data/lib/twitter/suggestion.rb +5 -8
- data/lib/twitter/token.rb +11 -1
- data/lib/twitter/trend.rb +4 -8
- data/lib/twitter/trend_results.rb +65 -0
- data/lib/twitter/tweet.rb +43 -92
- data/lib/twitter/user.rb +72 -47
- data/lib/twitter/version.rb +4 -4
- data/lib/twitter.rb +4 -39
- data/spec/fixtures/already_posted.json +1 -0
- data/spec/fixtures/ids_list.json +1 -1
- data/spec/fixtures/ids_list2.json +1 -1
- data/spec/fixtures/request_token.txt +6 -0
- data/spec/fixtures/search.json +1 -1
- data/spec/fixtures/search_malformed.json +1 -1
- data/spec/fixtures/track_streaming.json +3 -0
- data/spec/fixtures/track_streaming_user.json +5 -0
- data/spec/helper.rb +8 -13
- data/spec/twitter/base_spec.rb +13 -103
- data/spec/twitter/basic_user_spec.rb +3 -3
- data/spec/twitter/configuration_spec.rb +1 -1
- data/spec/twitter/cursor_spec.rb +17 -35
- data/spec/twitter/direct_message_spec.rb +44 -11
- data/spec/twitter/entity/uri_spec.rb +75 -0
- data/spec/twitter/error_spec.rb +59 -11
- data/spec/twitter/geo/point_spec.rb +6 -6
- data/spec/twitter/geo/polygon_spec.rb +5 -5
- data/spec/twitter/geo_factory_spec.rb +4 -4
- data/spec/twitter/geo_results_spec.rb +35 -0
- data/spec/twitter/geo_spec.rb +6 -6
- data/spec/twitter/identifiable_spec.rb +5 -26
- data/spec/twitter/list_spec.rb +54 -11
- data/spec/twitter/media/photo_spec.rb +122 -6
- data/spec/twitter/media_factory_spec.rb +3 -3
- data/spec/twitter/null_object_spec.rb +27 -0
- data/spec/twitter/oembed_spec.rb +69 -45
- data/spec/twitter/place_spec.rb +84 -28
- data/spec/twitter/profile_banner_spec.rb +1 -1
- data/spec/twitter/rate_limit_spec.rb +8 -25
- data/spec/twitter/relationship_spec.rb +26 -12
- data/spec/twitter/{api → rest/api}/direct_messages_spec.rb +28 -15
- data/spec/twitter/{api → rest/api}/favorites_spec.rb +80 -7
- data/spec/twitter/{api → rest/api}/friends_and_followers_spec.rb +121 -152
- data/spec/twitter/{api → rest/api}/geo_spec.rb +9 -23
- data/spec/twitter/{api → rest/api}/help_spec.rb +6 -6
- data/spec/twitter/{api → rest/api}/lists_spec.rb +116 -95
- data/spec/twitter/{api → rest/api}/oauth_spec.rb +21 -10
- data/spec/twitter/{api → rest/api}/saved_searches_spec.rb +13 -13
- data/spec/twitter/{api → rest/api}/search_spec.rb +8 -9
- data/spec/twitter/{api → rest/api}/spam_reporting_spec.rb +3 -3
- data/spec/twitter/{api → rest/api}/suggested_users_spec.rb +5 -5
- data/spec/twitter/{api → rest/api}/timelines_spec.rb +9 -9
- data/spec/twitter/{api → rest/api}/trends_spec.rb +6 -6
- data/spec/twitter/rest/api/tweets_spec.rb +503 -0
- data/spec/twitter/{api → rest/api}/undocumented_spec.rb +19 -45
- data/spec/twitter/{api → rest/api}/users_spec.rb +64 -39
- data/spec/twitter/rest/client_spec.rb +193 -0
- data/spec/twitter/saved_search_spec.rb +14 -3
- data/spec/twitter/search_results_spec.rb +32 -45
- data/spec/twitter/settings_spec.rb +17 -6
- data/spec/twitter/size_spec.rb +5 -15
- data/spec/twitter/source_user_spec.rb +3 -3
- data/spec/twitter/streaming/client_spec.rb +92 -0
- data/spec/twitter/streaming/event_spec.rb +45 -0
- data/spec/twitter/suggestion_spec.rb +5 -15
- data/spec/twitter/target_user_spec.rb +3 -3
- data/spec/twitter/token_spec.rb +16 -0
- data/spec/twitter/trend_results_spec.rb +89 -0
- data/spec/twitter/trend_spec.rb +26 -13
- data/spec/twitter/tweet_spec.rb +137 -124
- data/spec/twitter/user_spec.rb +139 -80
- data/spec/twitter_spec.rb +0 -119
- data/twitter.gemspec +12 -6
- data.tar.gz.sig +0 -0
- metadata +197 -138
- metadata.gz.sig +0 -0
- data/lib/twitter/action/favorite.rb +0 -19
- data/lib/twitter/action/follow.rb +0 -30
- data/lib/twitter/action/list_member_added.rb +0 -39
- data/lib/twitter/action/mention.rb +0 -46
- data/lib/twitter/action/reply.rb +0 -27
- data/lib/twitter/action/retweet.rb +0 -27
- data/lib/twitter/action/tweet.rb +0 -20
- data/lib/twitter/action_factory.rb +0 -22
- data/lib/twitter/api/arguments.rb +0 -13
- data/lib/twitter/api/direct_messages.rb +0 -148
- data/lib/twitter/api/favorites.rb +0 -126
- data/lib/twitter/api/friends_and_followers.rb +0 -334
- data/lib/twitter/api/help.rb +0 -64
- data/lib/twitter/api/lists.rb +0 -618
- data/lib/twitter/api/oauth.rb +0 -44
- data/lib/twitter/api/places_and_geo.rb +0 -121
- data/lib/twitter/api/saved_searches.rb +0 -99
- data/lib/twitter/api/search.rb +0 -37
- data/lib/twitter/api/spam_reporting.rb +0 -30
- data/lib/twitter/api/suggested_users.rb +0 -55
- data/lib/twitter/api/timelines.rb +0 -214
- data/lib/twitter/api/trends.rb +0 -63
- data/lib/twitter/api/tweets.rb +0 -304
- data/lib/twitter/api/undocumented.rb +0 -97
- data/lib/twitter/api/users.rb +0 -439
- data/lib/twitter/api/utils.rb +0 -187
- data/lib/twitter/configurable.rb +0 -96
- data/lib/twitter/default.rb +0 -102
- data/lib/twitter/entity/url.rb +0 -9
- data/lib/twitter/error/client_error.rb +0 -35
- data/lib/twitter/error/decode_error.rb +0 -9
- data/lib/twitter/error/identity_map_key_error.rb +0 -9
- data/lib/twitter/error/server_error.rb +0 -28
- data/lib/twitter/exceptable.rb +0 -36
- data/lib/twitter/identity_map.rb +0 -22
- data/lib/twitter/request/multipart_with_file.rb +0 -34
- data/lib/twitter/response/parse_json.rb +0 -25
- data/spec/fixtures/about_me.json +0 -1
- data/spec/fixtures/activity_summary.json +0 -1
- data/spec/fixtures/bad_gateway.json +0 -1
- data/spec/fixtures/bad_request.json +0 -1
- data/spec/fixtures/by_friends.json +0 -1
- data/spec/fixtures/end_session.json +0 -1
- data/spec/fixtures/forbidden.json +0 -1
- data/spec/fixtures/internal_server_error.json +0 -1
- data/spec/fixtures/not_acceptable.json +0 -1
- data/spec/fixtures/phoenix_search.phoenix +0 -1
- data/spec/fixtures/resolve.json +0 -1
- data/spec/fixtures/service_unavailable.json +0 -1
- data/spec/fixtures/totals.json +0 -1
- data/spec/fixtures/trends.json +0 -1
- data/spec/fixtures/unauthorized.json +0 -1
- data/spec/fixtures/video_facets.json +0 -1
- data/spec/twitter/action/favorite_spec.rb +0 -29
- data/spec/twitter/action/follow_spec.rb +0 -29
- data/spec/twitter/action/list_member_added_spec.rb +0 -41
- data/spec/twitter/action/mention_spec.rb +0 -52
- data/spec/twitter/action/reply_spec.rb +0 -41
- data/spec/twitter/action/retweet_spec.rb +0 -41
- data/spec/twitter/action_factory_spec.rb +0 -35
- data/spec/twitter/action_spec.rb +0 -16
- data/spec/twitter/api/tweets_spec.rb +0 -285
- data/spec/twitter/client_spec.rb +0 -223
- data/spec/twitter/error/client_error_spec.rb +0 -23
- data/spec/twitter/error/server_error_spec.rb +0 -20
data/lib/twitter/api/lists.rb
DELETED
|
@@ -1,618 +0,0 @@
|
|
|
1
|
-
require 'twitter/api/arguments'
|
|
2
|
-
require 'twitter/api/utils'
|
|
3
|
-
require 'twitter/core_ext/enumerable'
|
|
4
|
-
require 'twitter/cursor'
|
|
5
|
-
require 'twitter/error/forbidden'
|
|
6
|
-
require 'twitter/error/not_found'
|
|
7
|
-
require 'twitter/list'
|
|
8
|
-
require 'twitter/tweet'
|
|
9
|
-
require 'twitter/user'
|
|
10
|
-
|
|
11
|
-
module Twitter
|
|
12
|
-
module API
|
|
13
|
-
module Lists
|
|
14
|
-
include Twitter::API::Utils
|
|
15
|
-
MAX_USERS_PER_REQUEST = 100
|
|
16
|
-
|
|
17
|
-
# Returns all lists the authenticating or specified user subscribes to, including their own
|
|
18
|
-
#
|
|
19
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/list
|
|
20
|
-
# @rate_limited Yes
|
|
21
|
-
# @authentication Requires user context
|
|
22
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
23
|
-
# @return [Array<Twitter::List>]
|
|
24
|
-
# @overload lists(options={})
|
|
25
|
-
# @param options [Hash] A customizable set of options.
|
|
26
|
-
# @option options [Boolean] :reverse Set this to true if you would like owned lists to be returned first.
|
|
27
|
-
# @example Return all lists the authenticating user subscribes to
|
|
28
|
-
# Twitter.lists
|
|
29
|
-
# @overload lists(user, options={})
|
|
30
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
31
|
-
# @param options [Hash] A customizable set of options.
|
|
32
|
-
# @option options [Boolean] :reverse Set this to true if you would like owned lists to be returned first.
|
|
33
|
-
# @example Return all lists that @sferik subscribes to
|
|
34
|
-
# Twitter.lists('sferik')
|
|
35
|
-
# Twitter.lists(7505382)
|
|
36
|
-
def lists(*args)
|
|
37
|
-
objects_from_response_with_user(Twitter::List, :get, "/1.1/lists/list.json", args)
|
|
38
|
-
end
|
|
39
|
-
alias lists_subscribed_to lists
|
|
40
|
-
|
|
41
|
-
# Show tweet timeline for members of the specified list
|
|
42
|
-
#
|
|
43
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/statuses
|
|
44
|
-
# @rate_limited Yes
|
|
45
|
-
# @authentication Requires user context
|
|
46
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
47
|
-
# @return [Array<Twitter::Tweet>]
|
|
48
|
-
# @overload list_timeline(list, options={})
|
|
49
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
50
|
-
# @param options [Hash] A customizable set of options.
|
|
51
|
-
# @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID.
|
|
52
|
-
# @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
|
|
53
|
-
# @option options [Integer] :count The number of results to retrieve.
|
|
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, Twitter::User] A Twitter user ID, screen name, or object.
|
|
59
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
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] :count The number of results to retrieve.
|
|
64
|
-
# @example Show tweet timeline for members of @sferik's "presidents" list
|
|
65
|
-
# Twitter.list_timeline('sferik', 'presidents')
|
|
66
|
-
# Twitter.list_timeline('sferik', 8863586)
|
|
67
|
-
# Twitter.list_timeline(7505382, 'presidents')
|
|
68
|
-
# Twitter.list_timeline(7505382, 8863586)
|
|
69
|
-
def list_timeline(*args)
|
|
70
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
71
|
-
merge_list!(arguments.options, arguments.pop)
|
|
72
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
73
|
-
objects_from_response(Twitter::Tweet, :get, "/1.1/lists/statuses.json", arguments.options)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
# Removes the specified member from the list
|
|
77
|
-
#
|
|
78
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy
|
|
79
|
-
# @rate_limited No
|
|
80
|
-
# @authentication Requires user context
|
|
81
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
82
|
-
# @return [Twitter::List] The list.
|
|
83
|
-
# @overload list_remove_member(list, user_to_remove, options={})
|
|
84
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
85
|
-
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
|
|
86
|
-
# @param options [Hash] A customizable set of options.
|
|
87
|
-
# @example Remove @BarackObama from the authenticated user's "presidents" list
|
|
88
|
-
# Twitter.list_remove_member('presidents', 813286)
|
|
89
|
-
# Twitter.list_remove_member('presidents', 'BarackObama')
|
|
90
|
-
# Twitter.list_remove_member(8863586, 'BarackObama')
|
|
91
|
-
# @overload list_remove_member(user, list, user_to_remove, options={})
|
|
92
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
93
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
94
|
-
# @param user_to_remove [Integer, String] The user id or screen name of the list member to remove.
|
|
95
|
-
# @param options [Hash] A customizable set of options.
|
|
96
|
-
# @example Remove @BarackObama from @sferik's "presidents" list
|
|
97
|
-
# Twitter.list_remove_member('sferik', 'presidents', 813286)
|
|
98
|
-
# Twitter.list_remove_member('sferik', 'presidents', 'BarackObama')
|
|
99
|
-
# Twitter.list_remove_member('sferik', 8863586, 'BarackObama')
|
|
100
|
-
# Twitter.list_remove_member(7505382, 'presidents', 813286)
|
|
101
|
-
def list_remove_member(*args)
|
|
102
|
-
list_from_response_with_user(:post, "/1.1/lists/members/destroy.json", args)
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# List the lists the specified user has been added to
|
|
106
|
-
#
|
|
107
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/memberships
|
|
108
|
-
# @rate_limited Yes
|
|
109
|
-
# @authentication Requires user context
|
|
110
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
111
|
-
# @return [Twitter::Cursor]
|
|
112
|
-
# @overload memberships(options={})
|
|
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
|
-
# @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
|
|
116
|
-
# @example List the lists the authenticated user has been added to
|
|
117
|
-
# Twitter.memberships
|
|
118
|
-
# @overload memberships(user, options={})
|
|
119
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
120
|
-
# @param options [Hash] A customizable set of options.
|
|
121
|
-
# @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.
|
|
122
|
-
# @option options [Boolean, String, Integer] :filter_to_owned_lists When set to true, t or 1, will return just lists the authenticating user owns, and the user represented by user_id or screen_name is a member of.
|
|
123
|
-
# @example List the lists that @sferik has been added to
|
|
124
|
-
# Twitter.memberships('sferik')
|
|
125
|
-
# Twitter.memberships(7505382)
|
|
126
|
-
def memberships(*args)
|
|
127
|
-
cursor_from_response_with_user(:lists, Twitter::List, :get, "/1.1/lists/memberships.json", args, :memberships)
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
# Returns the subscribers of the specified list
|
|
131
|
-
#
|
|
132
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers
|
|
133
|
-
# @rate_limited Yes
|
|
134
|
-
# @authentication Requires user context
|
|
135
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
136
|
-
# @return [Twitter::Cursor] The subscribers of the specified list.
|
|
137
|
-
# @overload list_subscribers(list, options={})
|
|
138
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
139
|
-
# @param options [Hash] A customizable set of options.
|
|
140
|
-
# @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.
|
|
141
|
-
# @example Return the subscribers of the authenticated user's "presidents" list
|
|
142
|
-
# Twitter.list_subscribers('presidents')
|
|
143
|
-
# Twitter.list_subscribers(8863586)
|
|
144
|
-
# @overload list_subscribers(user, list, options={})
|
|
145
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
146
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
147
|
-
# @param options [Hash] A customizable set of options.
|
|
148
|
-
# @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.
|
|
149
|
-
# @example Return the subscribers of @sferik's "presidents" list
|
|
150
|
-
# Twitter.list_subscribers('sferik', 'presidents')
|
|
151
|
-
# Twitter.list_subscribers('sferik', 8863586)
|
|
152
|
-
# Twitter.list_subscribers(7505382, 'presidents')
|
|
153
|
-
def list_subscribers(*args)
|
|
154
|
-
cursor_from_response_with_list(:get, "/1.1/lists/subscribers.json", args, :list_subscribers)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
# Make the authenticated user follow the specified list
|
|
158
|
-
#
|
|
159
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/create
|
|
160
|
-
# @rate_limited No
|
|
161
|
-
# @authentication Requires user context
|
|
162
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
163
|
-
# @return [Twitter::List] The specified list.
|
|
164
|
-
# @overload list_subscribe(list, options={})
|
|
165
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
166
|
-
# @param options [Hash] A customizable set of options.
|
|
167
|
-
# @example Subscribe to the authenticated user's "presidents" list
|
|
168
|
-
# Twitter.list_subscribe('presidents')
|
|
169
|
-
# Twitter.list_subscribe(8863586)
|
|
170
|
-
# @overload list_subscribe(user, list, options={})
|
|
171
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
172
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
173
|
-
# @param options [Hash] A customizable set of options.
|
|
174
|
-
# @example Subscribe to @sferik's "presidents" list
|
|
175
|
-
# Twitter.list_subscribe('sferik', 'presidents')
|
|
176
|
-
# Twitter.list_subscribe('sferik', 8863586)
|
|
177
|
-
# Twitter.list_subscribe(7505382, 'presidents')
|
|
178
|
-
def list_subscribe(*args)
|
|
179
|
-
list_from_response(:post, "/1.1/lists/subscribers/create.json", args)
|
|
180
|
-
end
|
|
181
|
-
|
|
182
|
-
# Check if a user is a subscriber of the specified list
|
|
183
|
-
#
|
|
184
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/subscribers/show
|
|
185
|
-
# @rate_limited Yes
|
|
186
|
-
# @authentication Requires user context
|
|
187
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
188
|
-
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
|
189
|
-
# @overload list_subscriber?(list, user_to_check, options={})
|
|
190
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
191
|
-
# @param user_to_check [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
192
|
-
# @param options [Hash] A customizable set of options.
|
|
193
|
-
# @example Check if @BarackObama is a subscriber of the authenticated user's "presidents" list
|
|
194
|
-
# Twitter.list_subscriber?('presidents', 813286)
|
|
195
|
-
# Twitter.list_subscriber?(8863586, 813286)
|
|
196
|
-
# Twitter.list_subscriber?('presidents', 'BarackObama')
|
|
197
|
-
# @overload list_subscriber?(user, list, user_to_check, options={})
|
|
198
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
199
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
200
|
-
# @param user_to_check [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
201
|
-
# @param options [Hash] A customizable set of options.
|
|
202
|
-
# @example Check if @BarackObama is a subscriber of @sferik's "presidents" list
|
|
203
|
-
# Twitter.list_subscriber?('sferik', 'presidents', 813286)
|
|
204
|
-
# Twitter.list_subscriber?('sferik', 8863586, 813286)
|
|
205
|
-
# Twitter.list_subscriber?(7505382, 'presidents', 813286)
|
|
206
|
-
# Twitter.list_subscriber?('sferik', 'presidents', 'BarackObama')
|
|
207
|
-
# @return [Boolean] true if user is a subscriber of the specified list, otherwise false.
|
|
208
|
-
def list_subscriber?(*args)
|
|
209
|
-
list_user?(:get, "/1.1/lists/subscribers/show.json", args)
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# Unsubscribes the authenticated user form the specified list
|
|
213
|
-
#
|
|
214
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/subscribers/destroy
|
|
215
|
-
# @rate_limited No
|
|
216
|
-
# @authentication Requires user context
|
|
217
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
218
|
-
# @return [Twitter::List] The specified list.
|
|
219
|
-
# @overload list_unsubscribe(list, options={})
|
|
220
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
221
|
-
# @param options [Hash] A customizable set of options.
|
|
222
|
-
# @example Unsubscribe from the authenticated user's "presidents" list
|
|
223
|
-
# Twitter.list_unsubscribe('presidents')
|
|
224
|
-
# Twitter.list_unsubscribe(8863586)
|
|
225
|
-
# @overload list_unsubscribe(user, list, options={})
|
|
226
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
227
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
228
|
-
# @param options [Hash] A customizable set of options.
|
|
229
|
-
# @example Unsubscribe from @sferik's "presidents" list
|
|
230
|
-
# Twitter.list_unsubscribe('sferik', 'presidents')
|
|
231
|
-
# Twitter.list_unsubscribe('sferik', 8863586)
|
|
232
|
-
# Twitter.list_unsubscribe(7505382, 'presidents')
|
|
233
|
-
def list_unsubscribe(*args)
|
|
234
|
-
list_from_response(:post, "/1.1/lists/subscribers/destroy.json", args)
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
# Adds specified members to a list
|
|
238
|
-
#
|
|
239
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/create_all
|
|
240
|
-
# @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.
|
|
241
|
-
# @rate_limited No
|
|
242
|
-
# @authentication Requires user context
|
|
243
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
244
|
-
# @return [Twitter::List] The list.
|
|
245
|
-
# @overload list_add_members(list, users, options={})
|
|
246
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
247
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
|
|
248
|
-
# @param options [Hash] A customizable set of options.
|
|
249
|
-
# @example Add @BarackObama and @pengwynn to the authenticated user's "presidents" list
|
|
250
|
-
# Twitter.list_add_members('presidents', ['BarackObama', 'pengwynn'])
|
|
251
|
-
# Twitter.list_add_members('presidents', [813286, 18755393])
|
|
252
|
-
# Twitter.list_add_members(8863586, ['BarackObama', 'pengwynn'])
|
|
253
|
-
# Twitter.list_add_members(8863586, [813286, 18755393])
|
|
254
|
-
# @overload list_add_members(user, list, users, options={})
|
|
255
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
256
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
257
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
|
|
258
|
-
# @param options [Hash] A customizable set of options.
|
|
259
|
-
# @example Add @BarackObama and @pengwynn to @sferik's "presidents" list
|
|
260
|
-
# Twitter.list_add_members('sferik', 'presidents', ['BarackObama', 'pengwynn'])
|
|
261
|
-
# Twitter.list_add_members('sferik', 'presidents', [813286, 18755393])
|
|
262
|
-
# Twitter.list_add_members(7505382, 'presidents', ['BarackObama', 'pengwynn'])
|
|
263
|
-
# Twitter.list_add_members(7505382, 'presidents', [813286, 18755393])
|
|
264
|
-
# Twitter.list_add_members(7505382, 8863586, ['BarackObama', 'pengwynn'])
|
|
265
|
-
# Twitter.list_add_members(7505382, 8863586, [813286, 18755393])
|
|
266
|
-
def list_add_members(*args)
|
|
267
|
-
list_from_response_with_users(:post, "/1.1/lists/members/create_all.json", args)
|
|
268
|
-
end
|
|
269
|
-
|
|
270
|
-
# Check if a user is a member of the specified list
|
|
271
|
-
#
|
|
272
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/members/show
|
|
273
|
-
# @authentication Requires user context
|
|
274
|
-
# @rate_limited Yes
|
|
275
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
276
|
-
# @return [Boolean] true if user is a member of the specified list, otherwise false.
|
|
277
|
-
# @overload list_member?(list, user_to_check, options={})
|
|
278
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
279
|
-
# @param user_to_check [Integer, String] The user ID or screen name of the list member.
|
|
280
|
-
# @param options [Hash] A customizable set of options.
|
|
281
|
-
# @example Check if @BarackObama is a member of the authenticated user's "presidents" list
|
|
282
|
-
# Twitter.list_member?('presidents', 813286)
|
|
283
|
-
# Twitter.list_member?(8863586, 'BarackObama')
|
|
284
|
-
# @overload list_member?(user, list, user_to_check, options={})
|
|
285
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
286
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
287
|
-
# @param user_to_check [Integer, String] The user ID or screen name of the list member.
|
|
288
|
-
# @param options [Hash] A customizable set of options.
|
|
289
|
-
# @example Check if @BarackObama is a member of @sferik's "presidents" list
|
|
290
|
-
# Twitter.list_member?('sferik', 'presidents', 813286)
|
|
291
|
-
# Twitter.list_member?('sferik', 8863586, 'BarackObama')
|
|
292
|
-
# Twitter.list_member?(7505382, 'presidents', 813286)
|
|
293
|
-
def list_member?(*args)
|
|
294
|
-
list_user?(:get, "/1.1/lists/members/show.json", args)
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
# Returns the members of the specified list
|
|
298
|
-
#
|
|
299
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/members
|
|
300
|
-
# @rate_limited Yes
|
|
301
|
-
# @authentication Requires user context
|
|
302
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
303
|
-
# @return [Twitter::Cursor]
|
|
304
|
-
# @overload list_members(list, options={})
|
|
305
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
306
|
-
# @param options [Hash] A customizable set of options.
|
|
307
|
-
# @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.
|
|
308
|
-
# @example Return the members of the authenticated user's "presidents" list
|
|
309
|
-
# Twitter.list_members('presidents')
|
|
310
|
-
# Twitter.list_members(8863586)
|
|
311
|
-
# @overload list_members(user, list, options={})
|
|
312
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
313
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
314
|
-
# @param options [Hash] A customizable set of options.
|
|
315
|
-
# @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.
|
|
316
|
-
# @example Return the members of @sferik's "presidents" list
|
|
317
|
-
# Twitter.list_members('sferik', 'presidents')
|
|
318
|
-
# Twitter.list_members('sferik', 8863586)
|
|
319
|
-
# Twitter.list_members(7505382, 'presidents')
|
|
320
|
-
# Twitter.list_members(7505382, 8863586)
|
|
321
|
-
def list_members(*args)
|
|
322
|
-
cursor_from_response_with_list(:get, "/1.1/lists/members.json", args, :list_members)
|
|
323
|
-
end
|
|
324
|
-
|
|
325
|
-
# Add a member to a list
|
|
326
|
-
#
|
|
327
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/create
|
|
328
|
-
# @note Lists are limited to having 500 members.
|
|
329
|
-
# @rate_limited No
|
|
330
|
-
# @authentication Requires user context
|
|
331
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
332
|
-
# @return [Twitter::List] The list.
|
|
333
|
-
# @overload list_add_member(list, user_to_add, options={})
|
|
334
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
335
|
-
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
|
|
336
|
-
# @param options [Hash] A customizable set of options.
|
|
337
|
-
# @example Add @BarackObama to the authenticated user's "presidents" list
|
|
338
|
-
# Twitter.list_add_member('presidents', 813286)
|
|
339
|
-
# Twitter.list_add_member(8863586, 813286)
|
|
340
|
-
# @overload list_add_member(user, list, user_to_add, options={})
|
|
341
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
342
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
343
|
-
# @param user_to_add [Integer, String] The user id or screen name to add to the list.
|
|
344
|
-
# @param options [Hash] A customizable set of options.
|
|
345
|
-
# @example Add @BarackObama to @sferik's "presidents" list
|
|
346
|
-
# Twitter.list_add_member('sferik', 'presidents', 813286)
|
|
347
|
-
# Twitter.list_add_member('sferik', 8863586, 813286)
|
|
348
|
-
# Twitter.list_add_member(7505382, 'presidents', 813286)
|
|
349
|
-
# Twitter.list_add_member(7505382, 8863586, 813286)
|
|
350
|
-
def list_add_member(*args)
|
|
351
|
-
list_from_response_with_user(:post, "/1.1/lists/members/create.json", args)
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
# Deletes the specified list
|
|
355
|
-
#
|
|
356
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/destroy
|
|
357
|
-
# @note Must be owned by the authenticated user.
|
|
358
|
-
# @rate_limited No
|
|
359
|
-
# @authentication Requires user context
|
|
360
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
361
|
-
# @return [Twitter::List] The deleted list.
|
|
362
|
-
# @overload list_destroy(list, options={})
|
|
363
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
364
|
-
# @param options [Hash] A customizable set of options.
|
|
365
|
-
# @example Delete the authenticated user's "presidents" list
|
|
366
|
-
# Twitter.list_destroy('presidents')
|
|
367
|
-
# Twitter.list_destroy(8863586)
|
|
368
|
-
# @overload list_destroy(user, list, options={})
|
|
369
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
370
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
371
|
-
# @param options [Hash] A customizable set of options.
|
|
372
|
-
# @example Delete @sferik's "presidents" list
|
|
373
|
-
# Twitter.list_destroy('sferik', 'presidents')
|
|
374
|
-
# Twitter.list_destroy('sferik', 8863586)
|
|
375
|
-
# Twitter.list_destroy(7505382, 'presidents')
|
|
376
|
-
# Twitter.list_destroy(7505382, 8863586)
|
|
377
|
-
def list_destroy(*args)
|
|
378
|
-
list_from_response(:post, "/1.1/lists/destroy.json", args)
|
|
379
|
-
end
|
|
380
|
-
|
|
381
|
-
# Updates the specified list
|
|
382
|
-
#
|
|
383
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/update
|
|
384
|
-
# @rate_limited No
|
|
385
|
-
# @authentication Requires user context
|
|
386
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
387
|
-
# @return [Twitter::List] The created list.
|
|
388
|
-
# @overload list_update(list, options={})
|
|
389
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
390
|
-
# @param options [Hash] A customizable set of options.
|
|
391
|
-
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
|
392
|
-
# @option options [String] :description The description to give the list.
|
|
393
|
-
# @example Update the authenticated user's "presidents" list to have the description "Presidents of the United States of America"
|
|
394
|
-
# Twitter.list_update('presidents', :description => "Presidents of the United States of America")
|
|
395
|
-
# Twitter.list_update(8863586, :description => "Presidents of the United States of America")
|
|
396
|
-
# @overload list_update(user, list, options={})
|
|
397
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
398
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
399
|
-
# @param options [Hash] A customizable set of options.
|
|
400
|
-
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
|
401
|
-
# @option options [String] :description The description to give the list.
|
|
402
|
-
# @example Update the @sferik's "presidents" list to have the description "Presidents of the United States of America"
|
|
403
|
-
# Twitter.list_update('sferik', 'presidents', :description => "Presidents of the United States of America")
|
|
404
|
-
# Twitter.list_update(7505382, 'presidents', :description => "Presidents of the United States of America")
|
|
405
|
-
# Twitter.list_update('sferik', 8863586, :description => "Presidents of the United States of America")
|
|
406
|
-
# Twitter.list_update(7505382, 8863586, :description => "Presidents of the United States of America")
|
|
407
|
-
def list_update(*args)
|
|
408
|
-
list_from_response(:post, "/1.1/lists/update.json", args)
|
|
409
|
-
end
|
|
410
|
-
|
|
411
|
-
# Creates a new list for the authenticated user
|
|
412
|
-
#
|
|
413
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/create
|
|
414
|
-
# @note Accounts are limited to 20 lists.
|
|
415
|
-
# @rate_limited No
|
|
416
|
-
# @authentication Requires user context
|
|
417
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
418
|
-
# @return [Twitter::List] The created list.
|
|
419
|
-
# @param name [String] The name for the list.
|
|
420
|
-
# @param options [Hash] A customizable set of options.
|
|
421
|
-
# @option options [String] :mode ('public') Whether your list is public or private. Values can be 'public' or 'private'.
|
|
422
|
-
# @option options [String] :description The description to give the list.
|
|
423
|
-
# @example Create a list named 'presidents'
|
|
424
|
-
# Twitter.list_create('presidents')
|
|
425
|
-
def list_create(name, options={})
|
|
426
|
-
object_from_response(Twitter::List, :post, "/1.1/lists/create.json", options.merge(:name => name))
|
|
427
|
-
end
|
|
428
|
-
|
|
429
|
-
# Show the specified list
|
|
430
|
-
#
|
|
431
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/show
|
|
432
|
-
# @note Private lists will only be shown if the authenticated user owns the specified list.
|
|
433
|
-
# @rate_limited Yes
|
|
434
|
-
# @authentication Requires user context
|
|
435
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
436
|
-
# @return [Twitter::List] The specified list.
|
|
437
|
-
# @overload list(list, options={})
|
|
438
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
439
|
-
# @param options [Hash] A customizable set of options.
|
|
440
|
-
# @example Show the authenticated user's "presidents" list
|
|
441
|
-
# Twitter.list('presidents')
|
|
442
|
-
# Twitter.list(8863586)
|
|
443
|
-
# @overload list(user, list, options={})
|
|
444
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
445
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
446
|
-
# @param options [Hash] A customizable set of options.
|
|
447
|
-
# @example Show @sferik's "presidents" list
|
|
448
|
-
# Twitter.list('sferik', 'presidents')
|
|
449
|
-
# Twitter.list('sferik', 8863586)
|
|
450
|
-
# Twitter.list(7505382, 'presidents')
|
|
451
|
-
# Twitter.list(7505382, 8863586)
|
|
452
|
-
def list(*args)
|
|
453
|
-
list_from_response(:get, "/1.1/lists/show.json", args)
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
# List the lists the specified user follows
|
|
457
|
-
#
|
|
458
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/subscriptions
|
|
459
|
-
# @rate_limited Yes
|
|
460
|
-
# @authentication Requires user context
|
|
461
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
462
|
-
# @return [Twitter::Cursor]
|
|
463
|
-
# @overload subscriptions(options={})
|
|
464
|
-
# @param options [Hash] A customizable set of options.
|
|
465
|
-
# @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.
|
|
466
|
-
# @example List the lists the authenticated user follows
|
|
467
|
-
# Twitter.subscriptions
|
|
468
|
-
# @overload subscriptions(user, options={})
|
|
469
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
470
|
-
# @param options [Hash] A customizable set of options.
|
|
471
|
-
# @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.
|
|
472
|
-
# @example List the lists that @sferik follows
|
|
473
|
-
# Twitter.subscriptions('sferik')
|
|
474
|
-
# Twitter.subscriptions(7505382)
|
|
475
|
-
def subscriptions(*args)
|
|
476
|
-
cursor_from_response_with_user(:lists, Twitter::List, :get, "/1.1/lists/subscriptions.json", args, :subscriptions)
|
|
477
|
-
end
|
|
478
|
-
|
|
479
|
-
# Removes specified members from the list
|
|
480
|
-
#
|
|
481
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/lists/members/destroy_all
|
|
482
|
-
# @rate_limited No
|
|
483
|
-
# @authentication Requires user context
|
|
484
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
485
|
-
# @return [Twitter::List] The list.
|
|
486
|
-
# @overload list_remove_members(list, users, options={})
|
|
487
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
488
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
|
|
489
|
-
# @param options [Hash] A customizable set of options.
|
|
490
|
-
# @example Remove @BarackObama and @pengwynn from the authenticated user's "presidents" list
|
|
491
|
-
# Twitter.list_remove_members('presidents', ['BarackObama', 'pengwynn'])
|
|
492
|
-
# Twitter.list_remove_members('presidents', [813286, 18755393])
|
|
493
|
-
# Twitter.list_remove_members(8863586, ['BarackObama', 'pengwynn'])
|
|
494
|
-
# Twitter.list_remove_members(8863586, [813286, 18755393])
|
|
495
|
-
# @overload list_remove_members(user, list, users, options={})
|
|
496
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
497
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
498
|
-
# @param users [Array<Integer, String, Twitter::User>, Set<Integer, String, Twitter::User>] An array of Twitter user IDs, screen names, or objects.
|
|
499
|
-
# @param options [Hash] A customizable set of options.
|
|
500
|
-
# @example Remove @BarackObama and @pengwynn from @sferik's "presidents" list
|
|
501
|
-
# Twitter.list_remove_members('sferik', 'presidents', ['BarackObama', 'pengwynn'])
|
|
502
|
-
# Twitter.list_remove_members('sferik', 'presidents', [813286, 18755393])
|
|
503
|
-
# Twitter.list_remove_members(7505382, 'presidents', ['BarackObama', 'pengwynn'])
|
|
504
|
-
# Twitter.list_remove_members(7505382, 'presidents', [813286, 18755393])
|
|
505
|
-
# Twitter.list_remove_members(7505382, 8863586, ['BarackObama', 'pengwynn'])
|
|
506
|
-
# Twitter.list_remove_members(7505382, 8863586, [813286, 18755393])
|
|
507
|
-
def list_remove_members(*args)
|
|
508
|
-
list_from_response_with_users(:post, "/1.1/lists/members/destroy_all.json", args)
|
|
509
|
-
end
|
|
510
|
-
|
|
511
|
-
# Returns the lists owned by the specified Twitter user
|
|
512
|
-
#
|
|
513
|
-
# @see https://dev.twitter.com/docs/api/1.1/get/lists/ownerships
|
|
514
|
-
# @rate_limited Yes
|
|
515
|
-
# @authentication Requires user context
|
|
516
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
517
|
-
# @return [Array<Twitter::List>]
|
|
518
|
-
# @overload lists_owned(options={})
|
|
519
|
-
# @param options [Hash] A customizable set of options.
|
|
520
|
-
# @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
|
|
521
|
-
# @example Return all lists the authenticating user owns
|
|
522
|
-
# Twitter.lists_owend
|
|
523
|
-
# @overload lists_owned(user, options={})
|
|
524
|
-
# @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, or object.
|
|
525
|
-
# @param options [Hash] A customizable set of options.
|
|
526
|
-
# @option options [Integer] :count The amount of results to return per page. Defaults to 20. No more than 1000 results will ever be returned in a single page.
|
|
527
|
-
# @example Return all lists that @sferik owns
|
|
528
|
-
# Twitter.lists_owned('sferik')
|
|
529
|
-
# Twitter.lists_owned(7505382)
|
|
530
|
-
def lists_owned(*args)
|
|
531
|
-
cursor_from_response_with_user(:lists, Twitter::List, :get, "/1.1/lists/ownerships.json", args, :lists_owned)
|
|
532
|
-
end
|
|
533
|
-
alias lists_ownerships lists_owned
|
|
534
|
-
|
|
535
|
-
private
|
|
536
|
-
|
|
537
|
-
# @param request_method [Symbol]
|
|
538
|
-
# @param path [String]
|
|
539
|
-
# @param args [Array]
|
|
540
|
-
# @return [Array<Twitter::User>]
|
|
541
|
-
def list_from_response(request_method, path, args)
|
|
542
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
543
|
-
merge_list!(arguments.options, arguments.pop)
|
|
544
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
545
|
-
object_from_response(Twitter::List, request_method, path, arguments.options)
|
|
546
|
-
end
|
|
547
|
-
|
|
548
|
-
def cursor_from_response_with_list(request_method, path, args, calling_method)
|
|
549
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
550
|
-
merge_list!(arguments.options, arguments.pop)
|
|
551
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
552
|
-
cursor_from_response(:users, Twitter::User, request_method, path, arguments.options, calling_method)
|
|
553
|
-
end
|
|
554
|
-
|
|
555
|
-
def list_user?(request_method, path, args)
|
|
556
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
557
|
-
merge_user!(arguments.options, arguments.pop)
|
|
558
|
-
merge_list!(arguments.options, arguments.pop)
|
|
559
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
560
|
-
send(request_method.to_sym, path, arguments.options)
|
|
561
|
-
true
|
|
562
|
-
rescue Twitter::Error::NotFound, Twitter::Error::Forbidden
|
|
563
|
-
false
|
|
564
|
-
end
|
|
565
|
-
|
|
566
|
-
def list_from_response_with_user(request_method, path, args)
|
|
567
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
568
|
-
merge_user!(arguments.options, arguments.pop)
|
|
569
|
-
merge_list!(arguments.options, arguments.pop)
|
|
570
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
571
|
-
object_from_response(Twitter::List, request_method, path, arguments.options)
|
|
572
|
-
end
|
|
573
|
-
|
|
574
|
-
def list_from_response_with_users(request_method, path, args)
|
|
575
|
-
arguments = Twitter::API::Arguments.new(args)
|
|
576
|
-
members = arguments.pop
|
|
577
|
-
merge_list!(arguments.options, arguments.pop)
|
|
578
|
-
merge_owner!(arguments.options, arguments.pop)
|
|
579
|
-
members.flatten.each_slice(MAX_USERS_PER_REQUEST).threaded_map do |users|
|
|
580
|
-
object_from_response(Twitter::List, request_method, path, merge_users(arguments.options, users))
|
|
581
|
-
end.last
|
|
582
|
-
end
|
|
583
|
-
|
|
584
|
-
# Take a list and merge it into the hash with the correct key
|
|
585
|
-
#
|
|
586
|
-
# @param hash [Hash]
|
|
587
|
-
# @param list [Integer, String, Twitter::List] A Twitter list ID, slug, or object.
|
|
588
|
-
# @return [Hash]
|
|
589
|
-
def merge_list!(hash, list)
|
|
590
|
-
case list
|
|
591
|
-
when Integer
|
|
592
|
-
hash[:list_id] = list
|
|
593
|
-
when String
|
|
594
|
-
hash[:slug] = list
|
|
595
|
-
when Twitter::List
|
|
596
|
-
hash[:list_id] = list.id
|
|
597
|
-
merge_owner!(hash, list.user)
|
|
598
|
-
end
|
|
599
|
-
hash
|
|
600
|
-
end
|
|
601
|
-
|
|
602
|
-
# Take an owner and merge it into the hash with the correct key
|
|
603
|
-
#
|
|
604
|
-
# @param hash [Hash]
|
|
605
|
-
# @param user[Integer, String, Twitter::User] A Twitter user ID, screen_name, or object.
|
|
606
|
-
# @return [Hash]
|
|
607
|
-
def merge_owner!(hash, user)
|
|
608
|
-
unless hash[:owner_id] || hash[:owner_screen_name]
|
|
609
|
-
user ||= screen_name
|
|
610
|
-
merge_user!(hash, user, "owner")
|
|
611
|
-
hash[:owner_id] = hash.delete(:owner_user_id) unless hash[:owner_user_id].nil?
|
|
612
|
-
end
|
|
613
|
-
hash
|
|
614
|
-
end
|
|
615
|
-
|
|
616
|
-
end
|
|
617
|
-
end
|
|
618
|
-
end
|
data/lib/twitter/api/oauth.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require 'twitter/api/utils'
|
|
2
|
-
require 'twitter/token'
|
|
3
|
-
|
|
4
|
-
module Twitter
|
|
5
|
-
module API
|
|
6
|
-
module OAuth
|
|
7
|
-
include Twitter::API::Utils
|
|
8
|
-
|
|
9
|
-
# Allows a registered application to obtain an OAuth 2 Bearer Token, which can be used to make API requests
|
|
10
|
-
# on an application's own behalf, without a user context.
|
|
11
|
-
#
|
|
12
|
-
# Only one bearer token may exist outstanding for an application, and repeated requests to this method
|
|
13
|
-
# will yield the same already-existent token until it has been invalidated.
|
|
14
|
-
#
|
|
15
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/oauth2/token
|
|
16
|
-
# @rate_limited No
|
|
17
|
-
# @authentication Required
|
|
18
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
19
|
-
# @return [Twitter::Token] The Bearer Token. token_type should be 'bearer'.
|
|
20
|
-
# @example Generate a Bearer Token
|
|
21
|
-
# client = Twitter::Client.new(:consumer_key => "abc", :consumer_secret => 'def')
|
|
22
|
-
# bearer_token = client.token
|
|
23
|
-
def token
|
|
24
|
-
object_from_response(Twitter::Token, :post, "/oauth2/token", :grant_type => "client_credentials", :bearer_token_request => true)
|
|
25
|
-
end
|
|
26
|
-
alias bearer_token token
|
|
27
|
-
|
|
28
|
-
# Allows a registered application to revoke an issued OAuth 2 Bearer Token by presenting its client credentials.
|
|
29
|
-
#
|
|
30
|
-
# @see https://dev.twitter.com/docs/api/1.1/post/oauth2/invalidate_token
|
|
31
|
-
# @rate_limited No
|
|
32
|
-
# @authentication Required
|
|
33
|
-
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
|
34
|
-
# @param access_token [String, Twitter::Token] The bearer token to revoke.
|
|
35
|
-
# @return [Twitter::Token] The invalidated token. token_type should be nil.
|
|
36
|
-
# @example Revoke a token
|
|
37
|
-
# Twitter.invalidate_token("AAAA%2FAAA%3DAAAAAAAA")
|
|
38
|
-
def invalidate_token(access_token)
|
|
39
|
-
access_token = access_token.access_token if access_token.is_a?(Twitter::Token)
|
|
40
|
-
object_from_response(Twitter::Token, :post, "/oauth2/invalidate_token", :access_token => access_token)
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|