Last active
August 29, 2015 14:02
-
-
Save ebuckley/8b792d6d8f27a50d9fe4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
require 'json' | |
#hamilton RegionId | |
hamilton = 16 | |
waikato = 14 | |
# make a query to the Residential endpoiint of the trademe search api | |
# | |
# @param argument_hash Hash | |
# | |
# The keys are query string parameter values, check the trademe documentation to find | |
# supported parameters. The value for a hashes key is the same as the value for its parameter | |
# | |
# Documentation of trademe residential search api: | |
# http://developer.trademe.co.nz/api-reference/search-methods/residential-search/ | |
# | |
# @returns Hash with the json response. | |
def trademeGet(argument_hash) | |
base_uri = "http://api.trademe.co.nz/v1/Search/Property/Residential.json?" | |
# add the region/district to the argument_hash | |
argument_hash.each do |key, value| | |
base_uri += "&#{key}=#{value}" | |
end | |
uri = URI(base_uri) | |
res = Net::HTTP.get(uri) | |
JSON.parse(res) | |
end | |
puts trademeGet region: waikato, district: hamilton |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment