lib/twitter/rest/api/saved_searches.rb in twitter-5.5.1 vs lib/twitter/rest/api/saved_searches.rb in twitter-5.6.0
- old
+ new
@@ -1,15 +1,17 @@
require 'twitter/arguments'
+require 'twitter/request'
require 'twitter/rest/api/utils'
require 'twitter/saved_search'
require 'twitter/utils'
module Twitter
module REST
module API
module SavedSearches
include Twitter::REST::API::Utils
+ include Twitter::Utils
# @rate_limited Yes
# @authentication Requires user context
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Array<Twitter::SavedSearch>] The saved searches.
@@ -30,13 +32,13 @@
# @param ids [Enumerable<Integer>] A collection of saved search IDs.
# @param options [Hash] A customizable set of options.
def saved_searches(*args)
arguments = Twitter::Arguments.new(args)
if arguments.empty?
- objects_from_response(Twitter::SavedSearch, :get, '/1.1/saved_searches/list.json', arguments.options)
+ perform_with_objects(:get, '/1.1/saved_searches/list.json', arguments.options, Twitter::SavedSearch)
else
- Twitter::Utils.parallel_map(arguments) do |id|
+ parallel_map(arguments) do |id|
saved_search(id, arguments.options)
end
end
end
@@ -48,11 +50,11 @@
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::SavedSearch] The saved searches.
# @param id [Integer] The ID of the saved search.
# @param options [Hash] A customizable set of options.
def saved_search(id, options = {})
- object_from_response(Twitter::SavedSearch, :get, "/1.1/saved_searches/show/#{id}.json", options)
+ perform_with_object(:get, "/1.1/saved_searches/show/#{id}.json", options, Twitter::SavedSearch)
end
# Creates a saved search for the authenticated user
#
# @see https://dev.twitter.com/docs/api/1.1/post/saved_searches/create
@@ -61,11 +63,11 @@
# @raise [Twitter::Error::Unauthorized] Error raised when supplied user credentials are not valid.
# @return [Twitter::SavedSearch] The created saved search.
# @param query [String] The query of the search the user would like to save.
# @param options [Hash] A customizable set of options.
def create_saved_search(query, options = {})
- object_from_response(Twitter::SavedSearch, :post, '/1.1/saved_searches/create.json', options.merge(:query => query))
+ perform_with_object(:post, '/1.1/saved_searches/create.json', options.merge(:query => query), Twitter::SavedSearch)
end
deprecate_alias :saved_search_create, :create_saved_search
# Destroys saved searches for the authenticated user
#
@@ -80,11 +82,11 @@
# @overload destroy_saved_search(*ids, options)
# @param ids [Enumerable<Integer>] A collection of saved search IDs.
# @param options [Hash] A customizable set of options.
def destroy_saved_search(*args)
arguments = Twitter::Arguments.new(args)
- Twitter::Utils.parallel_map(arguments) do |id|
- object_from_response(Twitter::SavedSearch, :post, "/1.1/saved_searches/destroy/#{id}.json", arguments.options)
+ parallel_map(arguments) do |id|
+ perform_with_object(:post, "/1.1/saved_searches/destroy/#{id}.json", arguments.options, Twitter::SavedSearch)
end
end
deprecate_alias :saved_search_destroy, :destroy_saved_search
end
end