Module: Twitter::API::SavedSearches

Includes:
Utils
Included in:
Client
Defined in:
lib/twitter/api/saved_searches.rb

Constant Summary

Constants included from Utils

Utils::DEFAULT_CURSOR

Instance Method Summary collapse

Instance Method Details

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

Retrieve the data for saved searches owned by the authenticating user

Examples:

Retrieve the data for a saved search owned by the authenticating user with the ID 16129012

Twitter.saved_search(16129012)

Parameters:

  • id (Integer)

    A Tweet IDs.

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

    A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • Yes

Authentication:

  • Requires user context



56
57
58
# File 'lib/twitter/api/saved_searches.rb', line 56

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

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

Creates a saved search for the authenticated user

Examples:

Create a saved search for the authenticated user with the query "twitter"

Twitter.saved_search_create("twitter")

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



71
72
73
# File 'lib/twitter/api/saved_searches.rb', line 71

def saved_search_create(query, options={})
  object_from_response(Twitter::SavedSearch, :post, "/1.1/saved_searches/create.json", options.merge(:query => query))
end

#saved_search_destroy(*ids) ⇒ Array<Twitter::SavedSearch> #saved_search_destroy(*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:

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

    Examples:

    Destroys a saved search for the authenticated user with the ID 16129012

    Twitter.saved_search_destroy(16129012)
    

    Parameters:

    • ids (Array<Integer>, Set<Integer>)

      An array of Tweet IDs.

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

    Parameters:

    • ids (Array<Integer>, Set<Integer>)

      An array of Tweet IDs.

    • options (Hash)

      A customizable set of options.

Returns:

Raises:

See Also:

Rate Limited?:

  • No

Authentication:

  • Requires user context



90
91
92
93
94
95
# File 'lib/twitter/api/saved_searches.rb', line 90

def saved_search_destroy(*args)
  arguments = Twitter::API::Arguments.new(args)
  arguments.flatten.threaded_map do |id|
    object_from_response(Twitter::SavedSearch, :post, "/1.1/saved_searches/destroy/#{id}.json", arguments.options)
  end
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



34
35
36
37
38
39
40
41
42
43
# File 'lib/twitter/api/saved_searches.rb', line 34

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