gillbus 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/gillbus/helpers/fields.rb +5 -1
- data/lib/gillbus/search_trips.rb +29 -3
- data/lib/gillbus/version.rb +1 -1
- data/lib/gillbus.rb +1 -1
- data/test/search_trips_test.rb +30 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e967c8446ef81abea1d78c2a65b347bf9f9cac7
|
4
|
+
data.tar.gz: 3b6b92154b530f2c0cb9f2cdd1569df04142cecf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4ecde0f8320dcee976b504543343c3b0790a2d0fd30586fc0ba77dd565b34b0fafbbfe4184f0d8d8930dcc9ae5f2cdd792637f5ff56d371179fe59489164703
|
7
|
+
data.tar.gz: 5c7065a612da886f5c672a47e790ef26be481cd0bb16bed841eeffe08d6953ecaefc0af2042f67394490e9315c034aa035aef85c8f8f36d2e60e7efa6961dda5
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.2
|
1
|
+
2.3.2
|
data/lib/gillbus/search_trips.rb
CHANGED
@@ -51,15 +51,24 @@ class Gillbus
|
|
51
51
|
# Количество оформляемых билетов. От 1 до k.
|
52
52
|
attr_accessor :ticket_count
|
53
53
|
|
54
|
-
# TODO
|
55
54
|
# passenger0studentTicket... passengerNstudentTicket (не обязательный)
|
56
55
|
# Номер студенческого билета пассажира с порядковым номером 0... N.
|
57
56
|
#
|
57
|
+
# passenger0studentYea... passengerNstudentYear (не обязательный)
|
58
|
+
# Курс, на котором учится пассажир с порядковым номером 0…N, если он студент. Для просчета более выгодной скидки.
|
59
|
+
#
|
58
60
|
# passenger0birthday... passengerNbirthday (не обязательный)
|
59
61
|
# Дата рождения пассажира с порядковым номером 0...N.
|
60
62
|
#
|
61
63
|
# passenger0ISIC... passengerNISIC (не обязательный)
|
62
64
|
# Номер ISIC пассажира с порядковым номером 0...N.
|
65
|
+
|
66
|
+
# В passengers записывается структура вида
|
67
|
+
# [
|
68
|
+
# {birthday: ..., student_ticket:..., student_year:..., isic:... },
|
69
|
+
# {birthday: ..., student_ticket:..., student_year:..., isic:... },
|
70
|
+
# ]
|
71
|
+
# Далее она преобразуется к формату gillbus методом passengers_data
|
63
72
|
attr_accessor :passengers
|
64
73
|
|
65
74
|
# waitTimeout
|
@@ -74,7 +83,6 @@ class Gillbus
|
|
74
83
|
attr_accessor :only_branded
|
75
84
|
|
76
85
|
def params
|
77
|
-
pax = (passengers || []).map.with_index { |p, i| PassengerDiscount.wrap(p).params("passenger#{i}") }.reduce({}, :merge)
|
78
86
|
compact(
|
79
87
|
selectedModes: modes(selected_modes),
|
80
88
|
connectionIds: list(connection_ids),
|
@@ -88,9 +96,27 @@ class Gillbus
|
|
88
96
|
ticketCount: ticket_count,
|
89
97
|
waitTimeout: wait_timeout,
|
90
98
|
onlyBranded: bool(only_branded),
|
91
|
-
**
|
99
|
+
**passengers_data,
|
92
100
|
)
|
93
101
|
end
|
102
|
+
|
103
|
+
# В passengers_data преобразуем passengers к виду для передачи в gillbus:
|
104
|
+
# {
|
105
|
+
# :passenger0birthday=>"01.01.1990",
|
106
|
+
# :passenger0studentTicket=>"STUDENTTICKET#1",
|
107
|
+
# :passenger0studentYear=>1,
|
108
|
+
# :passenger0ISIC=>"ISIC#1",
|
109
|
+
# :passenger1birthday=>"02.02.1990",
|
110
|
+
# :passenger1studentTicket=>"STUDENTTICKET#2",
|
111
|
+
# :passenger1studentYear=>2,
|
112
|
+
# :passenger1ISIC=>"ISIC#2"
|
113
|
+
# }
|
114
|
+
def passengers_data
|
115
|
+
(passengers || []).map.with_index do |p, i|
|
116
|
+
PassengerDiscount.wrap(p).params("passenger#{i}")
|
117
|
+
end.reduce({}, :merge)
|
118
|
+
end
|
119
|
+
|
94
120
|
end
|
95
121
|
|
96
122
|
class Response < BaseResponse
|
data/lib/gillbus/version.rb
CHANGED
data/lib/gillbus.rb
CHANGED
data/test/search_trips_test.rb
CHANGED
@@ -6,15 +6,38 @@ class SearchTripsRequestTest < Minitest::Test
|
|
6
6
|
req = Gillbus::SearchTrips::Request.new(
|
7
7
|
start_date_search: Date.new(2013, 2, 4),
|
8
8
|
selected_modes: [:avia, :connections],
|
9
|
-
round_trip: true
|
9
|
+
round_trip: true,
|
10
|
+
passengers: [
|
11
|
+
{
|
12
|
+
birthday: Date.parse('1990-01-01'),
|
13
|
+
student_ticket: 'STUDENTTICKET#1',
|
14
|
+
student_year: 1,
|
15
|
+
isic: 'ISIC#1',
|
16
|
+
},
|
17
|
+
{
|
18
|
+
birthday: Date.parse('1990-02-02'),
|
19
|
+
student_ticket: 'STUDENTTICKET#2',
|
20
|
+
student_year: 2,
|
21
|
+
isic: 'ISIC#2',
|
22
|
+
}
|
23
|
+
],
|
10
24
|
)
|
11
25
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
26
|
+
expected_params = {
|
27
|
+
startDateSearch: "04.02.2013",
|
28
|
+
selectedModes: "3;8",
|
29
|
+
roundTrip: "1",
|
30
|
+
passenger0birthday: '01.01.1990',
|
31
|
+
passenger0studentTicket: 'STUDENTTICKET#1',
|
32
|
+
passenger0studentYear: 1,
|
33
|
+
passenger0ISIC: 'ISIC#1',
|
34
|
+
passenger1birthday: '02.02.1990',
|
35
|
+
passenger1studentTicket: 'STUDENTTICKET#2',
|
36
|
+
passenger1studentYear: 2,
|
37
|
+
passenger1ISIC: 'ISIC#2',
|
38
|
+
}
|
39
|
+
|
40
|
+
assert_equal expected_params, req.params
|
18
41
|
end
|
19
42
|
|
20
43
|
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.14.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:
|
12
|
+
date: 2017-03-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_xml
|
@@ -261,7 +261,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
261
|
version: '0'
|
262
262
|
requirements: []
|
263
263
|
rubyforge_project:
|
264
|
-
rubygems_version: 2.
|
264
|
+
rubygems_version: 2.5.2
|
265
265
|
signing_key:
|
266
266
|
specification_version: 4
|
267
267
|
summary: Driver for Gillbus IDS API
|