Permalink
Browse files

added ability to search on Foursque Venue ID (v2)

  • Loading branch information...
1 parent 4321b76 commit f6a66c3c4be9979009555ed94b0f82188a875546 locationstar committed Nov 13, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 lib/instagram/client/locations.rb
@@ -38,20 +38,32 @@ def location_recent_media(id, *args)
response
end
- # Returns Instagram locations within proximity of given lat,lng
+ # Returns Instagram locations within proximity of given lat,lng or foursquare venue id
#
# @param lat [String] A given latitude in decimal format
# @param lng [String] A given longitude in decimal format
+ # or
+ # @param foursquare_v2_id [String] A valid Foursquare Venue ID (v2)
# @option options [Integer] :count The number of media items to retrieve.
# @return [Array]
- # @example Return locations around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)
+ # @example 1: Return a location with the Foursquare Venue ID = ()
+ # Instagram.location_search("")
+ # @example 2: Return locations around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)
# Instagram.location_search("37.7808851", "-122.3948632")
# @see TODO:doc url
# @format :json
# @authenticated false
# @rate_limited true
- def location_search(lat, lng, options={})
- response = get('locations/search', options.merge(:lat => lat, :lng => lng))
+ def location_search(*args)
+ options = args.last.is_a?(Hash) ? args.pop : {}
+ case args.size
+ when 1
+ foursquare_v2_id = args.first
+ response = get('locations/search', options.merge(:foursquare_v2_id => foursquare_v2_id))
+ when 2
+ lat, lng = args
+ response = get('locations/search', options.merge(:lat => lat, :lng => lng))
+ end
response["data"]
end
end

0 comments on commit f6a66c3

Please sign in to comment.