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 +4 -4
- data/lib/gillbus/structs/ticket.rb +2 -0
- data/lib/gillbus/tickets_booking.rb +20 -0
- data/lib/gillbus/version.rb +1 -1
- data/test/responses/ticketsBooking.xml +1 -0
- data/test/tickets_booking_test.rb +63 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8361c79694f78a6bf0e69712d72128d8ece89e53677eab24b5534b5662e096b
|
4
|
+
data.tar.gz: 4e0efe0e59ffd350698ded2cc7a6fbd70ec097703e6ff84f69a56ed0bfb0766f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb84cdcebde50aa95fc7a0d181c9e3ae93817921d0630e09a296b7995acc25cb3646f76801f8b81da31db792178bd21fbeb67695c1dd12b3cd4c79f075362879
|
7
|
+
data.tar.gz: 4e4b7b34efd3975617d71e788dc885b901ab1a320551364f818826169b5e552bae95d1fc125cda57ace11e8e55365cc1a3272f1b670da8ccb7aab4f42e6aa296
|
@@ -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
|
|
data/lib/gillbus/version.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|