gillbus 0.20.8 → 0.20.9
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 -1
- data/lib/gillbus/get_required_fields.rb +1 -1
- data/lib/gillbus/structs/luggage.rb +19 -0
- data/lib/gillbus/structs/ticket.rb +1 -1
- data/lib/gillbus/tickets_booking.rb +8 -8
- data/lib/gillbus/version.rb +1 -1
- data/test/get_required_fields_test.rb +33 -33
- data/test/responses/{getRequiredFieldsWithOneBaggage.xml → getRequiredFieldsWithOneLuggage.xml} +0 -0
- data/test/responses/{getRequiredFieldsWithTwoBaggageSegments.xml → getRequiredFieldsWithTwoLuggageSegments.xml} +0 -0
- data/test/responses/{getRequiredFieldsWithoutBaggage.xml → getRequiredFieldsWithoutLuggage.xml} +0 -0
- data/test/tickets_booking_test.rb +8 -8
- metadata +8 -8
- data/lib/gillbus/structs/baggage.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 161f8a17f94402b8ca20cd20a4db0c512f6dc127d8335c2ac2af83e55a3d515a
|
4
|
+
data.tar.gz: 572967b18f23751e5c0932e16943a838d4f0ef1630aae9f08a281d9a2b693f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcba1738e7f4bb40644d0f9fe191367241910e7e69d3e330d6a831f24aa92c95b4e6c9993c34b0b43cd0f28b7abb2de679194d3bfba242e3773d5e6e163e7b3a
|
7
|
+
data.tar.gz: b0a62ce474a083e012e28c8ded9c2ade5d941a9f7e1b34277801cc54047d38e63158b0e2a3815c8a2148c387fd75e452cfbfd0e9de19f62f4ca20715f26a233a
|
data/lib/gillbus.rb
CHANGED
@@ -87,7 +87,7 @@ class Gillbus
|
|
87
87
|
require 'gillbus/structs/item'
|
88
88
|
require 'gillbus/structs/carrier'
|
89
89
|
require 'gillbus/structs/nearby_cities_trip'
|
90
|
-
require 'gillbus/structs/
|
90
|
+
require 'gillbus/structs/luggage'
|
91
91
|
|
92
92
|
require 'gillbus/parse_error'
|
93
93
|
require 'gillbus/base_request'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Gillbus
|
2
|
+
class Luggage
|
3
|
+
extend Fields
|
4
|
+
|
5
|
+
# => "0"
|
6
|
+
field :segment_number, :int
|
7
|
+
|
8
|
+
# => "true"
|
9
|
+
field :is_buy, :bool
|
10
|
+
|
11
|
+
# => "50.5"
|
12
|
+
field :luggage_tariff, :decimal, key: 'BAGGAGE_TARIFF'
|
13
|
+
|
14
|
+
# => "2"
|
15
|
+
field :luggage_limit, :int, key: 'BAGGAGE_LIMIT'
|
16
|
+
|
17
|
+
field :segments, [Luggage], key: 'SEGMENT'
|
18
|
+
end
|
19
|
+
end
|
@@ -150,22 +150,22 @@ class Gillbus
|
|
150
150
|
# passenger0baggageCount... passengerNbaggageCount (не обязательный)
|
151
151
|
# На рейс без сегментов
|
152
152
|
# Количество мест багажа для пассажира с порядковым номером 0...N.
|
153
|
-
attr_accessor :
|
153
|
+
attr_accessor :luggage
|
154
154
|
|
155
155
|
# passenger0segment0baggageCount... passengerNsegmentMbaggageCount
|
156
156
|
# На рейс с сегментами
|
157
157
|
# Количество мест багажа для пассажира 0...N на сегмент 0...M
|
158
|
-
attr_accessor :
|
158
|
+
attr_accessor :segments_luggage
|
159
159
|
|
160
160
|
attr_accessor :insurance_id
|
161
161
|
attr_accessor :insurance_cost
|
162
162
|
|
163
163
|
def params(prefix = '')
|
164
164
|
# [0, 1] => {'segment0baggageCount' => 0, 'segment1baggageCount' => 1}
|
165
|
-
|
166
|
-
if
|
167
|
-
|
168
|
-
["segment#{index}baggageCount".to_sym,
|
165
|
+
prepared_segments_luggage =
|
166
|
+
if segments_luggage
|
167
|
+
segments_luggage.map.with_index do |luggage_count, index|
|
168
|
+
["segment#{index}baggageCount".to_sym, luggage_count]
|
169
169
|
end.to_h
|
170
170
|
else
|
171
171
|
{}
|
@@ -186,8 +186,8 @@ class Gillbus
|
|
186
186
|
discountValue: discount.to_f.to_s,
|
187
187
|
insuranceId: insurance_id,
|
188
188
|
insurance: insurance_cost,
|
189
|
-
baggageCount:
|
190
|
-
**
|
189
|
+
baggageCount: luggage&.first, # luggage используется для односегментных
|
190
|
+
**prepared_segments_luggage,
|
191
191
|
).map { |k, v| [:"#{prefix}#{k}", v] }.to_h
|
192
192
|
end
|
193
193
|
|
data/lib/gillbus/version.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class GetRequiredFieldsTest < Minitest::Test
|
4
|
-
def
|
5
|
-
response_xml = File.read('test/responses/
|
4
|
+
def get_required_fields_without_luggage
|
5
|
+
response_xml = File.read('test/responses/getRequiredFieldsWithoutLuggage.xml')
|
6
6
|
Gillbus::GetRequiredFields::Response.parse_string(response_xml)
|
7
7
|
end
|
8
8
|
|
9
|
-
def
|
10
|
-
response_xml = File.read('test/responses/
|
9
|
+
def get_required_fields_with_one_luggage
|
10
|
+
response_xml = File.read('test/responses/getRequiredFieldsWithOneLuggage.xml')
|
11
11
|
Gillbus::GetRequiredFields::Response.parse_string(response_xml)
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
response_xml = File.read('test/responses/
|
14
|
+
def get_required_fields_with_two_luggage_segments
|
15
|
+
response_xml = File.read('test/responses/getRequiredFieldsWithTwoLuggageSegments.xml')
|
16
16
|
Gillbus::GetRequiredFields::Response.parse_string(response_xml)
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
result =
|
19
|
+
def test_required_fields_without_luggage
|
20
|
+
result = get_required_fields_without_luggage
|
21
21
|
|
22
|
-
assert_nil result.
|
22
|
+
assert_nil result.luggage
|
23
23
|
|
24
24
|
dictionary = result.dictionary
|
25
25
|
assert_equal false, dictionary[:student_ticket]
|
@@ -41,37 +41,37 @@ class GetRequiredFieldsTest < Minitest::Test
|
|
41
41
|
assert_equal true, dictionary[:only_latin_symbols]
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
result =
|
46
|
-
|
44
|
+
def test_required_fields_with_one_luggage
|
45
|
+
result = get_required_fields_with_one_luggage
|
46
|
+
luggage = result.luggage
|
47
47
|
|
48
|
-
assert_equal true,
|
49
|
-
assert_equal 50.5,
|
48
|
+
assert_equal true, luggage.is_buy
|
49
|
+
assert_equal 50.5, luggage.luggage_tariff
|
50
50
|
|
51
|
-
assert_equal [],
|
52
|
-
assert_nil
|
51
|
+
assert_equal [], luggage.segments
|
52
|
+
assert_nil luggage.segment_number
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
56
|
-
result =
|
57
|
-
|
55
|
+
def test_required_fields_with_two_luggage_segments
|
56
|
+
result = get_required_fields_with_two_luggage_segments
|
57
|
+
luggage = result.luggage
|
58
58
|
|
59
|
-
assert_nil
|
60
|
-
assert_nil
|
61
|
-
assert_nil
|
59
|
+
assert_nil luggage.is_buy
|
60
|
+
assert_nil luggage.luggage_tariff
|
61
|
+
assert_nil luggage.luggage_limit
|
62
62
|
|
63
|
-
assert_equal 2,
|
64
|
-
|
65
|
-
|
63
|
+
assert_equal 2, luggage.segments.count
|
64
|
+
first_luggage_segment = luggage.segments[0]
|
65
|
+
second_luggage_segment = luggage.segments[1]
|
66
66
|
|
67
|
-
assert_equal 0,
|
68
|
-
assert_equal true,
|
69
|
-
assert_equal 70.7,
|
70
|
-
assert_equal 2,
|
67
|
+
assert_equal 0, first_luggage_segment.segment_number
|
68
|
+
assert_equal true, first_luggage_segment.is_buy
|
69
|
+
assert_equal 70.7, first_luggage_segment.luggage_tariff
|
70
|
+
assert_equal 2, first_luggage_segment.luggage_limit
|
71
71
|
|
72
|
-
assert_equal 1,
|
73
|
-
assert_equal false,
|
74
|
-
assert_nil
|
75
|
-
assert_nil
|
72
|
+
assert_equal 1, second_luggage_segment.segment_number
|
73
|
+
assert_equal false, second_luggage_segment.is_buy
|
74
|
+
assert_nil second_luggage_segment.luggage_tariff
|
75
|
+
assert_nil second_luggage_segment.luggage_limit
|
76
76
|
end
|
77
77
|
end
|
data/test/responses/{getRequiredFieldsWithOneBaggage.xml → getRequiredFieldsWithOneLuggage.xml}
RENAMED
File without changes
|
File without changes
|
data/test/responses/{getRequiredFieldsWithoutBaggage.xml → getRequiredFieldsWithoutLuggage.xml}
RENAMED
File without changes
|
@@ -13,7 +13,7 @@ class TicketsBookingTest < Minitest::Test
|
|
13
13
|
assert_equal(Money.new(110_00, 'UAH'), tickets_booking.tickets.first.total_amount)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def test_params_generation_with_no_luggage
|
17
17
|
request = Gillbus::TicketsBooking::Request.new(
|
18
18
|
passengers: [
|
19
19
|
{ },
|
@@ -27,14 +27,14 @@ class TicketsBookingTest < Minitest::Test
|
|
27
27
|
assert_equal expected_params, request.params
|
28
28
|
end
|
29
29
|
|
30
|
-
def
|
30
|
+
def test_params_generation_with_luggage_with_one_segment
|
31
31
|
request = Gillbus::TicketsBooking::Request.new(
|
32
32
|
passengers: [
|
33
33
|
{
|
34
|
-
|
34
|
+
luggage: [1],
|
35
35
|
},
|
36
36
|
{
|
37
|
-
|
37
|
+
luggage: [2],
|
38
38
|
}
|
39
39
|
],
|
40
40
|
)
|
@@ -51,10 +51,10 @@ class TicketsBookingTest < Minitest::Test
|
|
51
51
|
request = Gillbus::TicketsBooking::Request.new(
|
52
52
|
passengers: [
|
53
53
|
{
|
54
|
-
|
54
|
+
segments_luggage: [0, 1],
|
55
55
|
},
|
56
56
|
{
|
57
|
-
|
57
|
+
segments_luggage: [1, 0],
|
58
58
|
}
|
59
59
|
],
|
60
60
|
)
|
@@ -69,10 +69,10 @@ class TicketsBookingTest < Minitest::Test
|
|
69
69
|
assert_equal expected_params, request.params
|
70
70
|
end
|
71
71
|
|
72
|
-
def
|
72
|
+
def test_parse_is_luggage_field
|
73
73
|
response = tickets_booking
|
74
74
|
ticket = response.tickets.first
|
75
75
|
|
76
|
-
assert_equal true, ticket.
|
76
|
+
assert_equal true, ticket.is_luggage
|
77
77
|
end
|
78
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey "codesnik" Trofimenko
|
@@ -201,11 +201,11 @@ files:
|
|
201
201
|
- lib/gillbus/search_nearby_trips.rb
|
202
202
|
- lib/gillbus/search_trips.rb
|
203
203
|
- lib/gillbus/session_login.rb
|
204
|
-
- lib/gillbus/structs/baggage.rb
|
205
204
|
- lib/gillbus/structs/bus_photo.rb
|
206
205
|
- lib/gillbus/structs/carrier.rb
|
207
206
|
- lib/gillbus/structs/commission.rb
|
208
207
|
- lib/gillbus/structs/item.rb
|
208
|
+
- lib/gillbus/structs/luggage.rb
|
209
209
|
- lib/gillbus/structs/nearby_cities_trip.rb
|
210
210
|
- lib/gillbus/structs/passenger_discount.rb
|
211
211
|
- lib/gillbus/structs/point.rb
|
@@ -257,9 +257,9 @@ files:
|
|
257
257
|
- test/responses/getCities.xml
|
258
258
|
- test/responses/getCountries.xml
|
259
259
|
- test/responses/getOrderTicket.xml
|
260
|
-
- test/responses/
|
261
|
-
- test/responses/
|
262
|
-
- test/responses/
|
260
|
+
- test/responses/getRequiredFieldsWithOneLuggage.xml
|
261
|
+
- test/responses/getRequiredFieldsWithTwoLuggageSegments.xml
|
262
|
+
- test/responses/getRequiredFieldsWithoutLuggage.xml
|
263
263
|
- test/responses/getTimeTable.xml
|
264
264
|
- test/responses/getTripSeats-back-seats.xml
|
265
265
|
- test/responses/getTripSeats-one-empty-segment.xml
|
@@ -345,9 +345,9 @@ test_files:
|
|
345
345
|
- test/responses/getCities.xml
|
346
346
|
- test/responses/getCountries.xml
|
347
347
|
- test/responses/getOrderTicket.xml
|
348
|
-
- test/responses/
|
349
|
-
- test/responses/
|
350
|
-
- test/responses/
|
348
|
+
- test/responses/getRequiredFieldsWithOneLuggage.xml
|
349
|
+
- test/responses/getRequiredFieldsWithTwoLuggageSegments.xml
|
350
|
+
- test/responses/getRequiredFieldsWithoutLuggage.xml
|
351
351
|
- test/responses/getTimeTable.xml
|
352
352
|
- test/responses/getTripSeats-back-seats.xml
|
353
353
|
- test/responses/getTripSeats-one-empty-segment.xml
|
@@ -1,19 +0,0 @@
|
|
1
|
-
class Gillbus
|
2
|
-
class Baggage
|
3
|
-
extend Fields
|
4
|
-
|
5
|
-
# => "0"
|
6
|
-
field :segment_number, :int
|
7
|
-
|
8
|
-
# => "true"
|
9
|
-
field :is_buy, :bool
|
10
|
-
|
11
|
-
# => "50.5"
|
12
|
-
field :baggage_tariff, :decimal
|
13
|
-
|
14
|
-
# => "2"
|
15
|
-
field :baggage_limit, :int
|
16
|
-
|
17
|
-
field :segments, [Baggage], key: 'SEGMENT'
|
18
|
-
end
|
19
|
-
end
|