Skip to content

Instantly share code, notes, and snippets.

@ebuckley
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ebuckley/8b792d6d8f27a50d9fe4 to your computer and use it in GitHub Desktop.
Save ebuckley/8b792d6d8f27a50d9fe4 to your computer and use it in GitHub Desktop.
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