curzon_uk 1.0.0 → 1.2.0
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/CHANGELOG.md +15 -0
- data/Gemfile +1 -0
- data/README.md +21 -3
- data/curzon_uk.gemspec +1 -1
- data/lib/curzon_uk/cinema.rb +25 -0
- data/lib/curzon_uk/internal/api_response.rb +12 -4
- data/lib/curzon_uk/internal/parser/api/showtime.rb +1 -0
- data/lib/curzon_uk/version.rb +2 -2
- data/lib/curzon_uk.rb +5 -8
- data/test/fixtures/api/sites.json +2 -0
- data/test/lib/curzon_uk/cinema_test.rb +23 -0
- data/test/lib/curzon_uk/internal/api_response_test.rb +8 -0
- data/test/lib/curzon_uk/internal/guest_token_test.rb +7 -0
- data/test/lib/curzon_uk/internal/parser/api/showtime_test.rb +1 -0
- data/test/lib/curzon_uk/performance_test.rb +13 -0
- data/test/live/integration_test.rb +10 -0
- data/test/support/api_shapes.rb +5 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98e52759b8bdefb7907aef8a425aabfed71f1f5684b809bbd7b61f0461bb74ed
|
|
4
|
+
data.tar.gz: d8690202bdbdd3e2757e89ed306542f2c6e2aae7fed2e3452bf04190ffbbe092
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40cd0b7d4b453587409def768c5f4575d2190c57bb4e31fbd7e6ccbc8995e60a9246c651bbb1727d77e6a61024f159e0d42178058d05fda6e983826b245cf039
|
|
7
|
+
data.tar.gz: b886f357a5a29a8e5cefad36bdd789e5b4a73ed19e247dd7e387ceba07bc6a13c66de46c341eb3c0ce604f85dddb478714ef2c3c8dcdf69a7245f46d755ceb29
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
|
|
5
|
+
## [1.2.0] - 2026-11-03
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Uses cinebase 5.9: performances take the raw `title:`, so audience labels become variants, and series prefixes such as `Met Opera:` become the performance's `event`.
|
|
9
|
+
|
|
10
|
+
## [1.1.0] - 2026-10-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Cinema#latitude` and `Cinema#longitude` as Floats in decimal degrees, from the Vista sites response. They are `nil` when a site has no location or sits at 0, 0.
|
|
14
|
+
- `CurzonUk.ensure_token!` fetches a guest token only when there is none or it expires within an hour, and `CurzonUk.token_expires_at` reads its expiry. Both come from cinebase's `Vista::TokenHolder`.
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- A token the API rejects is cleared from `CurzonUk.token`, so the next `ensure_token!` fetches a fresh one.
|
|
18
|
+
- Requires cinebase 5.6.
|
|
19
|
+
|
|
5
20
|
## [1.0.0] - 2026-10-22
|
|
6
21
|
|
|
7
22
|
### Added
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -53,9 +53,21 @@ CurzonUk.token = ENV.fetch('CURZON_TOKEN')
|
|
|
53
53
|
```
|
|
54
54
|
|
|
55
55
|
Tokens currently last 12 hours. The gem checks the declared expiry but does not
|
|
56
|
-
verify the signature.
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
verify the signature. Normal API calls never acquire or renew a token
|
|
57
|
+
automatically. `CurzonUk.ensure_token!` fetches one only when there is no token,
|
|
58
|
+
or the token expires within an hour, and otherwise keeps the current one. Call
|
|
59
|
+
it before each batch of requests:
|
|
60
|
+
|
|
61
|
+
``` ruby
|
|
62
|
+
CurzonUk.ensure_token!
|
|
63
|
+
CurzonUk.token_expires_at
|
|
64
|
+
#=> 2026-10-31 03:00:00 UTC
|
|
65
|
+
CurzonUk::Cinema.all
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Missing, expired or rejected tokens raise `CurzonUk::AuthenticationError`. A
|
|
69
|
+
token the API rejects is cleared from `CurzonUk.token`, so the next
|
|
70
|
+
`ensure_token!` fetches a fresh one.
|
|
59
71
|
|
|
60
72
|
### Cinema
|
|
61
73
|
|
|
@@ -84,6 +96,12 @@ cinema.brand
|
|
|
84
96
|
cinema.full_name
|
|
85
97
|
#=> 'Curzon Soho'
|
|
86
98
|
|
|
99
|
+
cinema.latitude
|
|
100
|
+
#=> 51.5127983093262
|
|
101
|
+
|
|
102
|
+
cinema.longitude
|
|
103
|
+
#=> -0.130500003695488
|
|
104
|
+
|
|
87
105
|
cinema.url
|
|
88
106
|
#=> 'https://www.curzon.com/venues/soho/'
|
|
89
107
|
```
|
data/curzon_uk.gemspec
CHANGED
data/lib/curzon_uk/cinema.rb
CHANGED
|
@@ -68,6 +68,24 @@ module CurzonUk
|
|
|
68
68
|
'Curzon'.freeze
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
+
# Latitude of the cinema
|
|
72
|
+
# @return [Float, nil] decimal degrees, or nil when unknown
|
|
73
|
+
# @example
|
|
74
|
+
# CurzonUk::Cinema.new('SOH1').latitude
|
|
75
|
+
# #=> 51.5127983093262
|
|
76
|
+
def latitude
|
|
77
|
+
coordinates&.first
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Longitude of the cinema
|
|
81
|
+
# @return [Float, nil] decimal degrees, or nil when unknown
|
|
82
|
+
# @example
|
|
83
|
+
# CurzonUk::Cinema.new('SOH1').longitude
|
|
84
|
+
# #=> -0.130500003695488
|
|
85
|
+
def longitude
|
|
86
|
+
coordinates&.last
|
|
87
|
+
end
|
|
88
|
+
|
|
71
89
|
# The name of the cinema
|
|
72
90
|
# @return [String]
|
|
73
91
|
# @example
|
|
@@ -102,6 +120,13 @@ module CurzonUk
|
|
|
102
120
|
end
|
|
103
121
|
end
|
|
104
122
|
|
|
123
|
+
# 0, 0 marks a site whose position was never set
|
|
124
|
+
def coordinates
|
|
125
|
+
location = site_hash['location'] || {}
|
|
126
|
+
pair = [location['latitude'], location['longitude']]
|
|
127
|
+
pair.map(&:to_f) if pair.all?(Numeric) && pair.any?(&:nonzero?)
|
|
128
|
+
end
|
|
129
|
+
|
|
105
130
|
def site_hash
|
|
106
131
|
@site_hash ||= self.class.send(:sites_hash).fetch(id, {})
|
|
107
132
|
end
|
|
@@ -12,23 +12,31 @@ module CurzonUk
|
|
|
12
12
|
|
|
13
13
|
# @return [Array<Hash>] cinemas
|
|
14
14
|
def sites
|
|
15
|
-
|
|
15
|
+
get("sites").fetch("sites")
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# @param [String] cinema_id site id, e.g. 'ALD1'
|
|
19
19
|
# @param [Date] date business date
|
|
20
20
|
# @return [Hash] showtimes plus their related films and attributes
|
|
21
21
|
def showtimes(cinema_id, date)
|
|
22
|
-
|
|
22
|
+
get("showtimes/by-business-date/#{date.iso8601}",
|
|
23
23
|
"siteIds" => cinema_id)
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
private
|
|
27
27
|
|
|
28
|
+
def get(path, query = {})
|
|
29
|
+
token = CurzonUk.token
|
|
30
|
+
client(token).get(path, query)
|
|
31
|
+
rescue Cinebase::Vista::AuthenticationError
|
|
32
|
+
CurzonUk.reject_token!(token)
|
|
33
|
+
raise
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
# Curzon's API needs no Connect-Region-Code.
|
|
29
|
-
def client
|
|
37
|
+
def client(token)
|
|
30
38
|
Cinebase::Vista::Client.new(base_url: BASE_URL, region_code: nil,
|
|
31
|
-
token:
|
|
39
|
+
token: token)
|
|
32
40
|
end
|
|
33
41
|
end
|
|
34
42
|
end
|
data/lib/curzon_uk/version.rb
CHANGED
data/lib/curzon_uk.rb
CHANGED
|
@@ -18,13 +18,10 @@ require_relative './curzon_uk/performance'
|
|
|
18
18
|
module CurzonUk
|
|
19
19
|
AuthenticationError = Cinebase::Vista::AuthenticationError
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def acquire_token!(curl: nil)
|
|
27
|
-
self.token = Internal::GuestToken.new(curl: curl).fetch
|
|
28
|
-
end
|
|
21
|
+
extend Cinebase::Vista::TokenHolder
|
|
22
|
+
|
|
23
|
+
# @api private
|
|
24
|
+
def self.guest_token_class
|
|
25
|
+
Internal::GuestToken
|
|
29
26
|
end
|
|
30
27
|
end
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
{
|
|
4
4
|
"id": "CAN2",
|
|
5
5
|
"name": { "text": "Canterbury" },
|
|
6
|
+
"location": { "latitude": 0, "longitude": 0 },
|
|
6
7
|
"contactDetails": {
|
|
7
8
|
"addressV2": {
|
|
8
9
|
"line1": { "text": "Unit 9," },
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
{
|
|
16
17
|
"id": "SOH1",
|
|
17
18
|
"name": { "text": "Soho" },
|
|
19
|
+
"location": { "latitude": 51.5127983093262, "longitude": -0.130500003695488 },
|
|
18
20
|
"contactDetails": {
|
|
19
21
|
"addressV2": {
|
|
20
22
|
"line1": { "text": "99 Example Avenue," },
|
|
@@ -58,6 +58,29 @@ class CurzonUk::CinemaTest < Minitest::Test
|
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
def test_latitude_and_longitude
|
|
62
|
+
with_fake_api do
|
|
63
|
+
cinema = CurzonUk::Cinema.new('SOH1')
|
|
64
|
+
|
|
65
|
+
assert_in_delta 51.5128, cinema.latitude, 0.0001
|
|
66
|
+
assert_in_delta(-0.1305, cinema.longitude, 0.0001)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def test_latitude_and_longitude_are_nil_without_a_location
|
|
71
|
+
with_fake_api do
|
|
72
|
+
assert_nil CurzonUk::Cinema.new('VIC1').latitude
|
|
73
|
+
assert_nil CurzonUk::Cinema.new('VIC1').longitude
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def test_latitude_and_longitude_are_nil_at_zero_zero
|
|
78
|
+
with_fake_api do
|
|
79
|
+
assert_nil CurzonUk::Cinema.new('CAN2').latitude
|
|
80
|
+
assert_nil CurzonUk::Cinema.new('CAN2').longitude
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
61
84
|
def test_name
|
|
62
85
|
with_fake_api do
|
|
63
86
|
assert_equal 'Soho', CurzonUk::Cinema.new('SOH1').name
|
|
@@ -44,6 +44,14 @@ class CurzonUk::Internal::ApiResponseTest < Minitest::Test
|
|
|
44
44
|
assert_raises(CurzonUk::AuthenticationError) { api.sites }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
def test_rejected_token_is_cleared
|
|
48
|
+
stub_request(:get, "#{BASE_URL}/sites").to_return(status: 401)
|
|
49
|
+
|
|
50
|
+
assert_raises(CurzonUk::AuthenticationError) { api.sites }
|
|
51
|
+
|
|
52
|
+
assert_nil CurzonUk.token
|
|
53
|
+
end
|
|
54
|
+
|
|
47
55
|
private
|
|
48
56
|
|
|
49
57
|
def api
|
|
@@ -58,6 +58,13 @@ class CurzonUk::Internal::GuestTokenTest < Minitest::Test
|
|
|
58
58
|
assert_match(/curl-impersonate/, error.message)
|
|
59
59
|
end
|
|
60
60
|
|
|
61
|
+
def test_ensure_token_fetches_only_without_a_current_token
|
|
62
|
+
token = token_expiring_at(Time.now + 7200)
|
|
63
|
+
|
|
64
|
+
assert_equal token, CurzonUk.ensure_token!(curl: fake_curl("#{page_with(token)}\n200"))
|
|
65
|
+
assert_equal token, CurzonUk.ensure_token!(curl: File.join(@directory, 'missing'))
|
|
66
|
+
end
|
|
67
|
+
|
|
61
68
|
def test_acquire_token_sets_token
|
|
62
69
|
token = token_expiring_at(Time.now + 3600)
|
|
63
70
|
|
|
@@ -35,6 +35,19 @@ class CurzonUk::PerformanceTest < Minitest::Test
|
|
|
35
35
|
assert_equal 'https://www.curzon.com/ticketing/seats/?showtimeId=SOH1-1001', performance.booking_url
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
+
def test_at_reads_audience_from_title
|
|
39
|
+
@api_response.define_singleton_method(:showtimes) do |cinema_id, date|
|
|
40
|
+
super(cinema_id, date).tap do |data|
|
|
41
|
+
data.dig('relatedData', 'films', 0, 'title')['text'] = 'Kids Club: Wonka'
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
performance = performances_at('SOH1').first
|
|
45
|
+
|
|
46
|
+
assert_equal 'Kids Club: Wonka', performance.title
|
|
47
|
+
assert_equal 'Wonka', performance.film_name
|
|
48
|
+
assert_equal %w(kids), performance.variant
|
|
49
|
+
end
|
|
50
|
+
|
|
38
51
|
def test_at_parses_3d_open_captions
|
|
39
52
|
performance = performances_at('SOH1')[1]
|
|
40
53
|
|
|
@@ -14,6 +14,16 @@ class LiveCinemaTest < Minitest::Test
|
|
|
14
14
|
refute_empty cinema.postal_code, "#{cinema.id} #{cinema.name}"
|
|
15
15
|
end
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
def test_cinemas_have_uk_coordinates
|
|
19
|
+
located = CurzonUk::Cinema.all.select(&:latitude)
|
|
20
|
+
|
|
21
|
+
refute_empty located
|
|
22
|
+
located.each do |cinema|
|
|
23
|
+
assert_includes 49.0..61.0, cinema.latitude, "#{cinema.id} #{cinema.name}"
|
|
24
|
+
assert_includes(-9.0..2.0, cinema.longitude, "#{cinema.id} #{cinema.name}")
|
|
25
|
+
end
|
|
26
|
+
end
|
|
17
27
|
end
|
|
18
28
|
|
|
19
29
|
class LivePerformanceTest < Minitest::Test
|
data/test/support/api_shapes.rb
CHANGED
|
@@ -16,6 +16,11 @@ module ApiShapes
|
|
|
16
16
|
line = address.fetch(key)
|
|
17
17
|
assert_kind_of String, line.fetch('text'), "site #{site['id']} #{key}" unless line.nil?
|
|
18
18
|
end
|
|
19
|
+
location = site['location'] || {}
|
|
20
|
+
%w(latitude longitude).each do |key|
|
|
21
|
+
value = location[key]
|
|
22
|
+
assert_kind_of Numeric, value, "site #{site['id']} #{key}" unless value.nil?
|
|
23
|
+
end
|
|
19
24
|
end
|
|
20
25
|
end
|
|
21
26
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: curzon_uk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andy Croll
|
|
@@ -113,14 +113,14 @@ dependencies:
|
|
|
113
113
|
requirements:
|
|
114
114
|
- - "~>"
|
|
115
115
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: '5.
|
|
116
|
+
version: '5.9'
|
|
117
117
|
type: :runtime
|
|
118
118
|
prerelease: false
|
|
119
119
|
version_requirements: !ruby/object:Gem::Requirement
|
|
120
120
|
requirements:
|
|
121
121
|
- - "~>"
|
|
122
122
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: '5.
|
|
123
|
+
version: '5.9'
|
|
124
124
|
description: Pull movie & cinema information from the Curzon Vista API
|
|
125
125
|
email:
|
|
126
126
|
- andy@goodscary.com
|