1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Kerox\Messenger\Model\Message\Attachment\Template; |
6
|
|
|
|
7
|
|
|
use Kerox\Messenger\Model\Message\Attachment\AbstractTemplate; |
8
|
|
|
|
9
|
|
|
class AirlineCheckInTemplate extends AbstractAirlineTemplate |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var string |
13
|
|
|
*/ |
14
|
|
|
protected $introMessage; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $pnrNumber; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var \Kerox\Messenger\Model\Message\Attachment\Template\Airline\FlightInfo[] |
23
|
|
|
*/ |
24
|
|
|
protected $flightInfo; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $checkinUrl; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* AirlineCheckIn constructor. |
33
|
|
|
* |
34
|
|
|
* @throws \Kerox\Messenger\Exception\MessengerException |
35
|
|
|
*/ |
36
|
1 |
|
public function __construct( |
37
|
|
|
string $introMessage, |
38
|
|
|
string $locale, |
39
|
|
|
string $pnrNumber, |
40
|
|
|
array $flightInfo, |
41
|
|
|
string $checkinUrl |
42
|
|
|
) { |
43
|
1 |
|
parent::__construct($locale); |
44
|
|
|
|
45
|
1 |
|
$this->introMessage = $introMessage; |
46
|
1 |
|
$this->pnrNumber = $pnrNumber; |
47
|
1 |
|
$this->flightInfo = $flightInfo; |
48
|
1 |
|
$this->checkinUrl = $checkinUrl; |
49
|
1 |
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
*@throws \Kerox\Messenger\Exception\MessengerException |
53
|
|
|
* |
54
|
|
|
*@return \Kerox\Messenger\Model\Message\Attachment\Template\AirlineCheckInTemplate |
55
|
|
|
*/ |
56
|
1 |
|
public static function create( |
57
|
|
|
string $introMessage, |
58
|
|
|
string $locale, |
59
|
|
|
string $pnrNumber, |
60
|
|
|
array $flightInfo, |
61
|
|
|
string $checkinUrl |
62
|
|
|
): self { |
63
|
1 |
|
return new self($introMessage, $locale, $pnrNumber, $flightInfo, $checkinUrl); |
64
|
|
|
} |
65
|
|
|
|
66
|
1 |
|
public function toArray(): array |
67
|
|
|
{ |
68
|
1 |
|
$array = parent::toArray(); |
69
|
|
|
$array += [ |
70
|
|
|
'payload' => [ |
71
|
1 |
|
'template_type' => AbstractTemplate::TYPE_AIRLINE_CHECKIN, |
72
|
1 |
|
'intro_message' => $this->introMessage, |
73
|
1 |
|
'locale' => $this->locale, |
74
|
1 |
|
'theme_color' => $this->themeColor, |
75
|
1 |
|
'pnr_number' => $this->pnrNumber, |
76
|
1 |
|
'flight_info' => $this->flightInfo, |
77
|
1 |
|
'checkin_url' => $this->checkinUrl, |
78
|
|
|
], |
79
|
|
|
]; |
80
|
|
|
|
81
|
1 |
|
return $this->arrayFilter($array); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|