yelp-fusion 0.3.pre.beta → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -12
- data/lib/yelp/fusion.rb +4 -1
- data/lib/yelp/fusion/client.rb +10 -4
- data/lib/yelp/fusion/configuration.rb +4 -0
- data/lib/yelp/fusion/endpoint/business.rb +3 -0
- data/lib/yelp/fusion/endpoint/match.rb +5 -2
- data/lib/yelp/fusion/endpoint/phone.rb +4 -1
- data/lib/yelp/fusion/endpoint/review.rb +3 -0
- data/lib/yelp/fusion/endpoint/search.rb +5 -1
- data/lib/yelp/fusion/endpoint/transaction.rb +7 -5
- data/lib/yelp/fusion/error.rb +21 -1
- data/lib/yelp/fusion/responses/base.rb +5 -1
- data/lib/yelp/fusion/responses/business.rb +3 -0
- data/lib/yelp/fusion/responses/match.rb +3 -0
- data/lib/yelp/fusion/responses/models/business.rb +4 -0
- data/lib/yelp/fusion/responses/models/categories.rb +3 -0
- data/lib/yelp/fusion/responses/models/center.rb +3 -0
- data/lib/yelp/fusion/responses/models/hours.rb +3 -0
- data/lib/yelp/fusion/responses/models/location.rb +3 -0
- data/lib/yelp/fusion/responses/models/{openHours.rb → open_hours.rb} +3 -0
- data/lib/yelp/fusion/responses/models/region.rb +3 -0
- data/lib/yelp/fusion/responses/models/reviews.rb +3 -0
- data/lib/yelp/fusion/responses/models/user.rb +3 -0
- data/lib/yelp/fusion/responses/phone.rb +5 -0
- data/lib/yelp/fusion/responses/review.rb +3 -0
- data/lib/yelp/fusion/responses/search.rb +3 -0
- data/lib/yelp/fusion/responses/transaction.rb +3 -0
- data/lib/yelp/fusion/singleton.rb +24 -0
- data/lib/yelp/fusion/version.rb +3 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15dcadbe7c95d940ded727d65c43248f3487d7437b4aa3cfa0b3fd229a880d26
|
4
|
+
data.tar.gz: 2bc14dec923d118e853513c6fcc044fcacdfcd0ea79af9f9899db0d1b899731a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ebdf227d9c0de147b3b058baae15e36ee198e526e61c430a20e33e6c1127ce369efd4b0028c28f6bdaa645060bd2c5ce5f163cc5c899230c12bb0ad22f82df4
|
7
|
+
data.tar.gz: 0c0989eb79de260f877ed2d8f18369092286614d8ecc3af17ffc764c07b3d7f0d163eb1fdb26d55ee4cfc4dfd0637ca56e59e03046e485d7a2d200ce992fda0a
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ Please remember to read and follow the [Terms of Use](https://www.yelp.com/devel
|
|
12
12
|
Add this line to your Rails application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'yelp-fusion'
|
15
|
+
gem 'yelp-fusion'
|
16
16
|
```
|
17
17
|
|
18
18
|
Add this line to your Ruby appliation's Gemfile:
|
@@ -21,8 +21,6 @@ Add this line to your Ruby appliation's Gemfile:
|
|
21
21
|
gem 'yelp-fusion', require: 'yelp/fusion'
|
22
22
|
```
|
23
23
|
|
24
|
-
|
25
|
-
|
26
24
|
And then execute:
|
27
25
|
|
28
26
|
$ bundle
|
@@ -50,7 +48,7 @@ use the gem with Rails, the client should be configured in an initializer.
|
|
50
48
|
```ruby
|
51
49
|
require 'yelp/fusion'
|
52
50
|
|
53
|
-
configuration = Yelp.client.configure do |config|
|
51
|
+
configuration = Yelp::Fusion.client.configure do |config|
|
54
52
|
config.api_key = YOUR_API_KEY
|
55
53
|
end
|
56
54
|
|
@@ -66,18 +64,44 @@ Once you have a client you can use ``#search`` to make a request to the Search A
|
|
66
64
|
client.search('San Francisco')
|
67
65
|
```
|
68
66
|
|
69
|
-
You can
|
67
|
+
You can pass options to filter your search. `client.search` expects two
|
68
|
+
arguments:
|
69
|
+
|
70
|
+
* location
|
71
|
+
* params
|
72
|
+
|
73
|
+
The location arguments match the location option in search endpoint.[Seach API](https://www.yelp.com/developers/documentation/v3/business_search)
|
74
|
+
This attribute is attached to options send to the serch endpoint.
|
75
|
+
|
76
|
+
The params are convert to a hash and send to endpoint as verbatim options.
|
77
|
+
|
78
|
+
* term: Search for term eg: 'food', 'restaurants', or the business name.
|
79
|
+
* categories: A list of comma limited categories to filter the business search
|
80
|
+
* locale: Specify the locale to return the business information in.
|
81
|
+
|
82
|
+
Form more info and the completed list of options, please go to [Search API](https://www.yelp.com/developers/documentation/v3/business_search)
|
83
|
+
|
84
|
+
You can call search method using ruby arguments. The lisf or arguments will be
|
85
|
+
parsed as hash for the second parameter.
|
70
86
|
|
71
87
|
```ruby
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
}
|
88
|
+
# ruby arguments
|
89
|
+
client.search('San Francisco', term: 'restaurants')
|
90
|
+
```
|
76
91
|
|
77
|
-
|
92
|
+
You can also pass a hash as second argument.
|
78
93
|
|
79
|
-
|
94
|
+
```ruby
|
95
|
+
# hash params
|
96
|
+
params = {
|
97
|
+
term: 'food',
|
98
|
+
limit: 3,
|
99
|
+
category_filter: 'discgolf'
|
100
|
+
}
|
101
|
+
|
102
|
+
client.search('San Francisco', params)
|
80
103
|
```
|
104
|
+
|
81
105
|
Key names and options for params and locale match the documented names on the [Yelp Search API](https://www.yelp.com/developers/documentation/v3/business_search)
|
82
106
|
|
83
107
|
Additionally there is one more search methods for searching by [geographical coordinates](https://www.yelp.com/developers/documentation/v3/business_search):
|
@@ -182,7 +206,6 @@ You can generate and find your Access Tokens at [https://www.yelp.com/developers
|
|
182
206
|
|
183
207
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT), Copyright (c) 2018 Jobcase, Inc
|
184
208
|
|
185
|
-
|
186
209
|
## Code of Conduct
|
187
210
|
|
188
211
|
Everyone interacting in the Yelp::Fusion project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/yelp-fusion/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/yelp/fusion.rb
CHANGED
@@ -20,7 +20,10 @@
|
|
20
20
|
|
21
21
|
require 'yelp/fusion/client'
|
22
22
|
|
23
|
+
# Yelp::Fusion
|
24
|
+
#
|
23
25
|
module Yelp
|
26
|
+
# Entry module for application
|
24
27
|
module Fusion
|
25
28
|
# Returns an initially-unconfigured instance of the client.
|
26
29
|
# @return [Client] an instance of the client
|
@@ -33,4 +36,4 @@ module Yelp
|
|
33
36
|
@client ||= Yelp::Fusion::Client.new
|
34
37
|
end
|
35
38
|
end
|
36
|
-
end
|
39
|
+
end
|
data/lib/yelp/fusion/client.rb
CHANGED
@@ -17,6 +17,7 @@
|
|
17
17
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
|
+
|
20
21
|
require 'faraday'
|
21
22
|
require 'faraday_middleware'
|
22
23
|
require 'yelp/fusion/configuration'
|
@@ -29,8 +30,11 @@ require 'yelp/fusion/endpoint/match'
|
|
29
30
|
require 'yelp/fusion/endpoint/transaction'
|
30
31
|
require 'yelp/fusion/singleton'
|
31
32
|
|
33
|
+
# Yelp::Fusion::Client
|
34
|
+
#
|
32
35
|
module Yelp
|
33
36
|
module Fusion
|
37
|
+
# Base class for the Yelp Client
|
34
38
|
class Client
|
35
39
|
include Fusion::Singleton
|
36
40
|
API_HOST = 'https://api.yelp.com'.freeze
|
@@ -40,18 +44,21 @@ module Yelp
|
|
40
44
|
# Creates an instance of the fusion client
|
41
45
|
# @param options [String, nil] a consumer key
|
42
46
|
# @return [Client] a new client initialized with the keys
|
43
|
-
|
47
|
+
#
|
44
48
|
def initialize(option = nil)
|
45
49
|
@configuration = nil
|
46
50
|
define_request_methods
|
47
51
|
return if option.nil?
|
52
|
+
|
48
53
|
@configuration = Configuration.new(option)
|
49
54
|
end
|
50
55
|
|
51
56
|
# Creates a configuration with API keys
|
52
57
|
# @return [@configuration] a frozen configuration
|
58
|
+
#
|
53
59
|
def configure
|
54
60
|
raise Error::AlreadyConfigured unless @configuration.nil?
|
61
|
+
|
55
62
|
@configuration = Configuration.new
|
56
63
|
yield(@configuration)
|
57
64
|
check_api_keys
|
@@ -63,12 +70,12 @@ module Yelp
|
|
63
70
|
if @configuration.nil? ||
|
64
71
|
@configuration.api_key.nil? ||
|
65
72
|
defined?(@configuration.api_key).nil?
|
73
|
+
|
66
74
|
@configuration = nil
|
67
75
|
raise Error::MissingAPIKeys
|
68
76
|
else
|
69
77
|
# Freeze the configuration so it cannot be modified once the gem is
|
70
|
-
# configured.
|
71
|
-
# is operating, which would necessitate invalidating various caches
|
78
|
+
# configured.
|
72
79
|
@configuration.freeze
|
73
80
|
end
|
74
81
|
end
|
@@ -79,7 +86,6 @@ module Yelp
|
|
79
86
|
|
80
87
|
check_api_keys
|
81
88
|
@connection = Faraday.new(API_HOST) do |conn|
|
82
|
-
# this guy uses oauth2 and bearer? maybe? to authorize the key
|
83
89
|
conn.request :oauth2, @configuration.api_key, token_type: :bearer
|
84
90
|
# Using default http library
|
85
91
|
conn.adapter :net_http
|
@@ -18,8 +18,11 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Configuration
|
22
|
+
#
|
21
23
|
module Yelp
|
22
24
|
module Fusion
|
25
|
+
# Store configuration values for api.
|
23
26
|
class Configuration
|
24
27
|
attr_accessor :api_key
|
25
28
|
|
@@ -30,6 +33,7 @@ module Yelp
|
|
30
33
|
# config_api String
|
31
34
|
def initialize(config_api = nil)
|
32
35
|
return unless !config_api.nil? && config_api.is_a?(String)
|
36
|
+
|
33
37
|
self.api_key = config_api
|
34
38
|
end
|
35
39
|
end
|
@@ -23,9 +23,12 @@ require 'json'
|
|
23
23
|
|
24
24
|
require 'yelp/fusion/responses/business'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Endpoint::Business
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Endpoint
|
31
|
+
# Endpoint to make client requests to the Businesses API
|
29
32
|
class Business
|
30
33
|
PATH = '/v3/businesses/'.freeze
|
31
34
|
|
@@ -23,9 +23,12 @@ require 'json'
|
|
23
23
|
|
24
24
|
require 'yelp/fusion/responses/business'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Endpoint::Match
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Endpoint
|
31
|
+
# Class for requests to find matching businesses
|
29
32
|
class Match
|
30
33
|
PATH = '/v3/businesses/matches'.freeze
|
31
34
|
|
@@ -33,7 +36,7 @@ module Yelp
|
|
33
36
|
@client = client
|
34
37
|
end
|
35
38
|
|
36
|
-
# Make a request to the business endpoint
|
39
|
+
# Make a request to the business endpoint
|
37
40
|
#
|
38
41
|
# @param params [Hash] a hash of the required location parameters
|
39
42
|
# @return [Response::Match] a parsed object of the response.
|
@@ -54,7 +57,7 @@ module Yelp
|
|
54
57
|
private
|
55
58
|
|
56
59
|
def match_request(params = {})
|
57
|
-
result = @client.connection.get
|
60
|
+
result = @client.connection.get(PATH, params)
|
58
61
|
Error.check_for_error(result)
|
59
62
|
result
|
60
63
|
end
|
@@ -23,9 +23,12 @@ require 'json'
|
|
23
23
|
|
24
24
|
require 'yelp/fusion/responses/phone'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Endpoint::Phone
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Endpoint
|
31
|
+
# Class to search businesses by phone
|
29
32
|
class Phone
|
30
33
|
PATH = '/v3/businesses/search/phone'.freeze
|
31
34
|
|
@@ -61,7 +64,7 @@ module Yelp
|
|
61
64
|
# @param phone [String] the phone number
|
62
65
|
# @return [Faraday::Response] the raw response back from the connection
|
63
66
|
def phone_request(phone)
|
64
|
-
result = @client.connection.get
|
67
|
+
result = @client.connection.get(PATH, phone)
|
65
68
|
Error.check_for_error(result)
|
66
69
|
result
|
67
70
|
end
|
@@ -23,9 +23,12 @@ require 'json'
|
|
23
23
|
|
24
24
|
require 'yelp/fusion/responses/review'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Endpoint::Review
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Endpoint
|
31
|
+
# Class to search for business reviews
|
29
32
|
class Review
|
30
33
|
PATH = '/v3/businesses/'.freeze
|
31
34
|
|
@@ -21,9 +21,12 @@
|
|
21
21
|
require 'json'
|
22
22
|
require 'yelp/fusion/responses/search'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Endpoint::Search
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Endpoint
|
29
|
+
# Class to search for businesses
|
27
30
|
class Search
|
28
31
|
PATH = '/v3/businesses/search'.freeze
|
29
32
|
def initialize(client)
|
@@ -81,6 +84,7 @@ module Yelp
|
|
81
84
|
def search_by_coordinates(coordinates, params = {})
|
82
85
|
raise Error::MissingLatLng if coordinates[:latitude].nil? ||
|
83
86
|
coordinates[:longitude].nil?
|
87
|
+
|
84
88
|
coordinates.merge!(params)
|
85
89
|
Responses::Search.new(JSON.parse(search_request(coordinates).body))
|
86
90
|
end
|
@@ -94,7 +98,7 @@ module Yelp
|
|
94
98
|
# @param params [Hash] a hash of parameters for the search request
|
95
99
|
# @return [Faraday::Response] the raw response back from the connection
|
96
100
|
def search_request(params)
|
97
|
-
result = @client.connection.get
|
101
|
+
result = @client.connection.get(PATH, params)
|
98
102
|
Yelp::Fusion::Error.check_for_error(result)
|
99
103
|
result
|
100
104
|
end
|
@@ -23,9 +23,12 @@ require 'json'
|
|
23
23
|
|
24
24
|
require 'yelp/fusion/responses/business'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Endpoint::Transaction
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Endpoint
|
31
|
+
# Endpoint to search for Yelp transactions
|
29
32
|
class Transaction
|
30
33
|
PATH = '/v3/transactions/'.freeze
|
31
34
|
|
@@ -33,11 +36,9 @@ module Yelp
|
|
33
36
|
@client = client
|
34
37
|
end
|
35
38
|
|
36
|
-
# Make a request to the
|
37
|
-
#
|
38
|
-
# @param
|
39
|
-
# @param locale [Hash] a hash of supported locale-related parameters
|
40
|
-
# @return [Response::Review] the parsed response object from the API
|
39
|
+
# Make a request to the transaction search endpoint of the API
|
40
|
+
# @param transaction_type [String] it has to be delivery
|
41
|
+
# @param location [Hash] a hash of supported locatio
|
41
42
|
#
|
42
43
|
# @example Get Transaction
|
43
44
|
# review = client.transaction('delivery', 'San Francisco')
|
@@ -70,6 +71,7 @@ module Yelp
|
|
70
71
|
def transaction_by_coordinates(transaction_type, coordinates)
|
71
72
|
raise Error::MissingLatLng if coordinates[:latitude].nil? ||
|
72
73
|
coordinates[:longitude].nil?
|
74
|
+
|
73
75
|
result = transaction_request(transaction_type, coordinates)
|
74
76
|
Responses::Transaction.new(JSON.parse(result.body))
|
75
77
|
end
|
data/lib/yelp/fusion/error.rb
CHANGED
@@ -20,15 +20,19 @@
|
|
20
20
|
|
21
21
|
require 'json'
|
22
22
|
|
23
|
+
# Yelp::Fusion::Error::ResponseValidator
|
23
24
|
module Yelp
|
24
25
|
module Fusion
|
26
|
+
# Module to handle errors in Gem
|
25
27
|
module Error
|
28
|
+
# Class to handle error responses
|
26
29
|
class ResponseValidator
|
27
30
|
# If the request is not successful, raise an appropriate Yelp::Error
|
28
31
|
# exception with the error text from the request response.
|
29
32
|
# @param response from the Yelp API
|
30
33
|
def validate(response)
|
31
34
|
return if successful_response?(response)
|
35
|
+
|
32
36
|
raise error_from_response(response)
|
33
37
|
end
|
34
38
|
|
@@ -64,12 +68,14 @@ module Yelp
|
|
64
68
|
@response_validator.validate(response)
|
65
69
|
end
|
66
70
|
|
71
|
+
# Standard error response class
|
67
72
|
class Base < StandardError
|
68
73
|
def initialize(msg, _error = nil)
|
69
74
|
super(msg)
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
78
|
+
# Class to handle an already configure Yelp Client
|
73
79
|
class AlreadyConfigured < Base
|
74
80
|
def initialize(msg = 'Gem cannot be reconfigured. Initialize a new ' \
|
75
81
|
'instance of Yelp::Client.', error = nil)
|
@@ -77,12 +83,14 @@ module Yelp
|
|
77
83
|
end
|
78
84
|
end
|
79
85
|
|
86
|
+
# Class for missing Yelp API Keys
|
80
87
|
class MissingAPIKeys < Base
|
81
88
|
def initialize(msg = "You're missing an API key", error = nil)
|
82
89
|
super
|
83
90
|
end
|
84
91
|
end
|
85
92
|
|
93
|
+
# Class for missing Latitude or longitude
|
86
94
|
class MissingLatLng < Base
|
87
95
|
def initialize(msg = 'Missing required latitude '\
|
88
96
|
'or longitude parameters', error = nil)
|
@@ -90,17 +98,29 @@ module Yelp
|
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
101
|
+
# Class for invalid Auth Token
|
93
102
|
class TokenInvalid < Base; end
|
103
|
+
# Class if no Yelp Location is found
|
94
104
|
class LocationNotFound < Base; end
|
105
|
+
# Class if the rate limit is exceeded
|
95
106
|
class TooManyRequestsPerSecond < Base; end
|
107
|
+
# Class if Yelp experiences a internal error
|
96
108
|
class InternalError < Base; end
|
109
|
+
# Class if a Validation Error occurs
|
97
110
|
class ValidationError < Base; end
|
111
|
+
# Class if an auth token is missing
|
98
112
|
class TokenMissing < Base; end
|
113
|
+
# Class for timed out requests
|
99
114
|
class RequestTimedOut < Base; end
|
115
|
+
# Class if the access limit for requests
|
116
|
+
# is reached
|
100
117
|
class AccessLimitReached < Base; end
|
118
|
+
# Class for resources not found
|
101
119
|
class NotFound < Base; end
|
120
|
+
# Class for client erro
|
102
121
|
class ClientError < Base; end
|
122
|
+
# Class if businesses are not found
|
103
123
|
class BusinessNotFound < Base; end
|
104
124
|
end
|
105
125
|
end
|
106
|
-
end
|
126
|
+
end
|
@@ -18,13 +18,16 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Responses::Base
|
21
22
|
module Yelp
|
22
23
|
module Fusion
|
23
24
|
module Responses
|
25
|
+
# Base instance variables sent back from JSON response
|
24
26
|
class Base
|
25
|
-
# yelp returns its data in JSON
|
27
|
+
# yelp returns its data in JSON format.
|
26
28
|
def initialize(json)
|
27
29
|
return if json.nil?
|
30
|
+
|
28
31
|
json.each do |key, value|
|
29
32
|
instance_variable_set("@#{key}", value)
|
30
33
|
end
|
@@ -35,6 +38,7 @@ module Yelp
|
|
35
38
|
def parse(json, klass)
|
36
39
|
return json.collect { |j| klass.new(j) } if json.is_a?(Array)
|
37
40
|
return klass.new(json) if json
|
41
|
+
|
38
42
|
nil
|
39
43
|
end
|
40
44
|
end
|
@@ -21,9 +21,12 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/business'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses::Business
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
29
|
+
# Base class to parse responses from the Business API
|
27
30
|
class Business < Base
|
28
31
|
attr_reader :business
|
29
32
|
def initialize(json)
|
@@ -21,9 +21,12 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/business'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
29
|
+
# Base class to parse json from the Business Match endpoint
|
27
30
|
class Match < Base
|
28
31
|
attr_reader :total, :businesses
|
29
32
|
def initialize(json)
|
@@ -23,10 +23,13 @@ require 'yelp/fusion/responses/models/categories'
|
|
23
23
|
require 'yelp/fusion/responses/models/location'
|
24
24
|
require 'yelp/fusion/responses/models/hours'
|
25
25
|
|
26
|
+
# Yelp::Fusion::Responses::Models::Business
|
27
|
+
#
|
26
28
|
module Yelp
|
27
29
|
module Fusion
|
28
30
|
module Responses
|
29
31
|
module Models
|
32
|
+
# Model for the Yelp Business response JSON
|
30
33
|
class Business < Responses::Base
|
31
34
|
attr_reader :categories, :coordinates, :display_phone,
|
32
35
|
:distance, :id,
|
@@ -34,6 +37,7 @@ module Yelp
|
|
34
37
|
:name, :phone, :price,
|
35
38
|
:rating, :review_count, :url, :transactions,
|
36
39
|
:hours, :is_claimed, :photos
|
40
|
+
|
37
41
|
def initialize(json)
|
38
42
|
super(json)
|
39
43
|
@categories = parse(@categories, Categories)
|
@@ -18,10 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Responses::Models::Categories
|
22
|
+
#
|
21
23
|
module Yelp
|
22
24
|
module Fusion
|
23
25
|
module Responses
|
24
26
|
module Models
|
27
|
+
# Model for the Categories JSON body
|
25
28
|
class Categories < Responses::Base
|
26
29
|
attr_reader :alias, :title
|
27
30
|
def initialize(json)
|
@@ -18,10 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Responses::Models::Center
|
22
|
+
#
|
21
23
|
module Yelp
|
22
24
|
module Fusion
|
23
25
|
module Responses
|
24
26
|
module Models
|
27
|
+
# Model fot the Center json body
|
25
28
|
class Center < Responses::Base
|
26
29
|
attr_reader :latitude, :longitude
|
27
30
|
def initialize(json)
|
@@ -21,10 +21,13 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/openHours'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses::Models::Hours
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
27
29
|
module Models
|
30
|
+
# Model for the Hours JSON body
|
28
31
|
class Hours < Responses::Base
|
29
32
|
attr_reader :is_open_now, :hours_type, :open
|
30
33
|
def initialize(json)
|
@@ -18,10 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Responses::Models::Location
|
22
|
+
#
|
21
23
|
module Yelp
|
22
24
|
module Fusion
|
23
25
|
module Responses
|
24
26
|
module Models
|
27
|
+
# Model for the Location JSON body
|
25
28
|
class Location < Responses::Base
|
26
29
|
attr_reader :city, :country, :address2, :address3,
|
27
30
|
:state, :address1, :zip_code,
|
@@ -18,10 +18,13 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
# Yelp::Fusion::Responses::Models::OpenHours
|
22
|
+
#
|
21
23
|
module Yelp
|
22
24
|
module Fusion
|
23
25
|
module Responses
|
24
26
|
module Models
|
27
|
+
# Model for the OpenHours JSON body
|
25
28
|
class OpenHours < Responses::Base
|
26
29
|
attr_reader :day, :start, :end, :is_overnight
|
27
30
|
def initialize(json)
|
@@ -21,10 +21,13 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/center'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses::Models::Region
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
27
29
|
module Models
|
30
|
+
# Model for the Region JSON body
|
28
31
|
class Region < Responses::Base
|
29
32
|
attr_reader :center
|
30
33
|
def initialize(json)
|
@@ -21,10 +21,13 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/user'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses::Models::Reviews
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
27
29
|
module Models
|
30
|
+
# Model for the Reviews JSON body
|
28
31
|
class Reviews < Base
|
29
32
|
attr_reader :id, :rating, :user, :text, :time_created, :url
|
30
33
|
def initialize(json)
|
@@ -20,10 +20,13 @@
|
|
20
20
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
|
23
|
+
# Yelp::Fusion::Responses::Models::Users
|
24
|
+
#
|
23
25
|
module Yelp
|
24
26
|
module Fusion
|
25
27
|
module Responses
|
26
28
|
module Models
|
29
|
+
# Model for the User JSON body
|
27
30
|
class User < Base
|
28
31
|
attr_reader :image_url, :name
|
29
32
|
def initialize(json)
|
@@ -21,11 +21,16 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/business'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses:Phone
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
29
|
+
# Base class to parse the business
|
30
|
+
# phone response JSON
|
27
31
|
class Phone < Base
|
28
32
|
attr_reader :total, :businesses
|
33
|
+
|
29
34
|
def initialize(json)
|
30
35
|
super(json)
|
31
36
|
@businesses = parse(@businesses, Models::Business)
|
@@ -21,9 +21,12 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/reviews'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Response::Review
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
29
|
+
# Class to parse the Review response JSON
|
27
30
|
class Review < Base
|
28
31
|
attr_reader :reviews, :total, :possible_languages
|
29
32
|
def initialize(json)
|
@@ -22,9 +22,12 @@ require 'yelp/fusion/responses/base'
|
|
22
22
|
require 'yelp/fusion/responses/models/business'
|
23
23
|
require 'yelp/fusion/responses/models/region'
|
24
24
|
|
25
|
+
# Yelp::Fusion::Responses::Search
|
26
|
+
#
|
25
27
|
module Yelp
|
26
28
|
module Fusion
|
27
29
|
module Responses
|
30
|
+
# Class to parse the Search response JSON
|
28
31
|
class Search < Base
|
29
32
|
attr_reader :businesses, :region, :total
|
30
33
|
def initialize(json)
|
@@ -21,9 +21,12 @@
|
|
21
21
|
require 'yelp/fusion/responses/base'
|
22
22
|
require 'yelp/fusion/responses/models/business'
|
23
23
|
|
24
|
+
# Yelp::Fusion::Responses::Transaction
|
25
|
+
#
|
24
26
|
module Yelp
|
25
27
|
module Fusion
|
26
28
|
module Responses
|
29
|
+
# Class to parse the Transaction response JSON
|
27
30
|
class Transaction < Base
|
28
31
|
attr_reader :total, :businesses
|
29
32
|
def initialize(json)
|
@@ -1,5 +1,29 @@
|
|
1
|
+
# Copyright (c) Jobcase, Inc. All rights reserved.
|
2
|
+
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
# Yelp::Fusion::Singleton
|
22
|
+
#
|
1
23
|
module Yelp
|
2
24
|
module Fusion
|
25
|
+
# Load each endpoint object once for acces by the
|
26
|
+
# Yelp::Fusion::Client object
|
3
27
|
module Singleton
|
4
28
|
REQUEST_CLASSES = [Yelp::Fusion::Endpoint::Search,
|
5
29
|
Yelp::Fusion::Endpoint::Business,
|
data/lib/yelp/fusion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yelp-fusion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0
|
4
|
+
version: '1.0'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Grueter
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-10-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -223,7 +223,7 @@ files:
|
|
223
223
|
- lib/yelp/fusion/responses/models/center.rb
|
224
224
|
- lib/yelp/fusion/responses/models/hours.rb
|
225
225
|
- lib/yelp/fusion/responses/models/location.rb
|
226
|
-
- lib/yelp/fusion/responses/models/
|
226
|
+
- lib/yelp/fusion/responses/models/open_hours.rb
|
227
227
|
- lib/yelp/fusion/responses/models/region.rb
|
228
228
|
- lib/yelp/fusion/responses/models/reviews.rb
|
229
229
|
- lib/yelp/fusion/responses/models/user.rb
|
@@ -249,12 +249,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
249
249
|
version: 2.2.2
|
250
250
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
251
251
|
requirements:
|
252
|
-
- - "
|
252
|
+
- - ">="
|
253
253
|
- !ruby/object:Gem::Version
|
254
|
-
version:
|
254
|
+
version: '0'
|
255
255
|
requirements: []
|
256
|
-
|
257
|
-
rubygems_version: 2.7.6
|
256
|
+
rubygems_version: 3.0.6
|
258
257
|
signing_key:
|
259
258
|
specification_version: 4
|
260
259
|
summary: "{A Ruby gem for the Yelp Fusion (V3) API}"
|