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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a7314c8cf6fe9167342a9fa5afa2a79f3c9d9d4
4
- data.tar.gz: 41d2a8dcf95cbc8826e6e67d1718cc612b287b8e
3
+ metadata.gz: 48a23c8133793e9abcc37a872de7d32807c4b8b7
4
+ data.tar.gz: 411679015803b8c36d9a4a4c529b3a006910feef
5
5
  SHA512:
6
- metadata.gz: 044121e759ccbcd4d07a6ae1af71dc63fbea7b5c811e2bed2742c00e6cbef5f075c2f9c6949340dd10925711c63fd3a0b9b2dc54779f213c6ff5dbc615deb521
7
- data.tar.gz: f656e036e42f486ed88cf5a1e690860c6b7eb163325a9f2d7be0360f1f8c6ec2876a5467658ea9b20d1f71d0c616c349ef0a1ba88079eb131d369f814ed6a7bb
6
+ metadata.gz: 91ed219a443d7e9e4c4b4be9fab6824988c4477dd3b86225ee4ee88daaf6c209aa76d284d08a98194a37afc75619109148433196f98a397f1e406f94dcaf4d08
7
+ data.tar.gz: 55b828d21194d0d877d410174bba84464ff25684e034cac91663e8a3594dfa03dad02a3541506b021cdb48ac0b2a434060cfd476953d69ade3a3154b48cab495
@@ -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')
@@ -1,3 +1,3 @@
1
1
  class Gillbus
2
- VERSION = '0.18.14'.freeze
2
+ VERSION = '0.19.0'.freeze
3
3
  end
@@ -22,7 +22,7 @@ class ErrorTest < Minitest::Test
22
22
 
23
23
  def test_malformed_errorness
24
24
  assert malformed_response.error?
25
- assert_equal "Malformed response: invalid format, expected < at line 1, column 1 [parse.c:146]\n", malformed_response.error_message
25
+ assert malformed_response.error_message.include?("Malformed response: invalid format")
26
26
  end
27
27
 
28
28
  def test_malformed_2_errorness
@@ -134,6 +134,9 @@
134
134
  <ITEM>BUSFOR_RECOMMEND</ITEM>
135
135
  <ITEM>ADVERTISING</ITEM>
136
136
  </PROMO>
137
+ <TICKETS>
138
+ <TICKET ID="7">ЭЛЕКТРОННЫЙ БИЛЕТ. Печать билета не требуется!</TICKET>
139
+ </TICKETS>
137
140
  </OPTIONS>
138
141
  </TRIP>
139
142
  <TRIP>
@@ -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.18.14
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-01-10 00:00:00.000000000 Z
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