gillbus 0.18.14 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gillbus.rb +1 -0
- data/lib/gillbus/structs/tickets_option.rb +29 -0
- data/lib/gillbus/structs/trip_options.rb +4 -0
- data/lib/gillbus/version.rb +1 -1
- data/test/error_test.rb +1 -1
- data/test/responses/searchTrips-prod.xml +3 -0
- data/test/search_trips_test.rb +6 -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: 48a23c8133793e9abcc37a872de7d32807c4b8b7
|
4
|
+
data.tar.gz: 411679015803b8c36d9a4a4c529b3a006910feef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91ed219a443d7e9e4c4b4be9fab6824988c4477dd3b86225ee4ee88daaf6c209aa76d284d08a98194a37afc75619109148433196f98a397f1e406f94dcaf4d08
|
7
|
+
data.tar.gz: 55b828d21194d0d877d410174bba84464ff25684e034cac91663e8a3594dfa03dad02a3541506b021cdb48ac0b2a434060cfd476953d69ade3a3154b48cab495
|
data/lib/gillbus.rb
CHANGED
@@ -67,6 +67,7 @@ class Gillbus
|
|
67
67
|
require 'gillbus/helpers/parser'
|
68
68
|
|
69
69
|
require 'gillbus/structs/trip_service'
|
70
|
+
require 'gillbus/structs/tickets_option'
|
70
71
|
require 'gillbus/structs/trip_options'
|
71
72
|
require 'gillbus/structs/point'
|
72
73
|
require 'gillbus/structs/tariff/return_cause'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class Gillbus
|
2
|
+
class TicketsOption
|
3
|
+
extend Fields
|
4
|
+
include UpdateAttrs
|
5
|
+
|
6
|
+
# идентификатор опции
|
7
|
+
field :id, :int, key: 'ID'
|
8
|
+
|
9
|
+
# текст опции
|
10
|
+
field :text, :string, key: :__content__
|
11
|
+
|
12
|
+
def self.parse(doc, instance: nil, parent: nil, options: {})
|
13
|
+
instance = new
|
14
|
+
if doc.is_a?(String)
|
15
|
+
instance.text = doc
|
16
|
+
elsif doc.is_a?(Array)
|
17
|
+
raise ArgumentError, "Unable to parse TicketsOption: #{doc.inspect}" unless doc.size == 2
|
18
|
+
instance.id = doc.first.fetch('ID').to_i
|
19
|
+
instance.text = doc.last
|
20
|
+
elsif doc.is_a?(Hash) #legacy data made with MultiXML
|
21
|
+
instance.id = doc.fetch('ID')
|
22
|
+
instance.text = doc.fetch('__content__')
|
23
|
+
else
|
24
|
+
raise ArgumentError, "Unable to parse TicketsOption: #{doc.inspect}"
|
25
|
+
end
|
26
|
+
instance
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -30,6 +30,10 @@ class Gillbus
|
|
30
30
|
# признак рекомендованого рейса, передается как <PROMO><ITEM>BUSFOR_RECOMMEND</ITEM></PROMO>
|
31
31
|
field :busfor_recommend, :recommend_bool, root: 'PROMO', key: 'ITEM'
|
32
32
|
|
33
|
+
# опции, связанные с билетами
|
34
|
+
# элемент с ID="7" означает электронный билет
|
35
|
+
field :tickets, [TicketsOption], root: 'TICKETS', key: 'TICKET'
|
36
|
+
|
33
37
|
parser do # better not to let flag value out of this gem
|
34
38
|
def adertising_bool(vals)
|
35
39
|
vals.include?('ADVERTISING')
|
data/lib/gillbus/version.rb
CHANGED
data/test/error_test.rb
CHANGED
@@ -22,7 +22,7 @@ class ErrorTest < Minitest::Test
|
|
22
22
|
|
23
23
|
def test_malformed_errorness
|
24
24
|
assert malformed_response.error?
|
25
|
-
|
25
|
+
assert malformed_response.error_message.include?("Malformed response: invalid format")
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_malformed_2_errorness
|
data/test/search_trips_test.rb
CHANGED
@@ -150,6 +150,10 @@ class SearchTripsResponseTest < Minitest::Test
|
|
150
150
|
'Трансфер',
|
151
151
|
'Cкидка при покупке раунд-трипа',
|
152
152
|
]
|
153
|
+
titckets_options = [
|
154
|
+
'ЭЛЕКТРОННЫЙ БИЛЕТ. Печать билета не требуется!',
|
155
|
+
]
|
156
|
+
titckets_options_ids = [7]
|
153
157
|
|
154
158
|
assert_equal services.values, options.services.map(&:name)
|
155
159
|
assert_equal services.keys, options.services.map(&:id)
|
@@ -159,6 +163,8 @@ class SearchTripsResponseTest < Minitest::Test
|
|
159
163
|
assert_equal critical_info, options.critical_info
|
160
164
|
assert_equal resource_options, options.resource_options
|
161
165
|
assert_equal other_options, options.other
|
166
|
+
assert_equal titckets_options, options.tickets.map(&:text)
|
167
|
+
assert_equal titckets_options_ids, options.tickets.map(&:id)
|
162
168
|
assert options.advertising
|
163
169
|
assert options.busfor_recommend
|
164
170
|
end
|
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.19.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: 2019-
|
12
|
+
date: 2019-02-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -214,6 +214,7 @@ files:
|
|
214
214
|
- lib/gillbus/structs/tariff.rb
|
215
215
|
- lib/gillbus/structs/tariff/return_cause.rb
|
216
216
|
- lib/gillbus/structs/ticket.rb
|
217
|
+
- lib/gillbus/structs/tickets_option.rb
|
217
218
|
- lib/gillbus/structs/timetable_segment.rb
|
218
219
|
- lib/gillbus/structs/timetable_trip.rb
|
219
220
|
- lib/gillbus/structs/trip.rb
|