booking_locations 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +62 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/booking_locations.gemspec +28 -0
- data/lib/booking_locations/api.rb +33 -0
- data/lib/booking_locations/location.rb +41 -0
- data/lib/booking_locations/slot.rb +17 -0
- data/lib/booking_locations/stub_api.json +341 -0
- data/lib/booking_locations/stub_api.rb +17 -0
- data/lib/booking_locations/version.rb +3 -0
- data/lib/booking_locations.rb +20 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5c8b877898b03f793be9ff7adfacfbb796c7698
|
4
|
+
data.tar.gz: e9f6eeafb705f4cec736f0783d3d5d5a89902fb4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 886c119dafaac5dc0941b7681b7656b87782aa7cd045f77c9d65e855738a4bdfbe88e2c45059be442e701bcbf73eb8da98713d1fa0f9b8c7d5f522b245c615c5
|
7
|
+
data.tar.gz: 41c894aa5ef2cb841759654f017e272d7ac916ca866152290e508f5f892aaeb416d417cc64b508de8e88f48e38e5b612a9589e8232e1b708d5594a4290ab493a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Ben Lovell
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# BookingLocations
|
2
|
+
|
3
|
+
Provides Booking Locations API access.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'booking_locations'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install booking_locations
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
|
25
|
+
BookingLocations.find(id) # returns a Location or nil
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
The library provides a stubbed adapter:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
|
33
|
+
require 'booking_locations/stub_api'
|
34
|
+
BookingLocations.api = BookingLocations::StubApi.new
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
This returns canned responses for locations within Hackney.
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
43
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
44
|
+
prompt that will allow you to experiment.
|
45
|
+
|
46
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
47
|
+
release a new version, update the version number in `version.rb`, and then run
|
48
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
49
|
+
git commits and tags, and push the `.gem` file to
|
50
|
+
[rubygems.org](https://rubygems.org).
|
51
|
+
|
52
|
+
## Contributing
|
53
|
+
|
54
|
+
Bug reports and pull requests are welcome on GitHub at
|
55
|
+
https://github.com/guidance-guarantee-programme/booking_locations.
|
56
|
+
|
57
|
+
|
58
|
+
## License
|
59
|
+
|
60
|
+
The gem is available as open source under the terms of the
|
61
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
62
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "booking_locations"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'booking_locations/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'booking_locations'
|
8
|
+
spec.version = BookingLocations::VERSION
|
9
|
+
spec.authors = ['Ben Lovell']
|
10
|
+
spec.email = ['benjamin.lovell@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Pension Guidance Booking Locations API adapter'
|
13
|
+
spec.homepage = 'https://github.com/guidance-guarantee-programme/booking_locations'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'activesupport', '>= 4', '< 5.1'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'vcr', '~> 3.0'
|
27
|
+
spec.add_development_dependency 'webmock', '~> 2.1'
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module BookingLocations
|
4
|
+
class Api
|
5
|
+
def get(id)
|
6
|
+
response = open("#{api_uri}/api/v1/booking_locations/#{id}.json", headers_and_options)
|
7
|
+
yield JSON.parse(response.read)
|
8
|
+
rescue OpenURI::HTTPError, Net::ReadTimeout
|
9
|
+
nil
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def headers_and_options
|
15
|
+
{}.tap do |hash|
|
16
|
+
hash[:read_timeout] = read_timeout
|
17
|
+
hash['Authorization'] = "Bearer #{bearer_token}" if bearer_token
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def bearer_token
|
22
|
+
ENV['BOOKING_LOCATIONS_API_BEARER_TOKEN']
|
23
|
+
end
|
24
|
+
|
25
|
+
def api_uri
|
26
|
+
ENV.fetch('BOOKING_LOCATIONS_API_URI', 'http://localhost:3001')
|
27
|
+
end
|
28
|
+
|
29
|
+
def read_timeout
|
30
|
+
ENV.fetch('BOOKING_LOCATIONS_API_READ_TIMEOUT', 5).to_i
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module BookingLocations
|
4
|
+
class Location
|
5
|
+
def initialize(data)
|
6
|
+
@data = data
|
7
|
+
end
|
8
|
+
|
9
|
+
def id
|
10
|
+
@data['uid']
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
@data['name']
|
15
|
+
end
|
16
|
+
|
17
|
+
def address
|
18
|
+
@data['address']
|
19
|
+
end
|
20
|
+
|
21
|
+
def locations
|
22
|
+
@locations ||= @data['locations'].map { |child_data| Location.new(child_data) }
|
23
|
+
end
|
24
|
+
|
25
|
+
def guiders
|
26
|
+
@guiders ||= @data['guiders'].map { |guider| OpenStruct.new(guider) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def slots
|
30
|
+
@slots ||= @data['slots'].map { |slot| Slot.new(slot) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def name_for(location_id)
|
34
|
+
if id == location_id
|
35
|
+
name
|
36
|
+
else
|
37
|
+
locations.find { |location| location.id == location_id }.name
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
module BookingLocations
|
4
|
+
class Slot < OpenStruct
|
5
|
+
def to_calendar
|
6
|
+
["#{calendar_date} - #{period}", "#{date}-#{start}-#{self.end}"]
|
7
|
+
end
|
8
|
+
|
9
|
+
def calendar_date
|
10
|
+
Date.parse(date).strftime('%A, %b %e')
|
11
|
+
end
|
12
|
+
|
13
|
+
def period
|
14
|
+
start == '0900' ? 'Morning' : 'Afternoon'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,341 @@
|
|
1
|
+
{
|
2
|
+
"uid": "ac7112c3-e3cf-45cd-a8ff-9ba827b8e7ef",
|
3
|
+
"name": "Hackney",
|
4
|
+
"address": "300 Mare St, HACKNEY, London, E8 1HE",
|
5
|
+
"locations": [
|
6
|
+
{
|
7
|
+
"uid": "183080c6-642b-4b8f-96fd-891f5cd9f9c7",
|
8
|
+
"name": "Dalston",
|
9
|
+
"address": "22 Dalston Lane, Hackney, London, E8 3AZ"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"uid": "1a1ad00f-d967-448a-a4a6-772369fa5087",
|
13
|
+
"name": "Tower Hamlets",
|
14
|
+
"address": "32 Greatorex Street, TOWER HAMLETS, London, E1 5NP"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"uid": "c165d25e-f27b-4ce9-b3d3-e7415ebaa93c",
|
18
|
+
"name": "Haringey",
|
19
|
+
"address": "551B Tottenham High Road, HARINGEY, London, N17 6SB"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"uid": "a77a031a-8037-4510-b1f7-63d4aab7b103",
|
23
|
+
"name": "Waltham Forest",
|
24
|
+
"address": "220 Hoe Street, Walthamstow, London, E17 3AY"
|
25
|
+
}
|
26
|
+
],
|
27
|
+
"guiders": [
|
28
|
+
{
|
29
|
+
"id": 1,
|
30
|
+
"name": "Ben Lovell",
|
31
|
+
"email": "ben@example.com"
|
32
|
+
},
|
33
|
+
{
|
34
|
+
"id": 2,
|
35
|
+
"name": "Jenny Smith",
|
36
|
+
"email": "jenny@example.com"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"id": 3,
|
40
|
+
"name": "Bob Johnson",
|
41
|
+
"email": "bob@example.com"
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"id": 4,
|
45
|
+
"name": "Janice Jones",
|
46
|
+
"email": "janice@example.com"
|
47
|
+
}
|
48
|
+
],
|
49
|
+
"slots": [
|
50
|
+
{
|
51
|
+
"date": "2016-06-20",
|
52
|
+
"start": "0900",
|
53
|
+
"end": "1300"
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"date": "2016-06-20",
|
57
|
+
"start": "1300",
|
58
|
+
"end": "1700"
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"date": "2016-06-21",
|
62
|
+
"start": "0900",
|
63
|
+
"end": "1300"
|
64
|
+
},
|
65
|
+
{
|
66
|
+
"date": "2016-06-21",
|
67
|
+
"start": "1300",
|
68
|
+
"end": "1700"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"date": "2016-06-22",
|
72
|
+
"start": "0900",
|
73
|
+
"end": "1300"
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"date": "2016-06-22",
|
77
|
+
"start": "1300",
|
78
|
+
"end": "1700"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
"date": "2016-06-23",
|
82
|
+
"start": "0900",
|
83
|
+
"end": "1300"
|
84
|
+
},
|
85
|
+
{
|
86
|
+
"date": "2016-06-23",
|
87
|
+
"start": "1300",
|
88
|
+
"end": "1700"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
"date": "2016-06-24",
|
92
|
+
"start": "0900",
|
93
|
+
"end": "1300"
|
94
|
+
},
|
95
|
+
{
|
96
|
+
"date": "2016-06-24",
|
97
|
+
"start": "1300",
|
98
|
+
"end": "1700"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"date": "2016-06-27",
|
102
|
+
"start": "0900",
|
103
|
+
"end": "1300"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"date": "2016-06-27",
|
107
|
+
"start": "1300",
|
108
|
+
"end": "1700"
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"date": "2016-06-28",
|
112
|
+
"start": "0900",
|
113
|
+
"end": "1300"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"date": "2016-06-28",
|
117
|
+
"start": "1300",
|
118
|
+
"end": "1700"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"date": "2016-06-29",
|
122
|
+
"start": "0900",
|
123
|
+
"end": "1300"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"date": "2016-06-29",
|
127
|
+
"start": "1300",
|
128
|
+
"end": "1700"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"date": "2016-06-30",
|
132
|
+
"start": "0900",
|
133
|
+
"end": "1300"
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"date": "2016-06-30",
|
137
|
+
"start": "1300",
|
138
|
+
"end": "1700"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"date": "2016-07-01",
|
142
|
+
"start": "0900",
|
143
|
+
"end": "1300"
|
144
|
+
},
|
145
|
+
{
|
146
|
+
"date": "2016-07-01",
|
147
|
+
"start": "1300",
|
148
|
+
"end": "1700"
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"date": "2016-07-04",
|
152
|
+
"start": "0900",
|
153
|
+
"end": "1300"
|
154
|
+
},
|
155
|
+
{
|
156
|
+
"date": "2016-07-04",
|
157
|
+
"start": "1300",
|
158
|
+
"end": "1700"
|
159
|
+
},
|
160
|
+
{
|
161
|
+
"date": "2016-07-05",
|
162
|
+
"start": "0900",
|
163
|
+
"end": "1300"
|
164
|
+
},
|
165
|
+
{
|
166
|
+
"date": "2016-07-05",
|
167
|
+
"start": "1300",
|
168
|
+
"end": "1700"
|
169
|
+
},
|
170
|
+
{
|
171
|
+
"date": "2016-07-06",
|
172
|
+
"start": "0900",
|
173
|
+
"end": "1300"
|
174
|
+
},
|
175
|
+
{
|
176
|
+
"date": "2016-07-06",
|
177
|
+
"start": "1300",
|
178
|
+
"end": "1700"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
"date": "2016-07-07",
|
182
|
+
"start": "0900",
|
183
|
+
"end": "1300"
|
184
|
+
},
|
185
|
+
{
|
186
|
+
"date": "2016-07-07",
|
187
|
+
"start": "1300",
|
188
|
+
"end": "1700"
|
189
|
+
},
|
190
|
+
{
|
191
|
+
"date": "2016-07-08",
|
192
|
+
"start": "0900",
|
193
|
+
"end": "1300"
|
194
|
+
},
|
195
|
+
{
|
196
|
+
"date": "2016-07-08",
|
197
|
+
"start": "1300",
|
198
|
+
"end": "1700"
|
199
|
+
},
|
200
|
+
{
|
201
|
+
"date": "2016-07-11",
|
202
|
+
"start": "0900",
|
203
|
+
"end": "1300"
|
204
|
+
},
|
205
|
+
{
|
206
|
+
"date": "2016-07-11",
|
207
|
+
"start": "1300",
|
208
|
+
"end": "1700"
|
209
|
+
},
|
210
|
+
{
|
211
|
+
"date": "2016-07-12",
|
212
|
+
"start": "0900",
|
213
|
+
"end": "1300"
|
214
|
+
},
|
215
|
+
{
|
216
|
+
"date": "2016-07-12",
|
217
|
+
"start": "1300",
|
218
|
+
"end": "1700"
|
219
|
+
},
|
220
|
+
{
|
221
|
+
"date": "2016-07-13",
|
222
|
+
"start": "0900",
|
223
|
+
"end": "1300"
|
224
|
+
},
|
225
|
+
{
|
226
|
+
"date": "2016-07-13",
|
227
|
+
"start": "1300",
|
228
|
+
"end": "1700"
|
229
|
+
},
|
230
|
+
{
|
231
|
+
"date": "2016-07-14",
|
232
|
+
"start": "0900",
|
233
|
+
"end": "1300"
|
234
|
+
},
|
235
|
+
{
|
236
|
+
"date": "2016-07-14",
|
237
|
+
"start": "1300",
|
238
|
+
"end": "1700"
|
239
|
+
},
|
240
|
+
{
|
241
|
+
"date": "2016-07-15",
|
242
|
+
"start": "0900",
|
243
|
+
"end": "1300"
|
244
|
+
},
|
245
|
+
{
|
246
|
+
"date": "2016-07-15",
|
247
|
+
"start": "1300",
|
248
|
+
"end": "1700"
|
249
|
+
},
|
250
|
+
{
|
251
|
+
"date": "2016-07-18",
|
252
|
+
"start": "0900",
|
253
|
+
"end": "1300"
|
254
|
+
},
|
255
|
+
{
|
256
|
+
"date": "2016-07-18",
|
257
|
+
"start": "1300",
|
258
|
+
"end": "1700"
|
259
|
+
},
|
260
|
+
{
|
261
|
+
"date": "2016-07-19",
|
262
|
+
"start": "0900",
|
263
|
+
"end": "1300"
|
264
|
+
},
|
265
|
+
{
|
266
|
+
"date": "2016-07-19",
|
267
|
+
"start": "1300",
|
268
|
+
"end": "1700"
|
269
|
+
},
|
270
|
+
{
|
271
|
+
"date": "2016-07-20",
|
272
|
+
"start": "0900",
|
273
|
+
"end": "1300"
|
274
|
+
},
|
275
|
+
{
|
276
|
+
"date": "2016-07-20",
|
277
|
+
"start": "1300",
|
278
|
+
"end": "1700"
|
279
|
+
},
|
280
|
+
{
|
281
|
+
"date": "2016-07-21",
|
282
|
+
"start": "0900",
|
283
|
+
"end": "1300"
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"date": "2016-07-21",
|
287
|
+
"start": "1300",
|
288
|
+
"end": "1700"
|
289
|
+
},
|
290
|
+
{
|
291
|
+
"date": "2016-07-22",
|
292
|
+
"start": "0900",
|
293
|
+
"end": "1300"
|
294
|
+
},
|
295
|
+
{
|
296
|
+
"date": "2016-07-22",
|
297
|
+
"start": "1300",
|
298
|
+
"end": "1700"
|
299
|
+
},
|
300
|
+
{
|
301
|
+
"date": "2016-07-25",
|
302
|
+
"start": "0900",
|
303
|
+
"end": "1300"
|
304
|
+
},
|
305
|
+
{
|
306
|
+
"date": "2016-07-25",
|
307
|
+
"start": "1300",
|
308
|
+
"end": "1700"
|
309
|
+
},
|
310
|
+
{
|
311
|
+
"date": "2016-07-26",
|
312
|
+
"start": "0900",
|
313
|
+
"end": "1300"
|
314
|
+
},
|
315
|
+
{
|
316
|
+
"date": "2016-07-26",
|
317
|
+
"start": "1300",
|
318
|
+
"end": "1700"
|
319
|
+
},
|
320
|
+
{
|
321
|
+
"date": "2016-07-27",
|
322
|
+
"start": "0900",
|
323
|
+
"end": "1300"
|
324
|
+
},
|
325
|
+
{
|
326
|
+
"date": "2016-07-27",
|
327
|
+
"start": "1300",
|
328
|
+
"end": "1700"
|
329
|
+
},
|
330
|
+
{
|
331
|
+
"date": "2016-07-28",
|
332
|
+
"start": "0900",
|
333
|
+
"end": "1300"
|
334
|
+
},
|
335
|
+
{
|
336
|
+
"date": "2016-07-28",
|
337
|
+
"start": "1300",
|
338
|
+
"end": "1700"
|
339
|
+
}
|
340
|
+
]
|
341
|
+
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BookingLocations
|
2
|
+
KNOWN_LOCATION_IDS = %w(
|
3
|
+
ac7112c3-e3cf-45cd-a8ff-9ba827b8e7ef
|
4
|
+
183080c6-642b-4b8f-96fd-891f5cd9f9c7
|
5
|
+
c165d25e-f27b-4ce9-b3d3-e7415ebaa93c
|
6
|
+
a77a031a-8037-4510-b1f7-63d4aab7b103
|
7
|
+
).freeze
|
8
|
+
|
9
|
+
class StubApi
|
10
|
+
def get(id)
|
11
|
+
return nil unless KNOWN_LOCATION_IDS.include?(id)
|
12
|
+
|
13
|
+
contents = IO.read(File.join(File.dirname(File.expand_path(__FILE__)), 'stub_api.json'))
|
14
|
+
yield JSON.parse(contents)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'booking_locations/version'
|
2
|
+
require 'booking_locations/api'
|
3
|
+
require 'booking_locations/slot'
|
4
|
+
require 'booking_locations/location'
|
5
|
+
|
6
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
7
|
+
|
8
|
+
module BookingLocations
|
9
|
+
mattr_writer :api
|
10
|
+
|
11
|
+
def self.api
|
12
|
+
@@api ||= BookingLocations::Api.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.find(id)
|
16
|
+
api.get(id) do |response_hash|
|
17
|
+
Location.new(response_hash)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: booking_locations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ben Lovell
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.1'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '4'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.1'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.12'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.12'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: vcr
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '3.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '3.0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: webmock
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '2.1'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '2.1'
|
103
|
+
description:
|
104
|
+
email:
|
105
|
+
- benjamin.lovell@gmail.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- ".travis.yml"
|
113
|
+
- Gemfile
|
114
|
+
- LICENSE.txt
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- booking_locations.gemspec
|
120
|
+
- lib/booking_locations.rb
|
121
|
+
- lib/booking_locations/api.rb
|
122
|
+
- lib/booking_locations/location.rb
|
123
|
+
- lib/booking_locations/slot.rb
|
124
|
+
- lib/booking_locations/stub_api.json
|
125
|
+
- lib/booking_locations/stub_api.rb
|
126
|
+
- lib/booking_locations/version.rb
|
127
|
+
homepage: https://github.com/guidance-guarantee-programme/booking_locations
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.6.4
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Pension Guidance Booking Locations API adapter
|
151
|
+
test_files: []
|