gillbus 0.20.7 → 0.20.8

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
  SHA256:
3
- metadata.gz: c2e0833d277086c53aa7b0c7200cc08f82a8c4afab04ab9f734e921efe9a8653
4
- data.tar.gz: e9032330fad73fc9d6481145a7addb761a6c2f8b045c6eb27b5cebfeede07034
3
+ metadata.gz: f8361c79694f78a6bf0e69712d72128d8ece89e53677eab24b5534b5662e096b
4
+ data.tar.gz: 4e0efe0e59ffd350698ded2cc7a6fbd70ec097703e6ff84f69a56ed0bfb0766f
5
5
  SHA512:
6
- metadata.gz: 3a113a7163c1c480b69657eb4aa4a9fdf7c8b19e5999f2a4e37eeeae3bca0edf7da783fd4eaa5cb6af4cf2d364ed143ac5bca0048d570f32e4cb4b15a1cd2585
7
- data.tar.gz: 827dbfde7454a93a01d6391620c58e4640f28fdc835f61ba96e3974d3023c8c3feb6204dfd081761b525e3d07c3814bba68fc7e44c960b8e16179970dc1691d8
6
+ metadata.gz: fb84cdcebde50aa95fc7a0d181c9e3ae93817921d0630e09a296b7995acc25cb3646f76801f8b81da31db792178bd21fbeb67695c1dd12b3cd4c79f075362879
7
+ data.tar.gz: 4e4b7b34efd3975617d71e788dc885b901ab1a320551364f818826169b5e552bae95d1fc125cda57ace11e8e55365cc1a3272f1b670da8ccb7aab4f42e6aa296
@@ -283,6 +283,8 @@ class Gillbus
283
283
 
284
284
  field :is_online_refund, :bool
285
285
 
286
+ field :is_baggage, :bool
287
+
286
288
  parser do
287
289
  def ticket_status(value)
288
290
  ::Gillbus::Ticket::STATUS_MAPPING[value]
@@ -147,11 +147,29 @@ class Gillbus
147
147
  # Величина скидки в валюте продажи для пассажира с порядковым номером 0…N.
148
148
  attr_accessor :discount
149
149
 
150
+ # passenger0baggageCount... passengerNbaggageCount (не обязательный)
151
+ # На рейс без сегментов
152
+ # Количество мест багажа для пассажира с порядковым номером 0...N.
153
+ attr_accessor :baggage
154
+
155
+ # passenger0segment0baggageCount... passengerNsegmentMbaggageCount
156
+ # На рейс с сегментами
157
+ # Количество мест багажа для пассажира 0...N на сегмент 0...M
158
+ attr_accessor :segments_baggage
150
159
 
151
160
  attr_accessor :insurance_id
152
161
  attr_accessor :insurance_cost
153
162
 
154
163
  def params(prefix = '')
164
+ # [0, 1] => {'segment0baggageCount' => 0, 'segment1baggageCount' => 1}
165
+ prepared_segments_baggage =
166
+ if segments_baggage
167
+ segments_baggage.map.with_index do |baggage_count, index|
168
+ ["segment#{index}baggageCount".to_sym, baggage_count]
169
+ end.to_h
170
+ else
171
+ {}
172
+ end
155
173
  compact(
156
174
  birthday: date(birthday),
157
175
  ISIC: isic,
@@ -168,6 +186,8 @@ class Gillbus
168
186
  discountValue: discount.to_f.to_s,
169
187
  insuranceId: insurance_id,
170
188
  insurance: insurance_cost,
189
+ baggageCount: baggage&.first, # baggage используется для односегментных
190
+ **prepared_segments_baggage,
171
191
  ).map { |k, v| [:"#{prefix}#{k}", v] }.to_h
172
192
  end
173
193
 
@@ -1,3 +1,3 @@
1
1
  class Gillbus
2
- VERSION = '0.20.7'.freeze
2
+ VERSION = '0.20.8'.freeze
3
3
  end
@@ -71,5 +71,6 @@
71
71
  <VAT>3.33</VAT>
72
72
  <CURRENCY>UAH</CURRENCY>
73
73
  </COMMISSION>
74
+ <IS_BAGGAGE>true</IS_BAGGAGE>
74
75
  </TICKET>
75
76
  </DATA>
@@ -12,4 +12,67 @@ class TicketsBookingTest < Minitest::Test
12
12
  def test_total
13
13
  assert_equal(Money.new(110_00, 'UAH'), tickets_booking.tickets.first.total_amount)
14
14
  end
15
+
16
+ def test_params_generation_with_no_baggage
17
+ request = Gillbus::TicketsBooking::Request.new(
18
+ passengers: [
19
+ { },
20
+ { },
21
+ ],
22
+ )
23
+ expected_params = {
24
+ passenger0discountValue: '0.0',
25
+ passenger1discountValue: '0.0',
26
+ }
27
+ assert_equal expected_params, request.params
28
+ end
29
+
30
+ def test_params_generation_with_baggage_with_one_segment
31
+ request = Gillbus::TicketsBooking::Request.new(
32
+ passengers: [
33
+ {
34
+ baggage: [1],
35
+ },
36
+ {
37
+ baggage: [2],
38
+ }
39
+ ],
40
+ )
41
+ expected_params = {
42
+ passenger0discountValue: '0.0',
43
+ passenger0baggageCount: 1,
44
+ passenger1discountValue: '0.0',
45
+ passenger1baggageCount: 2,
46
+ }
47
+ assert_equal expected_params, request.params
48
+ end
49
+
50
+ def test_params_generation_with_baggage_with_two_segments
51
+ request = Gillbus::TicketsBooking::Request.new(
52
+ passengers: [
53
+ {
54
+ segments_baggage: [0, 1],
55
+ },
56
+ {
57
+ segments_baggage: [1, 0],
58
+ }
59
+ ],
60
+ )
61
+ expected_params = {
62
+ passenger0discountValue: '0.0',
63
+ passenger0segment0baggageCount: 0,
64
+ passenger0segment1baggageCount: 1,
65
+ passenger1discountValue: '0.0',
66
+ passenger1segment0baggageCount: 1,
67
+ passenger1segment1baggageCount: 0,
68
+ }
69
+ assert_equal expected_params, request.params
70
+ end
71
+
72
+ def test_parse_is_baggage_field
73
+ response = tickets_booking
74
+ ticket = response.tickets.first
75
+
76
+ assert_equal true, ticket.is_baggage
77
+ end
15
78
  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.20.7
4
+ version: 0.20.8
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-10-24 00:00:00.000000000 Z
12
+ date: 2019-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport