Skip to content

Commit

Permalink
Add Search#image_facets and Search#video_facets methods
Browse files Browse the repository at this point in the history
Note: Change default endpoint to https://api.twitter.com/i/
  • Loading branch information
sferik committed Sep 4, 2011
1 parent 07b87e1 commit 1cc1f3c
Show file tree
Hide file tree
Showing 9 changed files with 2,271 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/twitter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ class Client < API
require 'twitter/client/list_subscribers'
require 'twitter/client/local_trends'
require 'twitter/client/notification'
require 'twitter/client/spam_reporting'
require 'twitter/client/saved_searches'
require 'twitter/client/search'
require 'twitter/client/spam_reporting'
require 'twitter/client/timeline'
require 'twitter/client/trends'
require 'twitter/client/tweets'
Expand All @@ -48,8 +49,9 @@ class Client < API
include Twitter::Client::ListSubscribers
include Twitter::Client::LocalTrends
include Twitter::Client::Notification
include Twitter::Client::SpamReporting
include Twitter::Client::SavedSearches
include Twitter::Client::Search
include Twitter::Client::SpamReporting
include Twitter::Client::Timeline
include Twitter::Client::Trends
include Twitter::Client::Tweets
Expand Down
44 changes: 44 additions & 0 deletions lib/twitter/client/search.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
module Twitter
class Client
# Defines methods related to Search
module Search
# Returns recent images related to a query
#
# @note Undocumented
# @rate_limited Yes
# @requires_authentication No
# @response_format `json`
# @response_format `xml`
# @param q [String] A search term.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
# @return [Array] An array of statuses that contain images
# @example Return recent images related to twitter
# Twitter.image_facets('twitter')
def image_facets(q, options={})
response = get('search/image_facets', options.merge(:q => q))
format.to_s.downcase == 'xml' ? response['statuses'] : response
end

# Returns recent videos related to a query
#
# @note Undocumented
# @rate_limited Yes
# @requires_authentication No
# @response_format `json`
# @response_format `xml`
# @param q [String] A search term.
# @param options [Hash] A customizable set of options.
# @option options [Integer] :count Specifies the number of records to retrieve. Must be less than or equal to 100.
# @option options [Boolean, String, Integer] :include_entities Include {http://dev.twitter.com/pages/tweet_entities Tweet Entities} when set to true, 't' or 1.
# @return [Array] An array of statuses that contain videos
# @example Return recent videos related to twitter
# Twitter.video_facets('twitter')
def video_facets(q, options={})
response = get('search/video_facets', options.merge(:q => q))
format.to_s.downcase == 'xml' ? response['statuses'] : response
end
end
end
end
2 changes: 1 addition & 1 deletion lib/twitter/client/urls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Urls
# @requires_authentication Yes
# @response_format `json`
# @overload resolve(urls, options={})
# @param urls [String] A list of shortened URLs
# @param urls [String] A list of shortened URLs.
# @param options [Hash] A customizable set of options.
# @return [Hashie::Mash] A hash of URLs with the shortened URLs as the key
# @example Return the canonical version of a URL shortened by Twitter
Expand Down
2 changes: 1 addition & 1 deletion lib/twitter/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module Configuration
# @see http://en.blog.wordpress.com/2009/12/12/twitter-api/
# @see http://staff.tumblr.com/post/287703110/api
# @see http://developer.typepad.com/typepad-twitter-api/twitter-api.html
DEFAULT_ENDPOINT = 'https://api.twitter.com/1/'.freeze
DEFAULT_ENDPOINT = 'https://api.twitter.com/i/'.freeze

# The response format appended to the path and sent in the 'Accept' header if none is set
#
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/image_facets.json

Large diffs are not rendered by default.

Loading

0 comments on commit 1cc1f3c

Please sign in to comment.