yelp 2.0.4 → 2.0.5
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-env.example +6 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/README.md +30 -1
- data/lib/yelp/burst_struct.rb +4 -0
- data/lib/yelp/client.rb +3 -1
- data/lib/yelp/endpoint/phone_search.rb +50 -0
- data/lib/yelp/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/phone_search.yml +70 -0
- data/spec/yelp/endpoint/phone_search_spec.rb +29 -0
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1d0b8a50232bec3fb20980bc176371381a8735c
|
4
|
+
data.tar.gz: 3fc892f1df95d2380342a4fe31f885d4c84aef96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ec51e7ff94f62a2e9ac2b7fa7fa2e6042c516a6f2e2a6e44baaa6927342608a3ac428aeabc23da196e2f0b353adaf1b23804e77c4abb71d80f3f8d95f983b4
|
7
|
+
data.tar.gz: 30a2d55c47ff8a3eef8849132426c1459bcce8db2ca6b207e59b202c197c19778eb85b1a8f6424fdad6e39c643942e5db13d9e8747d1e30abb4e3e6d6ee9f4c9
|
data/.gitignore
CHANGED
data/.ruby-env.example
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Replace <THESE_VALUES> with yours from
|
2
|
+
# https://www.yelp.com/developers/manage_api_keys (don't include <brackets>).
|
3
|
+
YELP_CONSUMER_KEY=<YOUR_YELP_CONSUMER_KEY>
|
4
|
+
YELP_CONSUMER_SECRET=<YOUR_YELP_CONSUMER_SECRET>
|
5
|
+
YELP_TOKEN=<YOUR_YELP_TOKEN>
|
6
|
+
YELP_TOKEN_SECRET=<YOUR_YELP_TOKEN_SECRET>
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
yelp-ruby
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.5
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# yelp-ruby
|
2
2
|
|
3
|
-
[](http://badge.fury.io/rb/yelp) [](https://travis-ci.org/Yelp/yelp-ruby) [](http://badge.fury.io/rb/yelp) [](https://travis-ci.org/Yelp/yelp-ruby) [](https://codeclimate.com/github/Yelp/yelp-ruby)
|
4
4
|
|
5
5
|
This is a Ruby Gem for the Yelp API. It'll simplify the process of consuming data from the Yelp API for developers using Ruby. The library encompasses both Search and Business API functions.
|
6
6
|
|
@@ -106,6 +106,22 @@ locale = { lang: 'fr' }
|
|
106
106
|
client.business('yelp-san-francisco', locale)
|
107
107
|
```
|
108
108
|
|
109
|
+
### [Phone Search API](http://www.yelp.com/developers/documentation/v2/phone_search)
|
110
|
+
|
111
|
+
To use the Phone Search API after you have a client you just need to call ``#phone_search`` with a phone number
|
112
|
+
|
113
|
+
```
|
114
|
+
client.phone_search('+15555555555')
|
115
|
+
```
|
116
|
+
|
117
|
+
You can pass in country code information as well
|
118
|
+
|
119
|
+
```
|
120
|
+
options = { cc: 'US', category: 'fashion' }
|
121
|
+
|
122
|
+
client.phone_search('5555555555', options)
|
123
|
+
```
|
124
|
+
|
109
125
|
## Responses
|
110
126
|
|
111
127
|
Responses from the API are all parsed and converted into Ruby objects. You're able to access information using dot-notation
|
@@ -144,6 +160,19 @@ For specific response values check out the docs for the [search api](http://www.
|
|
144
160
|
4. Push to the branch (`git push origin my-new-feature`)
|
145
161
|
5. Create new Pull Request
|
146
162
|
|
163
|
+
Our rspec test suite expects environment variables to be populated with your Yelp API Access Tokens. If you use RVM, you could create a `.ruby-env` file in the repo root with contents like:
|
164
|
+
|
165
|
+
```
|
166
|
+
YELP_CONSUMER_KEY=<YOUR_YELP_CONSUMER_KEY>
|
167
|
+
YELP_CONSUMER_SECRET=<YOUR_YELP_CONSUMER_SECRET>
|
168
|
+
YELP_TOKEN=<YOUR_YELP_TOKEN>
|
169
|
+
YELP_TOKEN_SECRET=<YOUR_YELP_TOKEN_SECRET>
|
170
|
+
```
|
171
|
+
|
172
|
+
You can generate and find your Access Tokens at [https://www.yelp.com/developers/manage_api_keys](https://www.yelp.com/developers/manage_api_keys).
|
173
|
+
|
174
|
+
(We've included `.ruby-env.example` to get you started. Be careful to remove the `.example`.)
|
175
|
+
|
147
176
|
### Git Workflow
|
148
177
|
|
149
178
|
We are using the [git flow](http://nvie.com/posts/a-successful-git-branching-model/)
|
data/lib/yelp/burst_struct.rb
CHANGED
data/lib/yelp/client.rb
CHANGED
@@ -5,13 +5,15 @@ require 'yelp/burst_struct'
|
|
5
5
|
require 'yelp/configuration'
|
6
6
|
require 'yelp/error'
|
7
7
|
require 'yelp/endpoint/business'
|
8
|
+
require 'yelp/endpoint/phone_search'
|
8
9
|
require 'yelp/endpoint/search'
|
9
10
|
|
10
11
|
module Yelp
|
11
12
|
class Client
|
12
13
|
API_HOST = 'http://api.yelp.com'
|
13
14
|
REQUEST_CLASSES = [ Yelp::Endpoint::Search,
|
14
|
-
Yelp::Endpoint::Business
|
15
|
+
Yelp::Endpoint::Business,
|
16
|
+
Yelp::Endpoint::PhoneSearch]
|
15
17
|
|
16
18
|
attr_reader :configuration
|
17
19
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Yelp
|
4
|
+
module Endpoint
|
5
|
+
class PhoneSearch
|
6
|
+
PATH = '/v2/phone_search/'
|
7
|
+
|
8
|
+
def initialize(client)
|
9
|
+
@client = client
|
10
|
+
end
|
11
|
+
|
12
|
+
# Make a request to the business endpoint on the API
|
13
|
+
#
|
14
|
+
# @param phone_number [String] the phone number
|
15
|
+
# @return [BurstStruct::Burst] a parsed object of the response. For a complete
|
16
|
+
# sample response visit:
|
17
|
+
# http://www.yelp.com/developers/documentation/v2/phone_search#sampleResponse
|
18
|
+
#
|
19
|
+
# @example Search for business with params and locale
|
20
|
+
# options = { code: 'US',
|
21
|
+
# category: 'localflavor' }
|
22
|
+
#
|
23
|
+
# response = client.phone_search('+14159083801', options)
|
24
|
+
# response.businesses # [<Business 1>, <Business 2>, <Business 3>]
|
25
|
+
# response.businesses[0].name # 'Yelp'
|
26
|
+
#
|
27
|
+
def phone_search(phone, options={})
|
28
|
+
params = {phone: phone}
|
29
|
+
params.merge!(options)
|
30
|
+
BurstStruct::Burst.new(JSON.parse(phone_search_request(params).body))
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# Make a request to the business endpoint of the API
|
36
|
+
# The endpoint requires a format of /v2/business/{business-id}
|
37
|
+
# so the primary request parameter is concatenated. After getting
|
38
|
+
# the response back it's checked to see if there are any API errors
|
39
|
+
# and raises the relevant one if there is.
|
40
|
+
#
|
41
|
+
# @param params [Hash] a hash of options for phone search
|
42
|
+
# @return [Faraday::Response] the raw response back from the connection
|
43
|
+
def phone_search_request(params)
|
44
|
+
result = @client.connection.get PATH, params
|
45
|
+
Error.check_for_error(result)
|
46
|
+
result
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/yelp/version.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://api.yelp.com/v2/phone_search/?category=localflavor&code=US&phone=%2B14159083801
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.1
|
12
|
+
Authorization:
|
13
|
+
- OAuth oauth_consumer_key="<YELP_CONSUMER_KEY>", oauth_nonce="ea69a813193ba6e5948fe4d6f7b96042",
|
14
|
+
oauth_signature="ukchha88%2Bsm6WWpiEAV8VbgIpYQ%3D", oauth_signature_method="HMAC-SHA1",
|
15
|
+
oauth_timestamp="1425778113", oauth_token="<YELP_TOKEN>", oauth_version="1.0"
|
16
|
+
Accept-Encoding:
|
17
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
18
|
+
Accept:
|
19
|
+
- "*/*"
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Sun, 08 Mar 2015 01:28:33 GMT
|
27
|
+
Server:
|
28
|
+
- Apache
|
29
|
+
X-Node:
|
30
|
+
- web102-r10-sfo2, api_com
|
31
|
+
Cache-Control:
|
32
|
+
- private
|
33
|
+
Set-Cookie:
|
34
|
+
- bse=3b7f48757900b68e51e2bb458656fc4b; Domain=.yelp.com; Path=/; HttpOnly
|
35
|
+
- yuv=Qj3YntiY6H9KR_Is0c63LJkIKjm9hzLLtk-_wgcaU2tHsmQutDrD7AVd-znxMnXQZjKafm3v7f6eQjklhSsif2P4XCLNSJHR;
|
36
|
+
Domain=.yelp.com; Max-Age=630720000; Path=/; expires=Sat, 03-Mar-2035 01:28:33
|
37
|
+
GMT
|
38
|
+
Content-Length:
|
39
|
+
- '1566'
|
40
|
+
Vary:
|
41
|
+
- User-Agent
|
42
|
+
Content-Type:
|
43
|
+
- application/json; charset=UTF-8
|
44
|
+
X-Mode:
|
45
|
+
- ro
|
46
|
+
X-Proxied:
|
47
|
+
- extlb1-r4-sfo2
|
48
|
+
body:
|
49
|
+
encoding: UTF-8
|
50
|
+
string: '{"region": null, "total": 1, "businesses": [{"is_claimed": true, "rating":
|
51
|
+
2.5, "mobile_url": "http://m.yelp.com/biz/yelp-san-francisco", "rating_img_url":
|
52
|
+
"http://s3-media4.fl.yelpcdn.com/assets/2/www/img/c7fb9aff59f9/ico/stars/v1/stars_2_half.png",
|
53
|
+
"review_count": 6827, "name": "Yelp", "snippet_image_url": "http://s3-media2.fl.yelpcdn.com/photo/IAgMHI6d24hklODg294Ejw/ms.jpg",
|
54
|
+
"rating_img_url_small": "http://s3-media4.fl.yelpcdn.com/assets/2/www/img/8e8633e5f8f0/ico/stars/v1/stars_small_2_half.png",
|
55
|
+
"url": "http://www.yelp.com/biz/yelp-san-francisco", "phone": "+14159083801",
|
56
|
+
"snippet_text": "I have been called a dumb bitch through business messaging...
|
57
|
+
I have been harassed, cussed a blue streak and stalked for telling the truth
|
58
|
+
and calling...", "image_url": "http://s3-media2.fl.yelpcdn.com/bphoto/EHCfkEpZraIfPl8gvCo1tg/ms.jpg",
|
59
|
+
"categories": [["Local Flavor", "localflavor"], ["Mass Media", "massmedia"]],
|
60
|
+
"display_phone": "+1-415-908-3801", "rating_img_url_large": "http://s3-media2.fl.yelpcdn.com/assets/2/www/img/d63e3add9901/ico/stars/v1/stars_large_2_half.png",
|
61
|
+
"id": "yelp-san-francisco", "is_closed": false, "location": {"cross_streets":
|
62
|
+
"Natoma St \u0026 Minna St", "city": "San Francisco", "display_address": ["140
|
63
|
+
New Montgomery St", "Financial District", "San Francisco, CA 94105"], "geo_accuracy":
|
64
|
+
9.5, "neighborhoods": ["Financial District", "SoMa"], "postal_code": "94105",
|
65
|
+
"country_code": "US", "address": ["140 New Montgomery St"], "coordinate":
|
66
|
+
{"latitude": 37.786770336292903, "longitude": -122.39995837211499}, "state_code":
|
67
|
+
"CA"}}]}'
|
68
|
+
http_version:
|
69
|
+
recorded_at: Sun, 08 Mar 2015 01:28:33 GMT
|
70
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Yelp::Endpoint::PhoneSearch do
|
4
|
+
include_context 'shared configuration'
|
5
|
+
|
6
|
+
let(:api_keys) { real_api_keys }
|
7
|
+
let(:phone) { '+14159083801' }
|
8
|
+
let(:options) { { code: 'US', category: 'localflavor' } }
|
9
|
+
let(:client) { Yelp::Client.new(api_keys) }
|
10
|
+
|
11
|
+
describe '#phone_search' do
|
12
|
+
subject(:results) {
|
13
|
+
VCR.use_cassette('phone_search') do
|
14
|
+
client.phone_search(phone, options)
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
it { should be_a(BurstStruct::Burst) }
|
19
|
+
it 'should get results' do
|
20
|
+
expect(results.businesses.size).to be > 0
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe 'errors' do
|
25
|
+
it_behaves_like 'a request error' do
|
26
|
+
let(:request) { client.phone_search(phone) }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomer Elmalem
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -223,6 +223,9 @@ extensions: []
|
|
223
223
|
extra_rdoc_files: []
|
224
224
|
files:
|
225
225
|
- ".gitignore"
|
226
|
+
- ".ruby-env.example"
|
227
|
+
- ".ruby-gemset"
|
228
|
+
- ".ruby-version"
|
226
229
|
- ".travis.yml"
|
227
230
|
- Gemfile
|
228
231
|
- LICENSE.txt
|
@@ -233,10 +236,12 @@ files:
|
|
233
236
|
- lib/yelp/client.rb
|
234
237
|
- lib/yelp/configuration.rb
|
235
238
|
- lib/yelp/endpoint/business.rb
|
239
|
+
- lib/yelp/endpoint/phone_search.rb
|
236
240
|
- lib/yelp/endpoint/search.rb
|
237
241
|
- lib/yelp/error.rb
|
238
242
|
- lib/yelp/version.rb
|
239
243
|
- spec/fixtures/vcr_cassettes/business.yml
|
244
|
+
- spec/fixtures/vcr_cassettes/phone_search.yml
|
240
245
|
- spec/fixtures/vcr_cassettes/search.yml
|
241
246
|
- spec/fixtures/vcr_cassettes/search_bounding_box.yml
|
242
247
|
- spec/fixtures/vcr_cassettes/search_by_coordinates.yml
|
@@ -247,6 +252,7 @@ files:
|
|
247
252
|
- spec/yelp/client_spec.rb
|
248
253
|
- spec/yelp/configuration_spec.rb
|
249
254
|
- spec/yelp/endpoint/business_spec.rb
|
255
|
+
- spec/yelp/endpoint/phone_search_spec.rb
|
250
256
|
- spec/yelp/endpoint/search_spec.rb
|
251
257
|
- spec/yelp/error_spec.rb
|
252
258
|
- spec/yelp/yelp_spec.rb
|
@@ -272,12 +278,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
278
|
version: '0'
|
273
279
|
requirements: []
|
274
280
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.
|
281
|
+
rubygems_version: 2.4.5
|
276
282
|
signing_key:
|
277
283
|
specification_version: 4
|
278
284
|
summary: Ruby client library for the Yelp API
|
279
285
|
test_files:
|
280
286
|
- spec/fixtures/vcr_cassettes/business.yml
|
287
|
+
- spec/fixtures/vcr_cassettes/phone_search.yml
|
281
288
|
- spec/fixtures/vcr_cassettes/search.yml
|
282
289
|
- spec/fixtures/vcr_cassettes/search_bounding_box.yml
|
283
290
|
- spec/fixtures/vcr_cassettes/search_by_coordinates.yml
|
@@ -288,7 +295,7 @@ test_files:
|
|
288
295
|
- spec/yelp/client_spec.rb
|
289
296
|
- spec/yelp/configuration_spec.rb
|
290
297
|
- spec/yelp/endpoint/business_spec.rb
|
298
|
+
- spec/yelp/endpoint/phone_search_spec.rb
|
291
299
|
- spec/yelp/endpoint/search_spec.rb
|
292
300
|
- spec/yelp/error_spec.rb
|
293
301
|
- spec/yelp/yelp_spec.rb
|
294
|
-
has_rdoc:
|