rlocu2 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/LICENSE +21 -0
- data/README.md +9 -10
- data/lib/rlocu2/client.rb +5 -0
- data/lib/rlocu2/client/venues.rb +14 -0
- data/rlocu2.gemspec +2 -2
- data/spec/venues_spec.rb +23 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54c4c25f4e95f149be74cd04da2d15b5140efb68
|
4
|
+
data.tar.gz: c9f06e5bd4c5bc9d63f2498bc28c001fe4e408ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acca0655d7fd586f5121c13be8dd055a59b68c8a667cb3dfec17ecb54351b437bc5b0dafd64c52120affa2dbdc96a71938d39bfbd4a7087230a565244968b339
|
7
|
+
data.tar.gz: 4a4c941ed42e78181d37a37f8d871e8c7a19196e541a6a197180925dc6e0d9cef4c12042ee102850d377e8b92ef9285cbe1d9233fb064c7a5b6ea6dae29f4a57
|
data/Gemfile.lock
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Andrea Cadamuro
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -10,30 +10,29 @@ Add this line to your application's Gemfile:
|
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
13
|
-
|
13
|
+
bundle install
|
14
14
|
|
15
15
|
Or install it yourself:
|
16
16
|
|
17
|
-
|
17
|
+
gem install rlocu2
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
21
|
First initialize the client with YOUR API KEY:
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
$ client = Rlocu2::Client.new(:api_key => YOUR_API_KEY)
|
23
|
+
require 'rlocu2'
|
24
|
+
client = Rlocu2::Client.new(:api_key => YOUR_API_KEY)
|
26
25
|
|
27
26
|
Prepare Hash with params to send to Locu:
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
params = Hash.new
|
29
|
+
params['fields'] = ['name','location','contact']
|
30
|
+
params['venue_queries'] = []
|
31
|
+
params['venue_queries'] << { 'name' => 'bistro central parc' }
|
33
32
|
|
34
33
|
Make call:
|
35
34
|
|
36
|
-
|
35
|
+
client.venues_search(params)
|
37
36
|
|
38
37
|
Response is an Array of Rlocu2::Venue objects
|
39
38
|
|
data/lib/rlocu2/client.rb
CHANGED
@@ -38,6 +38,11 @@ module Rlocu2
|
|
38
38
|
if type == 'venues'
|
39
39
|
output['venues'] = response_body['venues'].each.reduce([]) { |accum, venue| accum << Rlocu2::Venue.new(venue) }
|
40
40
|
end
|
41
|
+
|
42
|
+
if response_body.has_key? 'next_results_key'
|
43
|
+
output['next_results_key'] = response_body['next_results_key']
|
44
|
+
end
|
45
|
+
|
41
46
|
output
|
42
47
|
else
|
43
48
|
raise Rlocu2::APIError.new(response.body)
|
data/lib/rlocu2/client/venues.rb
CHANGED
@@ -42,6 +42,20 @@ module Rlocu2
|
|
42
42
|
options['menu_item_queries'] = params['menu_item_queries']
|
43
43
|
end
|
44
44
|
|
45
|
+
# pagination
|
46
|
+
if (params.has_key? 'results_key')
|
47
|
+
options['results_key'] = params['results_key']
|
48
|
+
else
|
49
|
+
if (params.has_key? 'limit')
|
50
|
+
options['limit'] = params['limit']
|
51
|
+
options['results_key'] = 'create'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if (params.has_key? 'offset') && (!params.has_key? 'results_key')
|
56
|
+
options['offset'] = 'offset'
|
57
|
+
end
|
58
|
+
|
45
59
|
response = connection.post do |req|
|
46
60
|
req.url "venue/search"
|
47
61
|
req.body = options.to_json
|
data/rlocu2.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'rlocu2'
|
4
|
-
s.version = '0.
|
5
|
-
s.date = '2016-02-
|
4
|
+
s.version = '0.2.0'
|
5
|
+
s.date = '2016-02-18'
|
6
6
|
s.summary = "A ruby wrapper for Locu API 2.0"
|
7
7
|
s.description = "The Locu API gives you access to real-time local business data, from opening hours to price lists, such as restaurant menus"
|
8
8
|
s.authors = ["Andrea Cadamuro"]
|
data/spec/venues_spec.rb
CHANGED
@@ -108,7 +108,30 @@ describe Rlocu2 do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
+
=begin
|
112
|
+
|
113
|
+
# My API KEY IS NOT SUPPORTED
|
114
|
+
|
115
|
+
it 'Quering with limit' do
|
116
|
+
|
117
|
+
params = Hash.new
|
118
|
+
params['fields'] = ['name','location','contact']
|
119
|
+
params['venue_queries'] = []
|
120
|
+
params['venue_queries'] << { 'open_hours' => { 'monday' => ['18:00', '20:00']} }
|
121
|
+
params['limit'] = 2
|
122
|
+
response = client.venues_search(params)
|
111
123
|
|
124
|
+
expect(response['status']).to eq('success')
|
125
|
+
expect(response['http_status']).to eq(200)
|
126
|
+
expect(response['venues']).to be_an_instance_of(Array)
|
127
|
+
expect(response['venues'].size).to eq(2)
|
128
|
+
|
129
|
+
response['venues'].each do |v|
|
130
|
+
expect(v).to be_an_instance_of(Rlocu2::Venue)
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
=end
|
112
135
|
end
|
113
136
|
|
114
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rlocu2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Cadamuro
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".rspec"
|
91
91
|
- Gemfile
|
92
92
|
- Gemfile.lock
|
93
|
+
- LICENSE
|
93
94
|
- README.md
|
94
95
|
- lib/rlocu2.rb
|
95
96
|
- lib/rlocu2/client.rb
|