-
Notifications
You must be signed in to change notification settings - Fork 1
/
MobiletechNotificationEnvelope.php
96 lines (76 loc) · 2.59 KB
/
MobiletechNotificationEnvelope.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
namespace Crm\MobiletechModule\Events;
use Nette\Database\Table\ActiveRow;
class MobiletechNotificationEnvelope
{
private $mobiletechInboundMessage;
private $projectId;
private $rcvMsgId;
private $servId;
private $fromShortNumber;
private $toPhoneNumber;
private $billKey;
public function __construct(
?ActiveRow $mobiletechInboundMessage,
?string $billKey = null,
?string $servId = null,
?string $fromShortNumber = null,
?string $toPhoneNumber = null
) {
if ($servId) {
$this->servId = $servId;
} elseif ($mobiletechInboundMessage) {
$this->servId = $mobiletechInboundMessage->serv_id;
} else {
throw new \Exception('Unable to create Mobiletech Notification Envelope, neither inbound message nor explicit servId parameter was provided');
}
if ($fromShortNumber) {
$this->fromShortNumber = $fromShortNumber;
} elseif ($mobiletechInboundMessage) {
$this->fromShortNumber = $mobiletechInboundMessage->to;
} else {
throw new \Exception('Unable to create Mobiletech Notification Envelope, neither inbound message nor explicit fromShortNumber parameter was provided');
}
if ($toPhoneNumber) {
$this->toPhoneNumber = $toPhoneNumber;
} elseif ($mobiletechInboundMessage) {
$this->toPhoneNumber = $mobiletechInboundMessage->from;
} else {
throw new \Exception('Unable to create Mobiletech Notification Envelope, neither inbound message nor explicit toPhoneNumber parameter was provided');
}
$this->billKey = $billKey;
$this->mobiletechInboundMessage = $mobiletechInboundMessage;
if ($mobiletechInboundMessage) {
$this->rcvMsgId = $mobiletechInboundMessage->mobiletech_id;
$this->projectId = $mobiletechInboundMessage->project_id;
}
}
public function getMobiletechInboundMessage(): ?ActiveRow
{
return $this->mobiletechInboundMessage;
}
public function getServId(): string
{
return $this->servId;
}
public function getFromShortNumber(): string
{
return $this->fromShortNumber;
}
public function getToPhoneNumber(): string
{
return $this->toPhoneNumber;
}
public function getBillKey(): ?string
{
return $this->billKey;
}
public function getRcvMsgId(): ?string
{
return $this->rcvMsgId;
}
public function getProjectId(): ?string
{
return $this->projectId;
}
}