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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54e47ea904a8755c00a4576845ae6779abea4cc3
4
- data.tar.gz: c6d830de157b234b145ae9b130c8152d712b5cee
3
+ metadata.gz: 6e967c8446ef81abea1d78c2a65b347bf9f9cac7
4
+ data.tar.gz: 3b6b92154b530f2c0cb9f2cdd1569df04142cecf
5
5
  SHA512:
6
- metadata.gz: 5a71b4974da670c7ff4a4ca2e63522c81a3835ec7b8eb4a58a0b823bd3b63db1c4cf9ac180776cedef74e6d791e8d3145fe9cd1a5a6013cbae1f90ab1acf61b6
7
- data.tar.gz: 1719fa183ae15163244f3d35da7e10be74ba180ffcbddfb6e2d6cef3a71262489eb085077265c97a80eae08aff98666e025e7c5037d982c9b273dea6e2bb059d
6
+ metadata.gz: b4ecde0f8320dcee976b504543343c3b0790a2d0fd30586fc0ba77dd565b34b0fafbbfe4184f0d8d8930dcc9ae5f2cdd792637f5ff56d371179fe59489164703
7
+ data.tar.gz: 5c7065a612da886f5c672a47e790ef26be481cd0bb16bed841eeffe08d6953ecaefc0af2042f67394490e9315c034aa035aef85c8f8f36d2e60e7efa6961dda5
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2.4
1
+ 2.3.2
@@ -15,7 +15,11 @@ class Gillbus
15
15
  module Fields
16
16
 
17
17
  def parser_class
18
- @parser_class || Gillbus::Parser
18
+ if defined? @parser_class
19
+ @parser_class || Gillbus::Parser
20
+ else
21
+ Gillbus::Parser
22
+ end
19
23
  end
20
24
 
21
25
  def parse(doc, instance=new)
@@ -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
- **pax
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
@@ -1,3 +1,3 @@
1
1
  class Gillbus
2
- VERSION = "0.13.0"
2
+ VERSION = "0.14.0"
3
3
  end
data/lib/gillbus.rb CHANGED
@@ -15,7 +15,7 @@ class Gillbus
15
15
  attr_accessor :session_id
16
16
 
17
17
  def login(password:, locale: nil)
18
- response = session_login password: password, locale: locale
18
+ session_login password: password, locale: locale
19
19
  self
20
20
  end
21
21
 
@@ -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
- assert_equal req.params,
13
- {
14
- startDateSearch: "04.02.2013",
15
- selectedModes: "3;8",
16
- roundTrip: "1"
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.13.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: 2016-11-21 00:00:00.000000000 Z
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.4.8
264
+ rubygems_version: 2.5.2
265
265
  signing_key:
266
266
  specification_version: 4
267
267
  summary: Driver for Gillbus IDS API