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 string|\Kerox\Messenger\Model\Message $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 | * @param string $recipient |
||
71 | * @param string $action |
||
72 | * @param string $notificationType |
||
73 | * @return \Kerox\Messenger\Response\SendResponse |
||
74 | */ |
||
75 | 2 | public function action(string $recipient, string $action, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
|
85 | |||
86 | /** |
||
87 | * @param \Kerox\Messenger\Model\Message\Attachment $attachment |
||
88 | * @return \Kerox\Messenger\Response\SendResponse |
||
89 | */ |
||
90 | 1 | public function attachment(Attachment $attachment): SendResponse |
|
99 | |||
100 | /** |
||
101 | * @param $message |
||
102 | * @return \Kerox\Messenger\Model\Message |
||
103 | * @throws \InvalidArgumentException |
||
104 | */ |
||
105 | 6 | private function isValidMessage($message): Message |
|
117 | |||
118 | /** |
||
119 | * @param string $notificationType |
||
120 | */ |
||
121 | 5 | private function isValidNotificationType(string $notificationType) |
|
128 | |||
129 | /** |
||
130 | * @return array |
||
131 | */ |
||
132 | 5 | private function getAllowedNotificationType(): array |
|
140 | |||
141 | /** |
||
142 | * @param string $action |
||
143 | */ |
||
144 | 2 | private function isValidAction(string $action) |
|
151 | |||
152 | /** |
||
153 | * @return array |
||
154 | */ |
||
155 | 2 | private function getAllowedSenderAction(): array |
|
163 | } |
||
164 |