yelpster 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +124 -0
- data/LICENSE.txt +504 -0
- data/Manifest +32 -0
- data/README.rdoc +199 -0
- data/Rakefile +19 -0
- data/TODO.txt +6 -0
- data/lib/yelpster/client.rb +105 -0
- data/lib/yelpster/record.rb +16 -0
- data/lib/yelpster/response_format.rb +36 -0
- data/lib/yelpster/v1/neighborhood/request/base.rb +15 -0
- data/lib/yelpster/v1/neighborhood/request/geo_point.rb +25 -0
- data/lib/yelpster/v1/neighborhood/request/location.rb +55 -0
- data/lib/yelpster/v1/phone/request/number.rb +26 -0
- data/lib/yelpster/v1/request.rb +55 -0
- data/lib/yelpster/v1/review/request/base.rb +33 -0
- data/lib/yelpster/v1/review/request/bounding_box.rb +39 -0
- data/lib/yelpster/v1/review/request/geo_point.rb +30 -0
- data/lib/yelpster/v1/review/request/location.rb +65 -0
- data/lib/yelpster/v2/business/request/id.rb +19 -0
- data/lib/yelpster/v2/request.rb +56 -0
- data/lib/yelpster/v2/search/request/base.rb +68 -0
- data/lib/yelpster/v2/search/request/bounding_box.rb +30 -0
- data/lib/yelpster/v2/search/request/geo_point.rb +54 -0
- data/lib/yelpster/v2/search/request/location.rb +76 -0
- data/lib/yelpster.rb +24 -0
- data/test/test_business_retrieve.rb +27 -0
- data/test/test_business_search.rb +73 -0
- data/test/test_client.rb +11 -0
- data/test/test_neighborhood_search.rb +46 -0
- data/test/test_phone_search.rb +20 -0
- data/test/test_review_search.rb +168 -0
- data/test/yelp_helper.rb +74 -0
- data/yelpster.gemspec +38 -0
- data.tar.gz.sig +3 -0
- metadata +164 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'yelpster/v1/review/request/base'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V1
|
5
|
+
module Review
|
6
|
+
module Request
|
7
|
+
# Describes a request to search for business reviews near a specific
|
8
|
+
# address/location. You do not need to specify all of the address
|
9
|
+
# attributes -- some subset of the core +address+, +city+,
|
10
|
+
# +neighborhood+, +state+ and +zipcode+ will suffice.
|
11
|
+
#
|
12
|
+
class Location < Yelp::V1::Review::Request::Base
|
13
|
+
# the street address of the location sought
|
14
|
+
attr_reader :address
|
15
|
+
|
16
|
+
# the city of the location sought
|
17
|
+
attr_reader :city
|
18
|
+
|
19
|
+
# the neighborhood of the location sought
|
20
|
+
attr_reader :neighborhood
|
21
|
+
|
22
|
+
# radius to use while searching around specified geo-point.
|
23
|
+
# default value is 1, maximum value is 25.
|
24
|
+
attr_reader :radius
|
25
|
+
|
26
|
+
# the state of the location sought
|
27
|
+
attr_reader :state
|
28
|
+
|
29
|
+
# the zipcode of the location sought
|
30
|
+
attr_reader :zipcode
|
31
|
+
|
32
|
+
def initialize (params)
|
33
|
+
# we explicitly initialize the location fields since we reference
|
34
|
+
# them later when building a full location string and we want
|
35
|
+
# to know they were initialized properly (and avoid warnings)
|
36
|
+
super({
|
37
|
+
:address => nil,
|
38
|
+
:city => nil,
|
39
|
+
:neighborhood => nil,
|
40
|
+
:state => nil,
|
41
|
+
:zipcode => nil
|
42
|
+
}.merge(params))
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_yelp_params
|
46
|
+
super.merge(:location => build_location_string,
|
47
|
+
:radius => radius)
|
48
|
+
end
|
49
|
+
|
50
|
+
protected
|
51
|
+
|
52
|
+
# Returns the Yelp-compatible concatenated string with the various
|
53
|
+
# possible bits of an address-oriented location.
|
54
|
+
#
|
55
|
+
def build_location_string
|
56
|
+
# per the Yelp documentation, the location string is to be built
|
57
|
+
# as some combination of "address, neighborhood, city, state, or
|
58
|
+
# zip".
|
59
|
+
[ @address, @neighborhood, @city, @state, @zipcode ].compact.join(" ")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'yelpster/v2/request'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V2
|
5
|
+
module Business
|
6
|
+
module Request
|
7
|
+
class Id < Yelp::V2::Request
|
8
|
+
# the alphanumeric id of the business to search for as provided by yelp,
|
9
|
+
# eg: 'pjb2WMwa0AfK3L-dWimO8w'
|
10
|
+
attr_reader :yelp_business_id
|
11
|
+
|
12
|
+
def base_url
|
13
|
+
'http://api.yelp.com/v2/business/'+yelp_business_id
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'yelpster/record'
|
2
|
+
require 'oauth'
|
3
|
+
|
4
|
+
class Yelp
|
5
|
+
module V2
|
6
|
+
class Request < Yelp::Record
|
7
|
+
# specifies whether the response content should be transmitted
|
8
|
+
# over the wire compressed, defaulting to true.
|
9
|
+
attr_reader :compress_response
|
10
|
+
|
11
|
+
# one of the Yelp::ResponseFormat format specifiers detailing the
|
12
|
+
# desired format of the search results, defaulting to
|
13
|
+
# Yelp::ResponseFormat::JSON_TO_RUBY.
|
14
|
+
attr_reader :response_format
|
15
|
+
|
16
|
+
# the Yelp consumer_key, consumer_secret, token, token_secret to be passed with the request for
|
17
|
+
# authentication purposes. See http://www.yelp.com/developers/getting_started/api_access
|
18
|
+
# to get your own.
|
19
|
+
attr_reader :consumer_key
|
20
|
+
attr_reader :consumer_secret
|
21
|
+
attr_reader :token
|
22
|
+
attr_reader :token_secret
|
23
|
+
|
24
|
+
alias :compress_response? :compress_response
|
25
|
+
|
26
|
+
def initialize (params)
|
27
|
+
default_params = {
|
28
|
+
:compress_response => true,
|
29
|
+
:response_format => Yelp::ResponseFormat::JSON_TO_RUBY
|
30
|
+
}
|
31
|
+
super(default_params.merge(params))
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_yelp_params
|
35
|
+
params = {}
|
36
|
+
|
37
|
+
# if they specified anything other than a json variant, we
|
38
|
+
# need to tell yelp what we're looking for
|
39
|
+
case @response_format
|
40
|
+
when Yelp::ResponseFormat::PICKLE
|
41
|
+
params[:output] = 'pickle'
|
42
|
+
when Yelp::ResponseFormat::PHP
|
43
|
+
params[:output] = 'php'
|
44
|
+
end
|
45
|
+
|
46
|
+
params
|
47
|
+
end
|
48
|
+
|
49
|
+
def pull_results (url, http_params)
|
50
|
+
consumer = OAuth::Consumer.new(consumer_key, consumer_secret, {:site => "http://api.yelp.com"})
|
51
|
+
access_token = OAuth::AccessToken.new(consumer, token, token_secret)
|
52
|
+
access_token.get(url).body
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'yelpster/v2/request'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V2
|
5
|
+
module Search
|
6
|
+
module Request
|
7
|
+
class Base < Yelp::V2::Request
|
8
|
+
#------------------------General Search Params -----------------
|
9
|
+
# string representing the name of business or search term being
|
10
|
+
#requested.
|
11
|
+
attr_reader :term
|
12
|
+
|
13
|
+
# integer representing number of business results to return
|
14
|
+
attr_reader :limit
|
15
|
+
|
16
|
+
# integer representing number of results to skip (for pagination)
|
17
|
+
attr_reader :offset
|
18
|
+
|
19
|
+
# integer for specifying how to sort results
|
20
|
+
# Sort Mode:
|
21
|
+
# 0 = Best matched (default)
|
22
|
+
# 1 = Distance
|
23
|
+
# 2 = Highest rated
|
24
|
+
# see www.yelp.com/developers/documentation/v2/search_api for more info
|
25
|
+
attr_reader :sort
|
26
|
+
|
27
|
+
# string specifying which business category to search in
|
28
|
+
# see www.yelp.com/developers/documentation/category_list for list of
|
29
|
+
# categories
|
30
|
+
attr_reader :category_filter
|
31
|
+
|
32
|
+
# integer specifying the search radius in meters
|
33
|
+
attr_reader :radius_filter
|
34
|
+
|
35
|
+
# boolean representing if business has claimed location
|
36
|
+
# not implemented by yelp as of 13-8-2011
|
37
|
+
attr_reader :claimed_filter
|
38
|
+
#---------------------------------------------------------------
|
39
|
+
|
40
|
+
#--------------------------- Locale Params ---------------------
|
41
|
+
# string representing default country to use while parsing location field
|
42
|
+
attr_reader :cc
|
43
|
+
|
44
|
+
# string representing which language of reviews to return
|
45
|
+
attr_reader :lang
|
46
|
+
#---------------------------------------------------------------
|
47
|
+
|
48
|
+
def base_url
|
49
|
+
'http://api.yelp.com/v2/search'
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_yelp_params
|
53
|
+
super.merge(:term => term,
|
54
|
+
:limit => limit,
|
55
|
+
:offset => offset,
|
56
|
+
:sort => sort,
|
57
|
+
:category_filter => category_filter,
|
58
|
+
:radius_filter => radius_filter,
|
59
|
+
:claimed_filter => claimed_filter,
|
60
|
+
|
61
|
+
:cc => cc,
|
62
|
+
:lang => lang)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'yelpster/v2/search/request/base'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V2
|
5
|
+
module Search
|
6
|
+
module Request
|
7
|
+
# Describes a request to search for businesses
|
8
|
+
# within a geo-point-specific bounding box
|
9
|
+
#
|
10
|
+
class BoundingBox < Yelp::V2::Search::Request::Base
|
11
|
+
# REQUIRED - double, bottom right latitude of bounding box (SOUTH-WEST LAT)
|
12
|
+
attr_reader :sw_latitude
|
13
|
+
|
14
|
+
# REQUIRED - double, bottom right longitude of bounding box (SOUTH-WEST LONG)
|
15
|
+
attr_reader :sw_longitude
|
16
|
+
|
17
|
+
# REQUIRED - double, top left latitude of bounding box (NORTH-EAST LAT)
|
18
|
+
attr_reader :ne_latitude
|
19
|
+
|
20
|
+
# REQUIRED - double, top left longitude of bounding box (NORTH-EAST LONG)
|
21
|
+
attr_reader :ne_longitude
|
22
|
+
|
23
|
+
def to_yelp_params
|
24
|
+
super.merge(:bounds => "#{sw_latitude},#{sw_longitude}|#{ne_latitude},#{ne_longitude}")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'yelpster/v2/search/request/base'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V2
|
5
|
+
module Search
|
6
|
+
module Request
|
7
|
+
# Describes a request to search for the name of a neighborhood at a
|
8
|
+
# specific geo-point location.
|
9
|
+
#
|
10
|
+
class GeoPoint < Yelp::V2::Search::Request::Base
|
11
|
+
# REQUIRED - double, latitude of geo-point to search
|
12
|
+
attr_reader :latitude
|
13
|
+
|
14
|
+
# REQUIRED - double, longitude of geo-point to search
|
15
|
+
attr_reader :longitude
|
16
|
+
|
17
|
+
# OPTIONAL - double, accuracy of latitude and longitude of geo-point to search
|
18
|
+
attr_reader :accuracy
|
19
|
+
|
20
|
+
# OPTIONAL - double, altitude of geo-point to search
|
21
|
+
attr_reader :altitude
|
22
|
+
|
23
|
+
# OPTIONAL - double, accuracy of altitude geo-point to search
|
24
|
+
attr_reader :altitude_accuracy
|
25
|
+
|
26
|
+
def initialize(params)
|
27
|
+
# we explicitly initialize the location fields since we reference
|
28
|
+
# them later when building a full location string and we want
|
29
|
+
# to know they were initialized properly (and avoid warnings)
|
30
|
+
# 50 and -100 default values are provided as they lie within yelp API's geo-location range
|
31
|
+
super({
|
32
|
+
:latitude => 50.0,
|
33
|
+
:longitude => -100.0,
|
34
|
+
:accuracy => nil,
|
35
|
+
:altitude => nil,
|
36
|
+
:altitude_accuracy => nil
|
37
|
+
}.merge(params))
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_yelp_params
|
41
|
+
super.merge(:ll => build_geo_loc_string)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns the Yelp-compatible concatenated string with the various
|
45
|
+
# possible bits of an address-oriented location.
|
46
|
+
#
|
47
|
+
def build_geo_loc_string
|
48
|
+
[ @latitude, @longitude, @accuracy, @altitude, @altitude_accuracy ].compact.join(",")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'yelpster/v2/search/request/base'
|
2
|
+
|
3
|
+
class Yelp
|
4
|
+
module V2
|
5
|
+
module Search
|
6
|
+
module Request
|
7
|
+
# Describes a request to search for a businesses by a
|
8
|
+
# address/location. You do not need to specify all of the address
|
9
|
+
# attributes -- some subset of the core
|
10
|
+
# address, neighborhood, city, state or zip, optional country
|
11
|
+
#
|
12
|
+
class Location < Yelp::V2::Search::Request::Base
|
13
|
+
# NOTE: At least one of address, neighborhood, city, state,
|
14
|
+
# zipcode or country must be specified
|
15
|
+
|
16
|
+
# string representing the street address of the location sought
|
17
|
+
attr_reader :address
|
18
|
+
|
19
|
+
# string representing the neighborhood of the location sought
|
20
|
+
attr_reader :neighborhood
|
21
|
+
|
22
|
+
# string representing the city of the location sought
|
23
|
+
attr_reader :city
|
24
|
+
|
25
|
+
# string representing the state of the location sought
|
26
|
+
attr_reader :state
|
27
|
+
|
28
|
+
# string representing the zipcode of the location sought
|
29
|
+
attr_reader :zipcode
|
30
|
+
|
31
|
+
# string representing the country of the location sought
|
32
|
+
attr_reader :country
|
33
|
+
|
34
|
+
# additional attributes that can be specified = latitude + longitude
|
35
|
+
attr_reader :latitude
|
36
|
+
attr_reader :longitude
|
37
|
+
|
38
|
+
def initialize (params)
|
39
|
+
# we explicitly initialize the location fields since we reference
|
40
|
+
# them later when building a full location string and we want
|
41
|
+
# to know they were initialized properly (and avoid warnings)
|
42
|
+
super({ :address => nil,
|
43
|
+
:neighborhood => nil,
|
44
|
+
:city => nil,
|
45
|
+
:state => nil,
|
46
|
+
:zipcode => nil,
|
47
|
+
:country => nil,
|
48
|
+
:latitude => nil,
|
49
|
+
:longitude => nil
|
50
|
+
}.merge(params))
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_yelp_params
|
54
|
+
super.merge(:location => build_location_string,
|
55
|
+
:cll => build_geo_location_string)
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
# Returns the Yelp-compatible concatenated string with the various
|
61
|
+
# possible bits of an address-oriented location.
|
62
|
+
#
|
63
|
+
def build_location_string
|
64
|
+
# per the Yelp documentation, the location string is to be built
|
65
|
+
# as some combination of "address, neighborhood, city, state, or zip, country".
|
66
|
+
[ @address, @neighborhood, @city, @state, @zipcode, @country ].compact.join(" ")
|
67
|
+
end
|
68
|
+
|
69
|
+
def build_geo_location_string
|
70
|
+
[ @latitude, @longitude ].collect{|var| var || 0}.join(",")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/lib/yelpster.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'yelpster/client'
|
2
|
+
require 'yelpster/record'
|
3
|
+
require 'yelpster/response_format'
|
4
|
+
#-----------------V1---------------------------
|
5
|
+
require 'yelpster/v1/request'
|
6
|
+
require 'yelpster/v1/neighborhood/request/base'
|
7
|
+
require 'yelpster/v1/neighborhood/request/geo_point'
|
8
|
+
require 'yelpster/v1/neighborhood/request/location'
|
9
|
+
require 'yelpster/v1/phone/request/number'
|
10
|
+
require 'yelpster/v1/review/request/base'
|
11
|
+
require 'yelpster/v1/review/request/bounding_box'
|
12
|
+
require 'yelpster/v1/review/request/geo_point'
|
13
|
+
require 'yelpster/v1/review/request/location'
|
14
|
+
#----------------V2----------------------------
|
15
|
+
require 'yelpster/v2/request'
|
16
|
+
require 'yelpster/v2/business/request/id'
|
17
|
+
require 'yelpster/v2/search/request/base'
|
18
|
+
require 'yelpster/v2/search/request/geo_point'
|
19
|
+
require 'yelpster/v2/search/request/bounding_box'
|
20
|
+
require 'yelpster/v2/search/request/location'
|
21
|
+
|
22
|
+
class Yelp
|
23
|
+
VERSION = '1.1.1'
|
24
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'yelpster'
|
4
|
+
|
5
|
+
require File.dirname(__FILE__) + '/yelp_helper'
|
6
|
+
|
7
|
+
class TestBusinessRetrieve < Test::Unit::TestCase
|
8
|
+
include YelpHelper
|
9
|
+
|
10
|
+
def setup
|
11
|
+
create_client YelpHelper::API_V2
|
12
|
+
end
|
13
|
+
|
14
|
+
CHOCOLATE_SF_ID = 'chocolate-san-francisco'
|
15
|
+
|
16
|
+
def test_id_retrieval
|
17
|
+
request = Yelp::V2::Business::Request::Id.new(
|
18
|
+
:yelp_business_id => "pjb2WMwa0AfK3L-dWimO8w",
|
19
|
+
:consumer_key => @consumer_key,
|
20
|
+
:consumer_secret => @consumer_secret,
|
21
|
+
:token => @token,
|
22
|
+
:token_secret => @token_secret)
|
23
|
+
response = @client.search(request)
|
24
|
+
validate_json_to_ruby_business(response)
|
25
|
+
assert_equal response['id'], CHOCOLATE_SF_ID
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'yelpster'
|
4
|
+
require File.dirname(__FILE__) + '/yelp_helper'
|
5
|
+
|
6
|
+
class TestBusinessSearch < Test::Unit::TestCase
|
7
|
+
include YelpHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
create_client YelpHelper::API_V2
|
11
|
+
end
|
12
|
+
|
13
|
+
BUSINESS_LAT = 37.782303
|
14
|
+
BUSINESS_LON = -122.484101
|
15
|
+
BUSINESS_LOCATION = {
|
16
|
+
"cross_streets"=>"24th Ave & 25th Ave",
|
17
|
+
"city"=>"San Francisco",
|
18
|
+
"display_address"=>["2308 Clement St", "(b/t 24th Ave & 25th Ave)", "Outer Richmond", "San Francisco, CA 94121"],
|
19
|
+
"geo_accuracy"=>8,
|
20
|
+
"neighborhoods"=>["Outer Richmond"],
|
21
|
+
"postal_code"=>"94121",
|
22
|
+
"country_code"=>"US",
|
23
|
+
"address"=>["2308 Clement St"],
|
24
|
+
"coordinate"=>{"latitude"=>37.782303, "longitude"=>-122.484101},
|
25
|
+
"state_code"=>"CA"
|
26
|
+
}
|
27
|
+
|
28
|
+
def test_bounding_box_search
|
29
|
+
request = Yelp::V2::Search::Request::BoundingBox.new(
|
30
|
+
:sw_latitude => 37.9,
|
31
|
+
:sw_longitude => -122.5,
|
32
|
+
:ne_latitude => 37.788022,
|
33
|
+
:ne_longitude => -122.399797,
|
34
|
+
# :radius => 1,
|
35
|
+
# :business_count => 3,
|
36
|
+
:term => 'yelp',
|
37
|
+
:consumer_key => @consumer_key,
|
38
|
+
:consumer_secret => @consumer_secret,
|
39
|
+
:token => @token,
|
40
|
+
:token_secret => @token_secret)
|
41
|
+
response = @client.search(request)
|
42
|
+
validate_json_to_ruby_response(response)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_geo_point_search
|
46
|
+
request = Yelp::V2::Search::Request::GeoPoint.new(:latitude => BUSINESS_LAT,
|
47
|
+
:longitude => BUSINESS_LON,
|
48
|
+
:consumer_key => @consumer_key,
|
49
|
+
:consumer_secret => @consumer_secret,
|
50
|
+
:token => @token,
|
51
|
+
:token_secret => @token_secret)
|
52
|
+
response = @client.search(request)
|
53
|
+
validate_json_to_ruby_response(response)
|
54
|
+
assert_equal response['businesses'].first["location"], BUSINESS_LOCATION
|
55
|
+
end
|
56
|
+
|
57
|
+
BUSINESS_ADDRESS = '2308 Clement St'
|
58
|
+
|
59
|
+
def test_location_search
|
60
|
+
request = Yelp::V2::Search::Request::Location.new(:address => BUSINESS_ADDRESS,
|
61
|
+
:city => 'San Francisco',
|
62
|
+
:state => 'CA',
|
63
|
+
:zipcode => 94121,
|
64
|
+
:consumer_key => @consumer_key,
|
65
|
+
:consumer_secret => @consumer_secret,
|
66
|
+
:token => @token,
|
67
|
+
:token_secret => @token_secret)
|
68
|
+
response = @client.search(request)
|
69
|
+
validate_json_to_ruby_response(response)
|
70
|
+
assert_equal response['businesses'].first['location'], BUSINESS_LOCATION
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
data/test/test_client.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'yelpster'
|
4
|
+
require File.dirname(__FILE__) + '/yelp_helper'
|
5
|
+
|
6
|
+
class TestNeighborhoodSearch < Test::Unit::TestCase
|
7
|
+
include YelpHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
create_client YelpHelper::API_V1
|
11
|
+
end
|
12
|
+
|
13
|
+
GORDO_LAT = 37.782093
|
14
|
+
GORDO_LON = -122.483230
|
15
|
+
GORDO_NEIGHBORHOOD = {
|
16
|
+
"city" => "San Francisco",
|
17
|
+
"name" => "Outer Richmond",
|
18
|
+
"country_code" => "US",
|
19
|
+
"country" => "USA",
|
20
|
+
"borough" => "",
|
21
|
+
"url" => "http://www.yelp.com/search?find_loc=Outer+Richmond%2C+San+Francisco%2C+CA%2C+USA",
|
22
|
+
"state" => "CA",
|
23
|
+
"state_code" => "CA" }
|
24
|
+
|
25
|
+
def test_geo_point_search
|
26
|
+
request = Yelp::V1::Neighborhood::Request::GeoPoint.new(:latitude => GORDO_LAT,
|
27
|
+
:longitude => GORDO_LON,
|
28
|
+
:yws_id => @yws_id)
|
29
|
+
response = @client.search(request)
|
30
|
+
validate_json_to_ruby_response(response)
|
31
|
+
assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
|
32
|
+
end
|
33
|
+
|
34
|
+
GORDO_ADDRESS = '2252 Clement Street'
|
35
|
+
|
36
|
+
def test_location_search
|
37
|
+
request = Yelp::V1::Neighborhood::Request::Location.new(:address => GORDO_ADDRESS,
|
38
|
+
:city => 'San Francisco',
|
39
|
+
:state => 'CA',
|
40
|
+
:zipcode => 94121,
|
41
|
+
:yws_id => @yws_id)
|
42
|
+
response = @client.search(request)
|
43
|
+
validate_json_to_ruby_response(response)
|
44
|
+
assert_equal response['neighborhoods'].first, GORDO_NEIGHBORHOOD
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'yelpster'
|
4
|
+
require File.dirname(__FILE__) + '/yelp_helper'
|
5
|
+
|
6
|
+
class TestPhoneSearch < Test::Unit::TestCase
|
7
|
+
include YelpHelper
|
8
|
+
|
9
|
+
def setup
|
10
|
+
create_client YelpHelper::API_V1
|
11
|
+
end
|
12
|
+
|
13
|
+
GORDO_PHONE_NUMBER = '4155666011'
|
14
|
+
|
15
|
+
def test_phone_search
|
16
|
+
request = Yelp::V1::Phone::Request::Number.new(:phone_number => GORDO_PHONE_NUMBER, :yws_id => @yws_id)
|
17
|
+
response = @client.search(request)
|
18
|
+
validate_json_to_ruby_response(response)
|
19
|
+
end
|
20
|
+
end
|