|
1
|
|
|
<?php |
|
2
|
|
|
namespace Kerox\Messenger\Model\Message\Attachment\Template; |
|
3
|
|
|
|
|
4
|
|
|
use Kerox\Messenger\Model\Message\Attachment\Template; |
|
5
|
|
|
|
|
6
|
|
|
class AirlineItinerary extends AbstractAirline |
|
7
|
|
|
{ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @var string |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $introMessage; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var string |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $pnrNumber; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var \Kerox\Messenger\Model\Message\Attachment\Template\Airline\PassengerInfo[] |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $passengerInfo; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var \Kerox\Messenger\Model\Message\Attachment\Template\Airline\ExtendedFlightInfo[] |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $flightInfo; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var \Kerox\Messenger\Model\Message\Attachment\Template\Airline\PassengerSegmentInfo[] |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $passengerSegmentInfo; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var array |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $priceInfo = []; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var null|string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $basePrice; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var null|string |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $tax; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
protected $totalPrice; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
protected $currency; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* AirlineItinerary constructor. |
|
61
|
|
|
* |
|
62
|
|
|
* @param string $introMessage |
|
63
|
|
|
* @param string $locale |
|
64
|
|
|
* @param string $pnrNumber |
|
65
|
|
|
* @param \Kerox\Messenger\Model\Message\Attachment\Template\Airline\PassengerInfo[] $passengerInfo |
|
66
|
|
|
* @param \Kerox\Messenger\Model\Message\Attachment\Template\Airline\ExtendedFlightInfo[] $flightInfo |
|
67
|
|
|
* @param \Kerox\Messenger\Model\Message\Attachment\Template\Airline\PassengerSegmentInfo[] $passengerSegmentInfo |
|
68
|
|
|
* @param string $totalPrice |
|
69
|
|
|
* @param string $currency |
|
70
|
|
|
*/ |
|
71
|
|
|
public function __construct( |
|
72
|
|
|
string $introMessage, |
|
73
|
|
|
string $locale, |
|
74
|
|
|
string $pnrNumber, |
|
75
|
|
|
array $passengerInfo, |
|
76
|
|
|
array $flightInfo, |
|
77
|
|
|
array $passengerSegmentInfo, |
|
78
|
|
|
string $totalPrice, |
|
79
|
|
|
string $currency |
|
80
|
|
|
) { |
|
81
|
|
|
parent::__construct($locale); |
|
82
|
|
|
|
|
83
|
|
|
$this->introMessage = $introMessage; |
|
84
|
|
|
$this->pnrNumber = $pnrNumber; |
|
85
|
|
|
$this->passengerInfo = $passengerInfo; |
|
86
|
|
|
$this->flightInfo = $flightInfo; |
|
87
|
|
|
$this->passengerSegmentInfo = $passengerSegmentInfo; |
|
88
|
|
|
$this->totalPrice = $totalPrice; |
|
89
|
|
|
$this->currency = $currency; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $title |
|
94
|
|
|
* @param string $amount |
|
95
|
|
|
* @param string $currency |
|
96
|
|
|
* @return \Kerox\Messenger\Model\Message\Attachment\Template\AirlineItinerary |
|
97
|
|
|
* @internal param array|null $priceInfo |
|
98
|
|
|
*/ |
|
99
|
|
|
public function addPriceInfo(string $title, string $amount, string $currency = null): AirlineItinerary |
|
100
|
|
|
{ |
|
101
|
|
|
if ($currency !== null) { |
|
102
|
|
|
$this->isValidCurrency($currency); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
$priceInfo = [ |
|
106
|
|
|
'title' => $title, |
|
107
|
|
|
'amount' => $amount, |
|
108
|
|
|
'currency' => $currency, |
|
109
|
|
|
]; |
|
110
|
|
|
|
|
111
|
|
|
$this->isValidArray($this->priceInfo, 4); |
|
112
|
|
|
$this->priceInfo[] = array_filter($priceInfo); |
|
113
|
|
|
|
|
114
|
|
|
return $this; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @param string $basePrice |
|
119
|
|
|
* @return AirlineItinerary |
|
120
|
|
|
*/ |
|
121
|
|
|
public function setBasePrice(string $basePrice): AirlineItinerary |
|
122
|
|
|
{ |
|
123
|
|
|
$this->basePrice = $basePrice; |
|
124
|
|
|
|
|
125
|
|
|
return $this; |
|
126
|
|
|
} |
|
127
|
|
|
|
|
128
|
|
|
/** |
|
129
|
|
|
* @param string $tax |
|
130
|
|
|
* @return AirlineItinerary |
|
131
|
|
|
*/ |
|
132
|
|
|
public function setTax(string $tax): AirlineItinerary |
|
133
|
|
|
{ |
|
134
|
|
|
$this->tax = $tax; |
|
135
|
|
|
|
|
136
|
|
|
return $this; |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
/** |
|
140
|
|
|
* @return array |
|
141
|
|
|
*/ |
|
142
|
|
|
public function jsonSerialize(): array |
|
143
|
|
|
{ |
|
144
|
|
|
$payload = [ |
|
145
|
|
|
'template_type' => Template::TYPE_AIRLINE_ITINERARY, |
|
146
|
|
|
'intro_message' => $this->introMessage, |
|
147
|
|
|
'locale' => $this->locale, |
|
148
|
|
|
'theme_color' => $this->themeColor, |
|
149
|
|
|
'pnr_number' => $this->pnrNumber, |
|
150
|
|
|
'passenger_info' => $this->passengerInfo, |
|
151
|
|
|
'flight_info' => $this->flightInfo, |
|
152
|
|
|
'passenger_segment_info' => $this->passengerSegmentInfo, |
|
153
|
|
|
'price_info' => $this->priceInfo, |
|
154
|
|
|
'base_price' => $this->basePrice, |
|
155
|
|
|
'tax' => $this->tax, |
|
156
|
|
|
'total_price' => $this->totalPrice, |
|
157
|
|
|
'currency' => $this->currency, |
|
158
|
|
|
]; |
|
159
|
|
|
|
|
160
|
|
|
$json = parent::jsonSerialize(); |
|
161
|
|
|
$json += [ |
|
162
|
|
|
'payload' => array_filter($payload), |
|
163
|
|
|
]; |
|
164
|
|
|
|
|
165
|
|
|
return $json; |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|