lib/fireeagle/client.rb in fireeagle-0.6.0 vs lib/fireeagle/client.rb in fireeagle-0.6.1
- old
+ new
@@ -155,15 +155,11 @@
def lookup(params)
raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
response = get(FireEagle::LOOKUP_API_PATH + ".#{format}", :params => params)
- if json?
- JSON.parse(response.body)
- else
- FireEagle::Response.new(response.body).locations
- end
+ FireEagle::Response.new(response.body).locations
end
# Sets a User's current Location using using a Place ID hash or a set of Location parameters. If the User
# provides a Location unconfirmed with lookup then FireEagle makes a best guess as to the User's Location.
#
@@ -194,50 +190,35 @@
location = sanitize_location_hash(location)
response = post(FireEagle::UPDATE_API_PATH + ".#{format}", :params => location)
- if json?
- JSON.parse(response.body)
- else
- FireEagle::Response.new(response.body)
- end
+ FireEagle::Response.new(response.body)
end
# Returns the Location of a User.
def user
raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
response = get(FireEagle::USER_API_PATH + ".#{format}")
- if json?
- JSON.parse(response.body)
- else
- FireEagle::Response.new(response.body).users.first
- end
+ FireEagle::Response.new(response.body).users.first
end
alias_method :location, :user
- # <b>NOTE: not implemented yet</b>
- #
# Query for Users of an Application who have updated their Location recently. Returns a list of
# Users for the Application with recently updated locations.
def recent(count = 10, start = 0)
raise FireEagle::ArgumentError, "OAuth Access Token Required" unless @access_token
params = { :count => count, :start => start }
response = get(FireEagle::RECENT_API_PATH + ".#{format}", :params => params)
- if json?
- JSON.parse(response.body)
- else
- FireEagle::Response.new(response.body).users
- end
+ FireEagle::Response.new(response.body).users
end
- # <b>NOTE: not implemented yet</b>
# Takes a Place ID or a Location and returns a list of users of your application who are within the bounding box of that Location.
#
# Location Hash keys, in order of priority:
#
# [<tt>(:lat, :lon)</tt>] both required, valid values are floats of -180 to 180 for lat and -90 to 90 for lon
@@ -262,15 +243,11 @@
location = sanitize_location_hash(location)
params = { :count => count, :start => start }.merge(location)
response = get(FireEagle::WITHIN_API_PATH + ".#{format}", :params => params)
- if json?
- JSON.parse(response.body)
- else
- FireEagle::Response.new(response.body).users
- end
+ FireEagle::Response.new(response.body).users
end
protected
def sanitize_location_hash(location)
@@ -284,13 +261,9 @@
location
end
def xml? #:nodoc:
format == FireEagle::FORMAT_XML
- end
-
- def json? #:nodoc:
- format == FireEagle::FORMAT_JSON
end
def create_token(response) #:nodoc:
token = Hash[*response.body.split("&").map { |x| x.split("=") }.flatten]
OAuth::Token.new(token["oauth_token"], token["oauth_token_secret"])
\ No newline at end of file