twitter 7.0.0 → 8.0.0.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -4
  3. data/README.md +4 -6
  4. data/lib/twitter/base.rb +11 -11
  5. data/lib/twitter/basic_user.rb +3 -2
  6. data/lib/twitter/client.rb +3 -3
  7. data/lib/twitter/creatable.rb +2 -2
  8. data/lib/twitter/cursor.rb +3 -3
  9. data/lib/twitter/direct_message.rb +4 -5
  10. data/lib/twitter/direct_message_event.rb +3 -3
  11. data/lib/twitter/direct_messages/welcome_message.rb +3 -3
  12. data/lib/twitter/direct_messages/welcome_message_rule.rb +2 -2
  13. data/lib/twitter/direct_messages/welcome_message_rule_wrapper.rb +3 -3
  14. data/lib/twitter/direct_messages/welcome_message_wrapper.rb +3 -3
  15. data/lib/twitter/entities.rb +6 -6
  16. data/lib/twitter/entity/hashtag.rb +1 -1
  17. data/lib/twitter/entity/symbol.rb +1 -1
  18. data/lib/twitter/entity/uri.rb +1 -1
  19. data/lib/twitter/entity/user_mention.rb +1 -1
  20. data/lib/twitter/entity.rb +1 -1
  21. data/lib/twitter/enumerable.rb +1 -3
  22. data/lib/twitter/error.rb +7 -6
  23. data/lib/twitter/factory.rb +1 -1
  24. data/lib/twitter/geo/point.rb +1 -1
  25. data/lib/twitter/geo/polygon.rb +1 -1
  26. data/lib/twitter/geo.rb +2 -2
  27. data/lib/twitter/geo_factory.rb +3 -3
  28. data/lib/twitter/geo_results.rb +2 -2
  29. data/lib/twitter/headers.rb +4 -4
  30. data/lib/twitter/identity.rb +2 -2
  31. data/lib/twitter/language.rb +1 -1
  32. data/lib/twitter/list.rb +3 -2
  33. data/lib/twitter/media/animated_gif.rb +1 -1
  34. data/lib/twitter/media/photo.rb +2 -2
  35. data/lib/twitter/media/video.rb +3 -3
  36. data/lib/twitter/media/video_info.rb +2 -2
  37. data/lib/twitter/media_factory.rb +4 -4
  38. data/lib/twitter/metadata.rb +1 -1
  39. data/lib/twitter/null_object.rb +4 -4
  40. data/lib/twitter/oembed.rb +2 -1
  41. data/lib/twitter/place.rb +3 -3
  42. data/lib/twitter/premium_search_results.rb +5 -5
  43. data/lib/twitter/profile.rb +8 -8
  44. data/lib/twitter/profile_banner.rb +2 -2
  45. data/lib/twitter/rate_limit.rb +4 -4
  46. data/lib/twitter/relationship.rb +2 -1
  47. data/lib/twitter/rest/account_activity.rb +3 -3
  48. data/lib/twitter/rest/api.rb +19 -19
  49. data/lib/twitter/rest/client.rb +4 -4
  50. data/lib/twitter/rest/direct_messages/welcome_messages.rb +13 -13
  51. data/lib/twitter/rest/direct_messages.rb +17 -17
  52. data/lib/twitter/rest/favorites.rb +15 -19
  53. data/lib/twitter/rest/form_encoder.rb +27 -0
  54. data/lib/twitter/rest/friends_and_followers.rb +21 -21
  55. data/lib/twitter/rest/help.rb +6 -18
  56. data/lib/twitter/rest/lists.rb +32 -32
  57. data/lib/twitter/rest/oauth.rb +8 -8
  58. data/lib/twitter/rest/places_and_geo.rb +6 -6
  59. data/lib/twitter/rest/premium_search.rb +3 -3
  60. data/lib/twitter/rest/request.rb +28 -21
  61. data/lib/twitter/rest/saved_searches.rb +6 -6
  62. data/lib/twitter/rest/search.rb +3 -3
  63. data/lib/twitter/rest/spam_reporting.rb +3 -3
  64. data/lib/twitter/rest/suggested_users.rb +5 -5
  65. data/lib/twitter/rest/timelines.rb +7 -7
  66. data/lib/twitter/rest/trends.rb +7 -7
  67. data/lib/twitter/rest/tweets.rb +19 -23
  68. data/lib/twitter/rest/undocumented.rb +7 -7
  69. data/lib/twitter/rest/upload_utils.rb +13 -13
  70. data/lib/twitter/rest/users.rb +32 -32
  71. data/lib/twitter/rest/utils.rb +17 -17
  72. data/lib/twitter/saved_search.rb +2 -2
  73. data/lib/twitter/search_results.rb +6 -6
  74. data/lib/twitter/settings.rb +2 -1
  75. data/lib/twitter/size.rb +2 -2
  76. data/lib/twitter/source_user.rb +1 -1
  77. data/lib/twitter/streaming/client.rb +14 -14
  78. data/lib/twitter/streaming/connection.rb +4 -5
  79. data/lib/twitter/streaming/message_parser.rb +6 -6
  80. data/lib/twitter/streaming/response.rb +11 -10
  81. data/lib/twitter/suggestion.rb +3 -3
  82. data/lib/twitter/target_user.rb +1 -1
  83. data/lib/twitter/trend.rb +3 -2
  84. data/lib/twitter/trend_results.rb +5 -5
  85. data/lib/twitter/tweet.rb +3 -3
  86. data/lib/twitter/user.rb +9 -9
  87. data/lib/twitter/utils.rb +2 -2
  88. data/lib/twitter/variant.rb +2 -1
  89. data/lib/twitter/version.rb +3 -3
  90. data/lib/twitter.rb +36 -36
  91. data/twitter.gemspec +19 -18
  92. metadata +23 -22
  93. data/lib/twitter/configuration.rb +0 -27
@@ -1,11 +1,11 @@
1
- require 'addressable/uri'
2
- require 'cgi'
3
- require 'memoizable'
1
+ require "addressable/uri"
2
+ require "cgi"
3
+ require "memoizable"
4
4
 
5
5
  module Twitter
6
6
  module Profile
7
- PROFILE_IMAGE_SUFFIX_REGEX = /_normal(\.gif|\.jpe?g|\.png)$/i.freeze
8
- PREDICATE_URI_METHOD_REGEX = /_uri\?$/.freeze
7
+ PROFILE_IMAGE_SUFFIX_REGEX = /_normal(\.gif|\.jpe?g|\.png)$/i
8
+ PREDICATE_URI_METHOD_REGEX = /_uri\?$/
9
9
  include Memoizable
10
10
 
11
11
  class << self
@@ -27,7 +27,7 @@ module Twitter
27
27
  # @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
28
28
  # @return [Addressable::URI]
29
29
  def profile_banner_uri(size = :web)
30
- parse_uri(insecure_uri([@attrs[:profile_banner_url], size].join('/'))) unless @attrs[:profile_banner_url].nil?
30
+ parse_uri(insecure_uri([@attrs[:profile_banner_url], size].join("/"))) unless @attrs[:profile_banner_url].nil?
31
31
  end
32
32
  alias profile_banner_url profile_banner_uri
33
33
 
@@ -36,7 +36,7 @@ module Twitter
36
36
  # @param size [String, Symbol] The size of the image. Must be one of: 'mobile', 'mobile_retina', 'web', 'web_retina', 'ipad', or 'ipad_retina'
37
37
  # @return [Addressable::URI]
38
38
  def profile_banner_uri_https(size = :web)
39
- parse_uri([@attrs[:profile_banner_url], size].join('/')) unless @attrs[:profile_banner_url].nil?
39
+ parse_uri([@attrs[:profile_banner_url], size].join("/")) unless @attrs[:profile_banner_url].nil?
40
40
  end
41
41
  alias profile_banner_url_https profile_banner_uri_https
42
42
 
@@ -85,7 +85,7 @@ module Twitter
85
85
  end
86
86
 
87
87
  def insecure_uri(uri)
88
- uri.to_s.sub(/^https/i, 'http')
88
+ uri.to_s.sub(/^https/i, "http")
89
89
  end
90
90
 
91
91
  def profile_image_suffix(size)
@@ -1,5 +1,5 @@
1
- require 'memoizable'
2
- require 'twitter/base'
1
+ require "memoizable"
2
+ require "twitter/base"
3
3
 
4
4
  module Twitter
5
5
  class ProfileBanner < Twitter::Base
@@ -1,4 +1,4 @@
1
- require 'memoizable'
1
+ require "memoizable"
2
2
 
3
3
  module Twitter
4
4
  class RateLimit < Twitter::Base
@@ -6,21 +6,21 @@ module Twitter
6
6
 
7
7
  # @return [Integer]
8
8
  def limit
9
- limit = @attrs['x-rate-limit-limit']
9
+ limit = @attrs["x-rate-limit-limit"]
10
10
  limit&.to_i
11
11
  end
12
12
  memoize :limit
13
13
 
14
14
  # @return [Integer]
15
15
  def remaining
16
- remaining = @attrs['x-rate-limit-remaining']
16
+ remaining = @attrs["x-rate-limit-remaining"]
17
17
  remaining&.to_i
18
18
  end
19
19
  memoize :remaining
20
20
 
21
21
  # @return [Time]
22
22
  def reset_at
23
- reset = @attrs['x-rate-limit-reset']
23
+ reset = @attrs["x-rate-limit-reset"]
24
24
  Time.at(reset.to_i).utc if reset
25
25
  end
26
26
  memoize :reset_at
@@ -1,4 +1,4 @@
1
- require 'twitter/base'
1
+ require "twitter/base"
2
2
 
3
3
  module Twitter
4
4
  class Relationship < Twitter::Base
@@ -10,6 +10,7 @@ module Twitter
10
10
  # @param attrs [Hash]
11
11
  # @return [Twitter::Relationship]
12
12
  def initialize(attrs = {})
13
+ super
13
14
  @attrs = attrs[:relationship]
14
15
  end
15
16
  end
@@ -1,6 +1,6 @@
1
- require 'twitter/rest/request'
2
- require 'twitter/rest/utils'
3
- require 'twitter/utils'
1
+ require "twitter/rest/request"
2
+ require "twitter/rest/utils"
3
+ require "twitter/utils"
4
4
 
5
5
  module Twitter
6
6
  module REST
@@ -1,22 +1,22 @@
1
- require 'twitter/rest/account_activity'
2
- require 'twitter/rest/direct_messages'
3
- require 'twitter/rest/direct_messages/welcome_messages'
4
- require 'twitter/rest/favorites'
5
- require 'twitter/rest/friends_and_followers'
6
- require 'twitter/rest/help'
7
- require 'twitter/rest/lists'
8
- require 'twitter/rest/oauth'
9
- require 'twitter/rest/places_and_geo'
10
- require 'twitter/rest/saved_searches'
11
- require 'twitter/rest/search'
12
- require 'twitter/rest/premium_search'
13
- require 'twitter/rest/spam_reporting'
14
- require 'twitter/rest/suggested_users'
15
- require 'twitter/rest/timelines'
16
- require 'twitter/rest/trends'
17
- require 'twitter/rest/tweets'
18
- require 'twitter/rest/undocumented'
19
- require 'twitter/rest/users'
1
+ require "twitter/rest/account_activity"
2
+ require "twitter/rest/direct_messages"
3
+ require "twitter/rest/direct_messages/welcome_messages"
4
+ require "twitter/rest/favorites"
5
+ require "twitter/rest/friends_and_followers"
6
+ require "twitter/rest/help"
7
+ require "twitter/rest/lists"
8
+ require "twitter/rest/oauth"
9
+ require "twitter/rest/places_and_geo"
10
+ require "twitter/rest/saved_searches"
11
+ require "twitter/rest/search"
12
+ require "twitter/rest/premium_search"
13
+ require "twitter/rest/spam_reporting"
14
+ require "twitter/rest/suggested_users"
15
+ require "twitter/rest/timelines"
16
+ require "twitter/rest/trends"
17
+ require "twitter/rest/tweets"
18
+ require "twitter/rest/undocumented"
19
+ require "twitter/rest/users"
20
20
 
21
21
  module Twitter
22
22
  module REST
@@ -1,7 +1,7 @@
1
- require 'twitter/client'
2
- require 'twitter/rest/api'
3
- require 'twitter/rest/request'
4
- require 'twitter/rest/utils'
1
+ require "twitter/client"
2
+ require "twitter/rest/api"
3
+ require "twitter/rest/request"
4
+ require "twitter/rest/utils"
5
5
 
6
6
  module Twitter
7
7
  module REST
@@ -1,7 +1,7 @@
1
- require 'twitter/arguments'
2
- require 'twitter/rest/upload_utils'
3
- require 'twitter/rest/utils'
4
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/rest/upload_utils"
3
+ require "twitter/rest/utils"
4
+ require "twitter/utils"
5
5
 
6
6
  module Twitter
7
7
  module REST
@@ -22,12 +22,12 @@ module Twitter
22
22
  },
23
23
  }
24
24
  json_options[:welcome_message][:name] = name if name
25
- welcome_message_wrapper = perform_request_with_object(:json_post, '/1.1/direct_messages/welcome_messages/new.json', json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper)
25
+ welcome_message_wrapper = perform_request_with_object(:json_post, "/1.1/direct_messages/welcome_messages/new.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper)
26
26
  welcome_message_wrapper.welcome_message
27
27
  end
28
28
 
29
29
  def destroy_welcome_message(*ids)
30
- perform_requests(:delete, '/1.1/direct_messages/welcome_messages/destroy.json', ids)
30
+ perform_requests(:delete, "/1.1/direct_messages/welcome_messages/destroy.json", ids)
31
31
  end
32
32
 
33
33
  def update_welcome_message(welcome_message_id, text, options = {})
@@ -39,20 +39,20 @@ module Twitter
39
39
  text: text,
40
40
  },
41
41
  }
42
- welcome_message_wrapper = perform_request_with_object(:json_put, '/1.1/direct_messages/welcome_messages/update.json', json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper, params)
42
+ welcome_message_wrapper = perform_request_with_object(:json_put, "/1.1/direct_messages/welcome_messages/update.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageWrapper, params)
43
43
  welcome_message_wrapper.welcome_message
44
44
  end
45
45
 
46
46
  def welcome_message(id, options = {})
47
47
  options = options.dup
48
48
  options[:id] = id
49
- welcome_message_wrapper = perform_get_with_object('/1.1/direct_messages/welcome_messages/show.json', options, Twitter::DirectMessages::WelcomeMessageWrapper)
49
+ welcome_message_wrapper = perform_get_with_object("/1.1/direct_messages/welcome_messages/show.json", options, Twitter::DirectMessages::WelcomeMessageWrapper)
50
50
  welcome_message_wrapper.welcome_message
51
51
  end
52
52
 
53
53
  def welcome_message_list(options = {})
54
54
  limit = options.fetch(:count, 20)
55
- welcome_message_wrappers = perform_get_with_cursor('/1.1/direct_messages/welcome_messages/list.json', options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_messages, Twitter::DirectMessages::WelcomeMessageWrapper)
55
+ welcome_message_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_messages, Twitter::DirectMessages::WelcomeMessageWrapper)
56
56
  welcome_message_wrappers.collect(&:welcome_message)
57
57
  end
58
58
 
@@ -64,24 +64,24 @@ module Twitter
64
64
  welcome_message_id: welcome_message_id,
65
65
  },
66
66
  }
67
- rule_wrapper = perform_request_with_object(:json_post, '/1.1/direct_messages/welcome_messages/rules/new.json', json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageRuleWrapper)
67
+ rule_wrapper = perform_request_with_object(:json_post, "/1.1/direct_messages/welcome_messages/rules/new.json", json_options.merge!(options), Twitter::DirectMessages::WelcomeMessageRuleWrapper)
68
68
  rule_wrapper.welcome_message_rule
69
69
  end
70
70
 
71
71
  def destroy_welcome_message_rule(*ids)
72
- perform_requests(:delete, '/1.1/direct_messages/welcome_messages/rules/destroy.json', ids)
72
+ perform_requests(:delete, "/1.1/direct_messages/welcome_messages/rules/destroy.json", ids)
73
73
  end
74
74
 
75
75
  def welcome_message_rule(id, options = {})
76
76
  options = options.dup
77
77
  options[:id] = id
78
- rule_wrapper = perform_get_with_object('/1.1/direct_messages/welcome_messages/rules/show.json', options, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
78
+ rule_wrapper = perform_get_with_object("/1.1/direct_messages/welcome_messages/rules/show.json", options, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
79
79
  rule_wrapper.welcome_message_rule
80
80
  end
81
81
 
82
82
  def welcome_message_rule_list(options = {})
83
83
  limit = options.fetch(:count, 20)
84
- rule_wrappers = perform_get_with_cursor('/1.1/direct_messages/welcome_messages/rules/list.json', options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_message_rules, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
84
+ rule_wrappers = perform_get_with_cursor("/1.1/direct_messages/welcome_messages/rules/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :welcome_message_rules, Twitter::DirectMessages::WelcomeMessageRuleWrapper)
85
85
  rule_wrappers.collect(&:welcome_message_rule)
86
86
  end
87
87
  end
@@ -1,10 +1,10 @@
1
- require 'twitter/arguments'
2
- require 'twitter/direct_message'
3
- require 'twitter/direct_message_event'
4
- require 'twitter/rest/upload_utils'
5
- require 'twitter/rest/utils'
6
- require 'twitter/user'
7
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/direct_message"
3
+ require "twitter/direct_message_event"
4
+ require "twitter/rest/upload_utils"
5
+ require "twitter/rest/utils"
6
+ require "twitter/user"
7
+ require "twitter/utils"
8
8
 
9
9
  module Twitter
10
10
  module REST
@@ -25,7 +25,7 @@ module Twitter
25
25
  # @option options [String] :cursor Specifies the cursor position of results to retrieve.
26
26
  def direct_messages_events(options = {})
27
27
  limit = options.fetch(:count, 20)
28
- perform_get_with_cursor('/1.1/direct_messages/events/list.json', options.merge!(no_default_cursor: true, count: 50, limit: limit), :events, Twitter::DirectMessageEvent)
28
+ perform_get_with_cursor("/1.1/direct_messages/events/list.json", options.merge!(no_default_cursor: true, count: 50, limit: limit), :events, Twitter::DirectMessageEvent)
29
29
  end
30
30
 
31
31
  # Returns all Direct Messages for the authenticated user (both sent and received) within the last 30 days. Sorted in reverse-chronological order.
@@ -102,7 +102,7 @@ module Twitter
102
102
  def direct_message_event(id, options = {})
103
103
  options = options.dup
104
104
  options[:id] = id
105
- perform_get_with_object('/1.1/direct_messages/events/show.json', options, Twitter::DirectMessageEvent)
105
+ perform_get_with_object("/1.1/direct_messages/events/show.json", options, Twitter::DirectMessageEvent)
106
106
  end
107
107
 
108
108
  # Returns direct messages specified in arguments, or, if no arguments are given, returns direct messages received by authenticating user
@@ -153,7 +153,7 @@ module Twitter
153
153
  # @param ids [Enumerable<Integer>] A collection of direct message IDs.
154
154
  def destroy_direct_message(*ids)
155
155
  pmap(ids) do |id|
156
- perform_requests(:delete, '/1.1/direct_messages/events/destroy.json', id: id)
156
+ perform_requests(:delete, "/1.1/direct_messages/events/destroy.json", id: id)
157
157
  end
158
158
  nil
159
159
  end
@@ -169,7 +169,7 @@ module Twitter
169
169
  # @param text [String] The text of your direct message, up to 10,000 characters.
170
170
  # @param options [Hash] A customizable set of options.
171
171
  def create_direct_message(user_id, text, options = {})
172
- event = perform_request_with_object(:json_post, '/1.1/direct_messages/events/new.json', format_json_options(user_id, text, options), Twitter::DirectMessageEvent)
172
+ event = perform_request_with_object(:json_post, "/1.1/direct_messages/events/new.json", format_json_options(user_id, text, options), Twitter::DirectMessageEvent)
173
173
  event.direct_message
174
174
  end
175
175
  alias d create_direct_message
@@ -190,8 +190,8 @@ module Twitter
190
190
  def create_direct_message_event(*args)
191
191
  arguments = Twitter::Arguments.new(args)
192
192
  options = arguments.options.dup
193
- options[:event] = {type: 'message_create', message_create: {target: {recipient_id: extract_id(arguments[0])}, message_data: {text: arguments[1]}}} if arguments.length >= 2
194
- response = Twitter::REST::Request.new(self, :json_post, '/1.1/direct_messages/events/new.json', options).perform
193
+ options[:event] = {type: "message_create", message_create: {target: {recipient_id: extract_id(arguments[0])}, message_data: {text: arguments[1]}}} if arguments.length >= 2
194
+ response = Twitter::REST::Request.new(self, :json_post, "/1.1/direct_messages/events/new.json", options).perform
195
195
  Twitter::DirectMessageEvent.new(response[:event])
196
196
  end
197
197
 
@@ -209,17 +209,17 @@ module Twitter
209
209
  # @param media [File] A media file (PNG, JPEG, GIF or MP4).
210
210
  # @param options [Hash] A customizable set of options.
211
211
  def create_direct_message_event_with_media(user, text, media, options = {})
212
- media_id = upload(media, media_category_prefix: 'dm')[:media_id]
212
+ media_id = upload(media, media_category_prefix: "dm")[:media_id]
213
213
  options = options.dup
214
- options[:event] = {type: 'message_create', message_create: {target: {recipient_id: extract_id(user)}, message_data: {text: text, attachment: {type: 'media', media: {id: media_id}}}}}
215
- response = Twitter::REST::Request.new(self, :json_post, '/1.1/direct_messages/events/new.json', options).perform
214
+ options[:event] = {type: "message_create", message_create: {target: {recipient_id: extract_id(user)}, message_data: {text: text, attachment: {type: "media", media: {id: media_id}}}}}
215
+ response = Twitter::REST::Request.new(self, :json_post, "/1.1/direct_messages/events/new.json", options).perform
216
216
  Twitter::DirectMessageEvent.new(response[:event])
217
217
  end
218
218
 
219
219
  private
220
220
 
221
221
  def format_json_options(user_id, text, options)
222
- {'event': {'type': 'message_create', 'message_create': {'target': {'recipient_id': user_id}, 'message_data': {'text': text}.merge(options)}}}
222
+ {event: {type: "message_create", message_create: {target: {recipient_id: user_id}, message_data: {text: text}.merge(options)}}}
223
223
  end
224
224
  end
225
225
  end
@@ -1,9 +1,9 @@
1
- require 'twitter/arguments'
2
- require 'twitter/error'
3
- require 'twitter/rest/utils'
4
- require 'twitter/tweet'
5
- require 'twitter/user'
6
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/error"
3
+ require "twitter/rest/utils"
4
+ require "twitter/tweet"
5
+ require "twitter/user"
6
+ require "twitter/utils"
7
7
 
8
8
  module Twitter
9
9
  module REST
@@ -32,7 +32,7 @@ module Twitter
32
32
  def favorites(*args)
33
33
  arguments = Twitter::Arguments.new(args)
34
34
  merge_user!(arguments.options, arguments.pop) if arguments.last
35
- perform_get_with_objects('/1.1/favorites/list.json', arguments.options, Twitter::Tweet)
35
+ perform_get_with_objects("/1.1/favorites/list.json", arguments.options, Twitter::Tweet)
36
36
  end
37
37
 
38
38
  # Un-favorites the specified Tweets as the authenticating user
@@ -50,11 +50,9 @@ module Twitter
50
50
  def unfavorite(*args)
51
51
  arguments = Twitter::Arguments.new(args)
52
52
  pmap(arguments) do |tweet|
53
- begin
54
- perform_post_with_object('/1.1/favorites/destroy.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
55
- rescue Twitter::Error::NotFound
56
- next
57
- end
53
+ perform_post_with_object("/1.1/favorites/destroy.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
54
+ rescue Twitter::Error::NotFound
55
+ next
58
56
  end.compact
59
57
  end
60
58
  alias destroy_favorite unfavorite
@@ -73,7 +71,7 @@ module Twitter
73
71
  # @param tweets [Enumerable<Integer, String, URI, Twitter::Tweet>] A collection of Tweet IDs, URIs, or objects.
74
72
  # @param options [Hash] A customizable set of options.
75
73
  def unfavorite!(*args)
76
- parallel_objects_from_response(Twitter::Tweet, :post, '/1.1/favorites/destroy.json', args)
74
+ parallel_objects_from_response(Twitter::Tweet, :post, "/1.1/favorites/destroy.json", args)
77
75
  end
78
76
 
79
77
  # Favorites the specified Tweets as the authenticating user
@@ -91,11 +89,9 @@ module Twitter
91
89
  def favorite(*args)
92
90
  arguments = Twitter::Arguments.new(args)
93
91
  pmap(arguments) do |tweet|
94
- begin
95
- perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
96
- rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
97
- next
98
- end
92
+ perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
93
+ rescue Twitter::Error::AlreadyFavorited, Twitter::Error::NotFound
94
+ next
99
95
  end.compact
100
96
  end
101
97
  alias fav favorite
@@ -118,7 +114,7 @@ module Twitter
118
114
  def favorite!(*args)
119
115
  arguments = Twitter::Arguments.new(args)
120
116
  pmap(arguments) do |tweet|
121
- perform_post_with_object('/1.1/favorites/create.json', arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
117
+ perform_post_with_object("/1.1/favorites/create.json", arguments.options.merge(id: extract_id(tweet)), Twitter::Tweet)
122
118
  end
123
119
  end
124
120
  alias create_favorite! favorite!
@@ -0,0 +1,27 @@
1
+ module Twitter
2
+ module REST
3
+ class FormEncoder
4
+ UNESCAPED_CHARS = /[^a-z0-9\-._~]/i
5
+
6
+ def self.encode(data)
7
+ data.collect do |k, v|
8
+ if v.nil?
9
+ ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
10
+ elsif v.respond_to?(:to_ary)
11
+ v.to_ary.collect do |w|
12
+ str = ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
13
+ unless w.nil?
14
+ str << "="
15
+ str << ::URI::DEFAULT_PARSER.escape(w.to_s, UNESCAPED_CHARS)
16
+ end
17
+ end.join("&")
18
+ else
19
+ str = ::URI::DEFAULT_PARSER.escape(k.to_s, UNESCAPED_CHARS)
20
+ str << "="
21
+ str << ::URI::DEFAULT_PARSER.escape(v.to_s, UNESCAPED_CHARS)
22
+ end
23
+ end.join("&")
24
+ end
25
+ end
26
+ end
27
+ end
@@ -1,10 +1,10 @@
1
- require 'twitter/arguments'
2
- require 'twitter/cursor'
3
- require 'twitter/relationship'
4
- require 'twitter/rest/request'
5
- require 'twitter/rest/utils'
6
- require 'twitter/user'
7
- require 'twitter/utils'
1
+ require "twitter/arguments"
2
+ require "twitter/cursor"
3
+ require "twitter/relationship"
4
+ require "twitter/rest/request"
5
+ require "twitter/rest/utils"
6
+ require "twitter/user"
7
+ require "twitter/utils"
8
8
 
9
9
  module Twitter
10
10
  module REST
@@ -27,7 +27,7 @@ module Twitter
27
27
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
28
28
  # @param options [Hash] A customizable set of options.
29
29
  def friend_ids(*args)
30
- cursor_from_response_with_user(:ids, nil, '/1.1/friends/ids.json', args)
30
+ cursor_from_response_with_user(:ids, nil, "/1.1/friends/ids.json", args)
31
31
  end
32
32
 
33
33
  # @see https://dev.twitter.com/rest/reference/get/followers/ids
@@ -45,7 +45,7 @@ module Twitter
45
45
  # @param user [Integer, String, Twitter::User] A Twitter user ID, screen name, URI, or object.
46
46
  # @param options [Hash] A customizable set of options.
47
47
  def follower_ids(*args)
48
- cursor_from_response_with_user(:ids, nil, '/1.1/followers/ids.json', args)
48
+ cursor_from_response_with_user(:ids, nil, "/1.1/followers/ids.json", args)
49
49
  end
50
50
 
51
51
  # 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.
@@ -63,7 +63,7 @@ module Twitter
63
63
  def friendships(*args)
64
64
  arguments = Twitter::Arguments.new(args)
65
65
  merge_users!(arguments.options, arguments)
66
- perform_get_with_objects('/1.1/friendships/lookup.json', arguments.options, Twitter::User)
66
+ perform_get_with_objects("/1.1/friendships/lookup.json", arguments.options, Twitter::User)
67
67
  end
68
68
 
69
69
  # Returns an array of numeric IDs for every user who has a pending request to follow the authenticating user
@@ -75,7 +75,7 @@ module Twitter
75
75
  # @return [Twitter::Cursor]
76
76
  # @param options [Hash] A customizable set of options.
77
77
  def friendships_incoming(options = {})
78
- perform_get_with_cursor('/1.1/friendships/incoming.json', options, :ids)
78
+ perform_get_with_cursor("/1.1/friendships/incoming.json", options, :ids)
79
79
  end
80
80
 
81
81
  # Returns an array of numeric IDs for every protected user for whom the authenticating user has a pending follow request
@@ -87,7 +87,7 @@ module Twitter
87
87
  # @return [Twitter::Cursor]
88
88
  # @param options [Hash] A customizable set of options.
89
89
  def friendships_outgoing(options = {})
90
- perform_get_with_cursor('/1.1/friendships/outgoing.json', options, :ids)
90
+ perform_get_with_cursor("/1.1/friendships/outgoing.json", options, :ids)
91
91
  end
92
92
 
93
93
  # Allows the authenticating user to follow the specified users, unless they are already followed
@@ -131,7 +131,7 @@ module Twitter
131
131
  def follow!(*args)
132
132
  arguments = Twitter::Arguments.new(args)
133
133
  pmap(arguments) do |user|
134
- perform_post_with_object('/1.1/friendships/create.json', merge_user(arguments.options, user), Twitter::User)
134
+ perform_post_with_object("/1.1/friendships/create.json", merge_user(arguments.options, user), Twitter::User)
135
135
  end.compact
136
136
  end
137
137
  alias create_friendship! follow!
@@ -149,7 +149,7 @@ module Twitter
149
149
  # @param users [Enumerable<Integer, String, Twitter::User>] A collection of Twitter user IDs, screen names, or objects.
150
150
  # @param options [Hash] A customizable set of options.
151
151
  def unfollow(*args)
152
- parallel_users_from_response(:post, '/1.1/friendships/destroy.json', args)
152
+ parallel_users_from_response(:post, "/1.1/friendships/destroy.json", args)
153
153
  end
154
154
  alias destroy_friendship unfollow
155
155
 
@@ -166,7 +166,7 @@ module Twitter
166
166
  # @option options [Boolean] :retweets Enable/disable retweets from the target user.
167
167
  def friendship_update(user, options = {})
168
168
  merge_user!(options, user)
169
- perform_post_with_object('/1.1/friendships/update.json', options, Twitter::Relationship)
169
+ perform_post_with_object("/1.1/friendships/update.json", options, Twitter::Relationship)
170
170
  end
171
171
 
172
172
  # Returns detailed information about the relationship between two users
@@ -181,11 +181,11 @@ module Twitter
181
181
  # @param options [Hash] A customizable set of options.
182
182
  def friendship(source, target, options = {})
183
183
  options = options.dup
184
- merge_user!(options, source, 'source')
184
+ merge_user!(options, source, "source")
185
185
  options[:source_id] = options.delete(:source_user_id) unless options[:source_user_id].nil?
186
- merge_user!(options, target, 'target')
186
+ merge_user!(options, target, "target")
187
187
  options[:target_id] = options.delete(:target_user_id) unless options[:target_user_id].nil?
188
- perform_get_with_object('/1.1/friendships/show.json', options, Twitter::Relationship)
188
+ perform_get_with_object("/1.1/friendships/show.json", options, Twitter::Relationship)
189
189
  end
190
190
  alias friendship_show friendship
191
191
  alias relationship friendship
@@ -225,7 +225,7 @@ module Twitter
225
225
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
226
226
  # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
227
227
  def followers(*args)
228
- cursor_from_response_with_user(:users, Twitter::User, '/1.1/followers/list.json', args)
228
+ cursor_from_response_with_user(:users, Twitter::User, "/1.1/followers/list.json", args)
229
229
  end
230
230
 
231
231
  # Returns a cursored collection of user objects for every user the specified user is following (otherwise known as their "friends").
@@ -249,7 +249,7 @@ module Twitter
249
249
  # @option options [Boolean, String, Integer] :skip_status Do not include contributee's Tweets when set to true, 't' or 1.
250
250
  # @option options [Boolean, String, Integer] :include_user_entities The user entities node will be disincluded when set to false.
251
251
  def friends(*args)
252
- cursor_from_response_with_user(:users, Twitter::User, '/1.1/friends/list.json', args)
252
+ cursor_from_response_with_user(:users, Twitter::User, "/1.1/friends/list.json", args)
253
253
  end
254
254
  alias following friends
255
255
 
@@ -261,7 +261,7 @@ module Twitter
261
261
  # @return [Array<Integer>]
262
262
  # @param options [Hash] A customizable set of options.
263
263
  def no_retweet_ids(options = {})
264
- perform_get('/1.1/friendships/no_retweets/ids.json', options).collect(&:to_i)
264
+ perform_get("/1.1/friendships/no_retweets/ids.json", options).collect(&:to_i)
265
265
  end
266
266
  alias no_retweets_ids no_retweet_ids
267
267
  end
@@ -1,24 +1,12 @@
1
- require 'twitter/configuration'
2
- require 'twitter/language'
3
- require 'twitter/rest/request'
4
- require 'twitter/rest/utils'
1
+ require "twitter/language"
2
+ require "twitter/rest/request"
3
+ require "twitter/rest/utils"
5
4
 
6
5
  module Twitter
7
6
  module REST
8
7
  module Help
9
8
  include Twitter::REST::Utils
10
9
 
11
- # Returns the current configuration used by Twitter
12
- #
13
- # @see https://dev.twitter.com/rest/reference/get/help/configuration
14
- # @rate_limited Yes
15
- # @authentication Requires user context
16
- # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
17
- # @return [Twitter::Configuration] Twitter's configuration.
18
- def configuration(options = {})
19
- perform_get_with_object('/1.1/help/configuration.json', options, Twitter::Configuration)
20
- end
21
-
22
10
  # Returns the list of languages supported by Twitter
23
11
  #
24
12
  # @see https://dev.twitter.com/rest/reference/get/help/languages
@@ -27,7 +15,7 @@ module Twitter
27
15
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
28
16
  # @return [Array<Twitter::Language>]
29
17
  def languages(options = {})
30
- perform_get_with_objects('/1.1/help/languages.json', options, Twitter::Language)
18
+ perform_get_with_objects("/1.1/help/languages.json", options, Twitter::Language)
31
19
  end
32
20
 
33
21
  # Returns {https://twitter.com/privacy Twitter's Privacy Policy}
@@ -38,7 +26,7 @@ module Twitter
38
26
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
39
27
  # @return [String]
40
28
  def privacy(options = {})
41
- perform_get('/1.1/help/privacy.json', options)[:privacy]
29
+ perform_get("/1.1/help/privacy.json", options)[:privacy]
42
30
  end
43
31
 
44
32
  # Returns {https://twitter.com/tos Twitter's Terms of Service}
@@ -49,7 +37,7 @@ module Twitter
49
37
  # @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
50
38
  # @return [String]
51
39
  def tos(options = {})
52
- perform_get('/1.1/help/tos.json', options)[:tos]
40
+ perform_get("/1.1/help/tos.json", options)[:tos]
53
41
  end
54
42
  end
55
43
  end