1 | <?php |
||
11 | class Send extends AbstractApi |
||
12 | { |
||
13 | |||
14 | const SENDER_ACTION_TYPING_ON = 'typing_on'; |
||
15 | const SENDER_ACTION_TYPING_OFF = 'typing_off'; |
||
16 | const SENDER_ACTION_MARK_SEEN = 'mark_seen'; |
||
17 | |||
18 | const NOTIFICATION_TYPE_REGULAR = 'REGULAR'; |
||
19 | const NOTIFICATION_TYPE_SILENT_PUSH = 'SILENT_PUSH'; |
||
20 | const NOTIFICATION_TYPE_NO_PUSH = 'NO_PUSH'; |
||
21 | |||
22 | /** |
||
23 | * @var null|\Kerox\Messenger\Api\Send |
||
24 | */ |
||
25 | private static $_instance; |
||
26 | |||
27 | /** |
||
28 | * Send constructor. |
||
29 | * |
||
30 | * @param string $pageToken |
||
31 | * @param \GuzzleHttp\ClientInterface $client |
||
32 | */ |
||
33 | 9 | public function __construct(string $pageToken, ClientInterface $client) |
|
37 | |||
38 | /** |
||
39 | * @param string $pageToken |
||
40 | * @param \GuzzleHttp\ClientInterface $client |
||
41 | * @return \Kerox\Messenger\Api\Send |
||
42 | */ |
||
43 | 1 | public static function getInstance(string $pageToken, ClientInterface $client): Send |
|
51 | |||
52 | /** |
||
53 | * @param string $recipient |
||
54 | * @param $message |
||
55 | * @param string $notificationType |
||
56 | * @return \Kerox\Messenger\Response\SendResponse |
||
57 | */ |
||
58 | 5 | public function message(string $recipient, $message, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
|
68 | |||
69 | /** |
||
70 | * @deprecated since 1.2.0 and will be remove in 1.3.0. |
||
71 | * @see message() |
||
72 | * @param string $recipient |
||
73 | * @param $message |
||
74 | * @param string $notificationType |
||
75 | * @return \Kerox\Messenger\Response\SendResponse |
||
76 | */ |
||
77 | public function sendMessage(string $recipient, $message, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
||
78 | { |
||
79 | return $this->message($recipient, $message, $notificationType); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param string $recipient |
||
84 | * @param string $action |
||
85 | * @param string $notificationType |
||
86 | * @return \Kerox\Messenger\Response\SendResponse |
||
87 | */ |
||
88 | 2 | public function action(string $recipient, string $action, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
|
98 | |||
99 | /** |
||
100 | * @deprecated since 1.2.0 and will be removed in 1.3.0. |
||
101 | * @see action() |
||
102 | * @param string $recipient |
||
103 | * @param string $action |
||
104 | * @param string $notificationType |
||
105 | * @return \Kerox\Messenger\Response\SendResponse |
||
106 | */ |
||
107 | public function sendAction(string $recipient, string $action, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
||
108 | { |
||
109 | return $this->action($recipient, $action, $notificationType); |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param \Kerox\Messenger\Model\Message\Attachment $attachment |
||
114 | * @return \Kerox\Messenger\Response\SendResponse |
||
115 | */ |
||
116 | 1 | public function attachment(Attachment $attachment): SendResponse |
|
125 | |||
126 | /** |
||
127 | * @param $message |
||
128 | * @return \Kerox\Messenger\Model\Message |
||
129 | * @throws \InvalidArgumentException |
||
130 | */ |
||
131 | 6 | private function isValidMessage($message): Message |
|
143 | |||
144 | /** |
||
145 | * @param string $notificationType |
||
146 | */ |
||
147 | 5 | private function isValidNotificationType(string $notificationType) |
|
154 | |||
155 | /** |
||
156 | * @return array |
||
157 | */ |
||
158 | 5 | private function getAllowedNotificationType(): array |
|
166 | |||
167 | /** |
||
168 | * @param string $action |
||
169 | */ |
||
170 | 2 | private function isValidAction(string $action) |
|
177 | |||
178 | /** |
||
179 | * @return array |
||
180 | */ |
||
181 | 2 | private function getAllowedSenderAction(): array |
|
189 | } |
||
190 |