gillbus 0.14.12 → 0.15.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/lib/gillbus/structs/segment.rb +2 -0
- data/lib/gillbus/structs/trip.rb +1 -1
- data/lib/gillbus/structs/trip_options.rb +29 -0
- data/lib/gillbus/structs/trip_service.rb +14 -0
- data/lib/gillbus/version.rb +1 -1
- data/lib/gillbus.rb +2 -0
- data/test/responses/searchTrips-prod.xml +28 -2
- data/test/search_trips_test.rb +54 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86ff42495ca0ac91395ca7d2f44e1109fd95a90b
|
4
|
+
data.tar.gz: ae27c073ed4ef845cee4f0099e5d16bad8f016b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25cf62b5632ad96b9bdca312474c26a7b04427b4b9f45a5ceb318e2484f76961e9f76862be71559edf68f03a0c4d7462d368dbb12b214a2714dd750294e12ed
|
7
|
+
data.tar.gz: 2b3cb677803aa430333282840918bef9326f16c8f2f7631f9af969cfabc7cccec5de634e78e60cb7a9ee1ab499a32c2226d4c0716d20769ea2c6cb66b25a49b3
|
data/lib/gillbus/structs/trip.rb
CHANGED
@@ -149,7 +149,7 @@ class Gillbus
|
|
149
149
|
|
150
150
|
field :segments, [Segment], key: "SEGMENT"
|
151
151
|
|
152
|
-
field :options,
|
152
|
+
field :options, TripOptions, key: 'OPTIONS'
|
153
153
|
|
154
154
|
def start_at
|
155
155
|
ActiveSupport::TimeZone["Europe/Kiev"].parse("#{data["START_DATE"]} #{data["START_TIME"]}")
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Gillbus
|
2
|
+
class TripOptions
|
3
|
+
|
4
|
+
extend Fields
|
5
|
+
include UpdateAttrs
|
6
|
+
|
7
|
+
# услуги на рейсе (Wi-Fi, розетки и т.п.)
|
8
|
+
field :services, [TripService], root: 'TRIP_SERVICES', key: 'TRIP_SERVICE'
|
9
|
+
|
10
|
+
# условия по багажу на рейсе
|
11
|
+
field :luggage, [:string], root: 'LUGGAGE', key: 'ITEM'
|
12
|
+
|
13
|
+
# условия рассадки на рейсе
|
14
|
+
field :seating, [:string], root: 'SEATING', key: 'ITEM'
|
15
|
+
|
16
|
+
# информация о технических остановках
|
17
|
+
field :technical_stops, [:string], root: 'TECHNICAL_STOP', key: 'ITEM'
|
18
|
+
|
19
|
+
# критичная информация о рейсе
|
20
|
+
field :critical_info, [:string], root: 'CRITICAL_INFO', key: 'ITEM'
|
21
|
+
|
22
|
+
# опции полученные от внешних ресурсов
|
23
|
+
field :resource_options, [:string], root: 'RESOURCE_TRIP_OPTION', key: 'ITEM'
|
24
|
+
|
25
|
+
# информация, отмеченная как "прочее"
|
26
|
+
field :other, [:string], root: 'OTHER', key: 'ITEM'
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
data/lib/gillbus/version.rb
CHANGED
data/lib/gillbus.rb
CHANGED
@@ -41,6 +41,8 @@ class Gillbus
|
|
41
41
|
require 'gillbus/helpers/update_attrs'
|
42
42
|
require 'gillbus/helpers/parser'
|
43
43
|
|
44
|
+
require 'gillbus/structs/trip_service'
|
45
|
+
require 'gillbus/structs/trip_options'
|
44
46
|
require 'gillbus/structs/point'
|
45
47
|
require 'gillbus/structs/tariff'
|
46
48
|
require 'gillbus/structs/segment'
|
@@ -101,8 +101,32 @@
|
|
101
101
|
<CHECK_POINT>false</CHECK_POINT>
|
102
102
|
</POINT>
|
103
103
|
<OPTIONS>
|
104
|
-
<
|
105
|
-
|
104
|
+
<TRIP_SERVICES>
|
105
|
+
<TRIP_SERVICE ID="1">Кофе</TRIP_SERVICE>
|
106
|
+
<TRIP_SERVICE ID="15">Wi-Fi</TRIP_SERVICE>
|
107
|
+
</TRIP_SERVICES>
|
108
|
+
<LUGGAGE>
|
109
|
+
<ITEM>В стоимость входит провоз 2 единиц багажа свыше 80 кг.</ITEM>
|
110
|
+
<ITEM>Ручная кладь 20см x 40см x 30см входит в стоимость билета.</ITEM>
|
111
|
+
<ITEM>Превышение по багажу оплачивается в размере 1% от стоимости тарифа.</ITEM>
|
112
|
+
</LUGGAGE>
|
113
|
+
<TECHNICAL_STOP>
|
114
|
+
<ITEM>Технические остановки осуществляются каждые 2-3 часа.</ITEM>
|
115
|
+
</TECHNICAL_STOP>
|
116
|
+
<CRITICAL_INFO>
|
117
|
+
<ITEM>ВНИМАНИЕ: Особые условия паспортного режима пересечения пропускного пункта (только с паспортами РБ и РФ).</ITEM>
|
118
|
+
</CRITICAL_INFO>
|
119
|
+
<SEATING>
|
120
|
+
<ITEM>Свободная рассадка.</ITEM>
|
121
|
+
</SEATING>
|
122
|
+
<RESOURCE_TRIP_OPTION>
|
123
|
+
<ITEM>Посадка начинается за 10 мин.</ITEM>
|
124
|
+
</RESOURCE_TRIP_OPTION>
|
125
|
+
<OTHER>
|
126
|
+
<ITEM>Переправа</ITEM>
|
127
|
+
<ITEM>Трансфер</ITEM>
|
128
|
+
<ITEM>Cкидка при покупке раунд-трипа</ITEM>
|
129
|
+
</OTHER>
|
106
130
|
</OPTIONS>
|
107
131
|
</TRIP>
|
108
132
|
<TRIP>
|
@@ -201,5 +225,7 @@
|
|
201
225
|
<DISPATCH_TIME/>
|
202
226
|
<CHECK_POINT>false</CHECK_POINT>
|
203
227
|
</POINT>
|
228
|
+
<OPTIONS>
|
229
|
+
</OPTIONS>
|
204
230
|
</TRIP>
|
205
231
|
</DATA>
|
data/test/search_trips_test.rb
CHANGED
@@ -84,13 +84,66 @@ class SearchTripsResponseTest < Minitest::Test
|
|
84
84
|
assert_equal 'Europe/Moscow', response.trips.first.start_timezone
|
85
85
|
assert_equal 'Europe/Moscow', response.trips.first.end_timezone
|
86
86
|
assert_equal true, response.trips.first.fake_time_in_road
|
87
|
-
assert_equal ['Кофе', 'Wi-Fi'], response.trips.first.options
|
88
87
|
assert_equal false, response.trips[1].recommended
|
89
88
|
assert_equal true, response.trips.first.recommended
|
90
89
|
assert_equal ['cause 1', 'cause 2'], response.trips.first.tariffs.first.return_cause
|
91
90
|
assert_equal ['cause 1'], response.trips[1].tariffs.first.return_cause
|
92
91
|
end
|
93
92
|
|
93
|
+
def test_options_parsing
|
94
|
+
response = get_successful_search_trips
|
95
|
+
options = response.trips.first.options
|
96
|
+
|
97
|
+
services = {
|
98
|
+
1 => 'Кофе',
|
99
|
+
15 => 'Wi-Fi'
|
100
|
+
}
|
101
|
+
luggage_options = [
|
102
|
+
'В стоимость входит провоз 2 единиц багажа свыше 80 кг.',
|
103
|
+
'Ручная кладь 20см x 40см x 30см входит в стоимость билета.',
|
104
|
+
'Превышение по багажу оплачивается в размере 1% от стоимости тарифа.'
|
105
|
+
]
|
106
|
+
seating_options = [
|
107
|
+
'Свободная рассадка.'
|
108
|
+
]
|
109
|
+
technical_stops = [
|
110
|
+
'Технические остановки осуществляются каждые 2-3 часа.'
|
111
|
+
]
|
112
|
+
critical_info = [
|
113
|
+
'ВНИМАНИЕ: Особые условия паспортного режима пересечения пропускного пункта (только с паспортами РБ и РФ).'
|
114
|
+
]
|
115
|
+
resource_options = [
|
116
|
+
'Посадка начинается за 10 мин.'
|
117
|
+
]
|
118
|
+
other_options = [
|
119
|
+
'Переправа',
|
120
|
+
'Трансфер',
|
121
|
+
'Cкидка при покупке раунд-трипа'
|
122
|
+
]
|
123
|
+
|
124
|
+
assert_equal services.values, options.services.map(&:name)
|
125
|
+
assert_equal services.keys, options.services.map(&:id)
|
126
|
+
assert_equal luggage_options, options.luggage
|
127
|
+
assert_equal seating_options, options.seating
|
128
|
+
assert_equal technical_stops, options.technical_stops
|
129
|
+
assert_equal critical_info, options.critical_info
|
130
|
+
assert_equal resource_options, options.resource_options
|
131
|
+
assert_equal other_options, options.other
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_empty_options_parsing
|
135
|
+
response = get_successful_search_trips
|
136
|
+
options = response.trips.last.options
|
137
|
+
|
138
|
+
assert_equal [], options.services
|
139
|
+
assert_equal [], options.luggage
|
140
|
+
assert_equal [], options.seating
|
141
|
+
assert_equal [], options.technical_stops
|
142
|
+
assert_equal [], options.critical_info
|
143
|
+
assert_equal [], options.resource_options
|
144
|
+
assert_equal [], options.other
|
145
|
+
end
|
146
|
+
|
94
147
|
def test_fields_parsing_bad_data
|
95
148
|
response = get_successful_search_trips_with_bad_data
|
96
149
|
assert response.error?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gillbus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey "codesnik" Trofimenko
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-08-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|
@@ -194,6 +194,8 @@ files:
|
|
194
194
|
- lib/gillbus/structs/timetable_segment.rb
|
195
195
|
- lib/gillbus/structs/timetable_trip.rb
|
196
196
|
- lib/gillbus/structs/trip.rb
|
197
|
+
- lib/gillbus/structs/trip_options.rb
|
198
|
+
- lib/gillbus/structs/trip_service.rb
|
197
199
|
- lib/gillbus/tickets_booking.rb
|
198
200
|
- lib/gillbus/unlock_seats.rb
|
199
201
|
- lib/gillbus/version.rb
|