Module: Twitter::REST::SavedSearches

Includes:
Utils, Utils
Included in:
API
Defined in:
lib/twitter/rest/saved_searches.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Methods included from Utils

flat_pmap, pmap

Instance Method Details

#create_saved_search(query, options = {}) ⇒ Twitter::SavedSearch

Creates a saved search for the authenticated user

Parameters:

  • query (String)

    The query of the search the user would like to save.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



65
66
67
# File 'lib/twitter/rest/saved_searches.rb', line 65

def create_saved_search(query, options = {})
  perform_post_with_object("/1.1/saved_searches/create.json", options.merge(query:), Twitter::SavedSearch)
end

#destroy_saved_search(*ids) ⇒ Array<Twitter::SavedSearch> #destroy_saved_search(*ids, options) ⇒ Array<Twitter::SavedSearch>

Note:

The search specified by ID must be owned by the authenticating user.

Destroys saved searches for the authenticated user

Overloads:

  • #destroy_saved_search(*ids) ⇒ Array<Twitter::SavedSearch>

    Parameters:

    • ids (Enumerable<Integer>)

      A collection of saved search IDs.

  • #destroy_saved_search(*ids, options) ⇒ Array<Twitter::SavedSearch>

    Parameters:

    • ids (Enumerable<Integer>)

      A collection of saved search IDs.

    • options (Hash)

      A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



82
83
84
85
86
87
# File 'lib/twitter/rest/saved_searches.rb', line 82

def destroy_saved_search(*args)
  arguments = Twitter::Arguments.new(args)
  pmap(arguments) do |id|
    perform_post_with_object("/1.1/saved_searches/destroy/#{id}.json", arguments.options, Twitter::SavedSearch)
  end
end

#saved_search(id, options = {}) ⇒ Twitter::SavedSearch

Retrieve the data for saved searches owned by the authenticating user

Parameters:

  • id (Integer)

    The ID of the saved search.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



52
53
54
# File 'lib/twitter/rest/saved_searches.rb', line 52

def saved_search(id, options = {})
  perform_get_with_object("/1.1/saved_searches/show/#{id}.json", options, Twitter::SavedSearch)
end

#saved_search(options = {}) ⇒ Array<Twitter::SavedSearch> #saved_search(*ids) ⇒ Array<Twitter::SavedSearch> #saved_search(*ids, options) ⇒ Array<Twitter::SavedSearch>

Returns The saved searches.

Overloads:

Returns:

Raises:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



32
33
34
35
36
37
38
39
40
41
# File 'lib/twitter/rest/saved_searches.rb', line 32

def saved_searches(*args)
  arguments = Twitter::Arguments.new(args)
  if arguments.empty?
    perform_get_with_objects("/1.1/saved_searches/list.json", arguments.options, Twitter::SavedSearch)
  else
    pmap(arguments) do |id|
      saved_search(id, arguments.options)
    end
  end
end