lib/twitter/rest/api/direct_messages.rb in twitter-5.5.1 vs lib/twitter/rest/api/direct_messages.rb in twitter-5.6.0

- old
+ new

@@ -1,16 +1,18 @@ require 'twitter/arguments' require 'twitter/direct_message' +require 'twitter/request' require 'twitter/rest/api/utils' require 'twitter/user' require 'twitter/utils' module Twitter module REST module API module DirectMessages include Twitter::REST::API::Utils + include Twitter::Utils # Returns the 20 most recent direct messages sent to the authenticating user # # @see https://dev.twitter.com/docs/api/1.1/get/direct_messages # @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. @@ -22,11 +24,11 @@ # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. # @option options [Integer] :page Specifies the page of results to retrieve. def direct_messages_received(options = {}) - objects_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages.json', options) + perform_with_objects(:get, '/1.1/direct_messages.json', options, Twitter::DirectMessage) end # Returns the 20 most recent direct messages sent by the authenticating user # # @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/sent @@ -39,11 +41,11 @@ # @option options [Integer] :since_id Returns results with an ID greater than (that is, more recent than) the specified ID. # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID. # @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 200. # @option options [Integer] :page Specifies the page of results to retrieve. def direct_messages_sent(options = {}) - objects_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages/sent.json', options) + perform_with_objects(:get, '/1.1/direct_messages/sent.json', options, Twitter::DirectMessage) end # Returns a direct message # # @see https://dev.twitter.com/docs/api/1.1/get/direct_messages/show @@ -54,11 +56,11 @@ # @return [Twitter::DirectMessage] The requested messages. # @param id [Integer] A direct message ID. # @param options [Hash] A customizable set of options. def direct_message(id, options = {}) options[:id] = id - object_from_response(Twitter::DirectMessage, :get, '/1.1/direct_messages/show.json', options) + perform_with_object(:get, '/1.1/direct_messages/show.json', options, Twitter::DirectMessage) end # @note This method requires an access token with RWD (read, write & direct message) permissions. Consult The Application Permission Model for more information. # @rate_limited Yes # @authentication Requires user context @@ -87,11 +89,11 @@ def direct_messages(*args) arguments = Twitter::Arguments.new(args) if arguments.empty? direct_messages_received(arguments.options) else - Twitter::Utils.parallel_map(arguments) do |id| + parallel_map(arguments) do |id| direct_message(id, arguments.options) end end end @@ -124,10 +126,10 @@ # @param text [String] The text of your direct message, up to 140 characters. # @param options [Hash] A customizable set of options. def create_direct_message(user, text, options = {}) merge_user!(options, user) options[:text] = text - object_from_response(Twitter::DirectMessage, :post, '/1.1/direct_messages/new.json', options) + perform_with_object(:post, '/1.1/direct_messages/new.json', options, Twitter::DirectMessage) end alias_method :d, :create_direct_message alias_method :m, :create_direct_message alias_method :dm, :create_direct_message deprecate_alias :direct_message_create, :create_direct_message