Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updated to v2 api

  • Loading branch information...
commit ccf84c19eaa60aa95d6f052935004bc19b7f7c85 1 parent 9691c6e
Jonathan Spooner authored
View
11 README.md
@@ -1,3 +1,14 @@
+# Why I Forked Citygrid
+
+To support their version 2 api. http://docs.citygridmedia.com/display/citygridv2/CityGrid+APIs
+
+You can not run version 1 and 2 gems at the same time. Why? Well their documentation says their V1 API will be depreciated at some
+point in time.
+
+
+
+
+
# Citygrid
This is a Ruby wrapper for the [CityGrid API](http://developer.citysearch.com/home).
View
10 Rakefile
@@ -6,11 +6,11 @@ begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "citygrid"
- gem.summary = %Q{Ruby wrapper for the CityGrid API}
- gem.description = %Q{Ruby wrapper for the CityGrid API}
- gem.email = "johnnyn@gmail.com"
- gem.homepage = "http://github.com/phuphighter/citygrid"
- gem.authors = ["Johnny Khai Nguyen"]
+ gem.summary = %Q{Ruby wrapper for the CityGrid API V2}
+ gem.description = %Q{Ruby wrapper for the CityGrid API V2}
+ gem.email = "johnnyn@gmail.com, jspooner@gmail.com"
+ gem.homepage = "https://github.com/jspooner/citygrid"
+ gem.authors = ["Johnny Khai Nguyen, Jonathan Spooner"]
gem.add_dependency('httparty', '>= 0.5.0')
end
View
2  VERSION
@@ -1 +1 @@
-0.2.0
+0.3.0
View
35 lib/citygrid/client.rb
@@ -2,7 +2,7 @@ module Citygrid
class Client
include HTTParty
- base_uri "http://api2.citysearch.com"
+ base_uri "http://api.citygridmedia.com/content/places/v2"
format :xml
attr_reader :api_key
@@ -12,24 +12,28 @@ def initialize(options={})
end
def search_locations(options={})
- mashup(self.class.get("/search/locations", :query => options.merge(self.default_options)))
+ mashup(self.class.get("/search/where", :query => options.merge(self.default_options)))
end
-
- def search_events(options={})
- mashup(self.class.get("/search/events", :query => options.merge(self.default_options)))
+
+ def detail(options={})
+ mashup(self.class.get("/detail", :query => options.merge(self.default_options)))
end
- def profile(options={})
- if options[:client_ip].nil?
- puts "Dude, a client_ip is required."
- else
- mashup(self.class.get("/profile/", :query => options.merge(self.default_options)))
- end
- end
+ # def search_events(options={})
+ # mashup(self.class.get("/search/events", :query => options.merge(self.default_options)))
+ # end
- def reviews(options={})
- mashup(self.class.get("/reviews/", :query => options.merge(self.default_options)))
- end
+ # def profile(options={})
+ # if options[:client_ip].nil?
+ # puts "Dude, a client_ip is required."
+ # else
+ # mashup(self.class.get("/profile/", :query => options.merge(self.default_options)))
+ # end
+ # end
+
+ # def reviews(options={})
+ # mashup(self.class.get("/reviews/", :query => options.merge(self.default_options)))
+ # end
protected
@@ -38,6 +42,7 @@ def default_options
end
def mashup(response)
+ puts response.inspect
case response.code
when 200
if response.is_a?(Hash)
View
BIN  pkg/citygrid-0.1.0.gem
Binary file not shown
View
BIN  pkg/citygrid-0.1.1.gem
Binary file not shown
View
44 test/citygrid_test.rb
@@ -9,30 +9,38 @@ class CitygridTest < Test::Unit::TestCase
context "and searching for a place" do
should "find a specific place" do
- stub_get("http://api2.citysearch.com/search/locations?what=roots%20coffee&api_key=wtf&where=76180&publisher=acme", "search.xml")
+ # stub_get("http://api.citygridmedia.com/content/places/v2?what=roots%20coffee&api_key=wtf&where=76180&publisher=acme", "search.xml")
search_result = @client.search_locations(:what => "roots coffee", :where => "76180")
- search_result.results.location.name.should == "Roots Coffeehouse"
- search_result.results.location.address.postalcode.should == "76180"
+ search_result.results.locations.first[1].name.should == "Roots Coffeehouse"
+ search_result.results.locations.first[1].address.postal_code.should == "76180"
end
end
- context "and get profile" do
- should "get specific profile data" do
- stub_get("http://api2.citysearch.com/profile/?api_key=wtf&client_ip=127.0.0.1&listing_id=613027480&publisher=acme", "profile.xml")
- profile = @client.profile(:client_ip => "127.0.0.1", :listing_id => 613027480)
- profile.locations.location.name.should == "Roots Coffeehouse"
- profile.locations.location.address.latitude.should == "32.849869"
- end
- end
-
- context "and get reviews" do
- should "get specific reviews" do
- stub_get("http://api2.citysearch.com/reviews/?publisher=acme&api_key=wtf&tag_name=restaurant&where=90069", "review.xml")
- restaurant_reviews = @client.reviews(:where => '90069', :tag_name => 'restaurant')
- restaurant_reviews.reviews.first.last.first.business_name.should == "Cafe du Qvondeyz"
- restaurant_reviews.reviews.first.last[1].business_name.should == "Joselito's Mexican Food"
+ context "and find detail for a place" do
+ should "hanger 94" do
+ search_result = @client.detail(:phone => "6196609393", :client_ip=>"127.0.0.1")
+ puts search_result.locations.first[1].name.should == "Hanger 94"
end
end
+
+
+ # context "and get profile" do
+ # should "get specific profile data" do
+ # stub_get("http://api.citygridmedia.com/content/places/v2/profile/?api_key=wtf&client_ip=127.0.0.1&listing_id=613027480&publisher=acme", "profile.xml")
+ # profile = @client.profile(:client_ip => "127.0.0.1", :listing_id => 613027480)
+ # profile.locations.location.name.should == "Roots Coffeehouse"
+ # profile.locations.location.address.latitude.should == "32.849869"
+ # end
+ # end
+ #
+ # context "and get reviews" do
+ # should "get specific reviews" do
+ # stub_get("http://api.citygridmedia.com/content/places/v2/reviews/?publisher=acme&api_key=wtf&tag_name=restaurant&where=90069", "review.xml")
+ # restaurant_reviews = @client.reviews(:where => '90069', :tag_name => 'restaurant')
+ # restaurant_reviews.reviews.first.last.first.business_name.should == "Cafe du Qvondeyz"
+ # restaurant_reviews.reviews.first.last[1].business_name.should == "Joselito's Mexican Food"
+ # end
+ # end
end
end
View
2  test/helper.rb
@@ -15,7 +15,7 @@
# Set the default allow_net_connect option--usually you'll want this off.
# You don't usually want your test suite to make HTTP connections, do you?
-FakeWeb.allow_net_connect = false
+# FakeWeb.allow_net_connect = false
class Test::Unit::TestCase
end
Please sign in to comment.
Something went wrong with that request. Please try again.