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 | const TAG_SHIPPING_UPDATE = 'SHIPPING_UPDATE'; |
||
23 | const TAG_RESERVATION_UPDATE = 'RESERVATION_UPDATE'; |
||
24 | const TAG_ISSUE_RESOLUTION = 'ISSUE_RESOLUTION'; |
||
25 | const TAG_APPOINTMENT_UPDATE = 'APPOINTMENT_UPDATE'; |
||
26 | const TAG_GAME_EVENT = 'GAME_EVENT'; |
||
27 | const TAG_TRANSPORTATION_UPDATE = 'TRANSPORTATION_UPDATE'; |
||
28 | const TAG_FEATURE_FUNCTIONALITY_UPDATE = 'FEATURE_FUNCTIONALITY_UPDATE'; |
||
29 | const TAG_TICKET_UPDATE = 'TICKET_UPDATE'; |
||
30 | |||
31 | /** |
||
32 | * @var null|\Kerox\Messenger\Api\Send |
||
33 | */ |
||
34 | private static $_instance; |
||
35 | |||
36 | /** |
||
37 | * Send constructor. |
||
38 | * |
||
39 | * @param string $pageToken |
||
40 | * @param \GuzzleHttp\ClientInterface $client |
||
41 | */ |
||
42 | 9 | public function __construct(string $pageToken, ClientInterface $client) |
|
46 | |||
47 | /** |
||
48 | * @param string $pageToken |
||
49 | * @param \GuzzleHttp\ClientInterface $client |
||
50 | * @return \Kerox\Messenger\Api\Send |
||
51 | */ |
||
52 | 1 | public static function getInstance(string $pageToken, ClientInterface $client): Send |
|
60 | |||
61 | /** |
||
62 | * @param string $recipient |
||
63 | * @param string|\Kerox\Messenger\Model\Message $message |
||
64 | * @param string $notificationType |
||
65 | * @param string|null $tag |
||
66 | * @return \Kerox\Messenger\Response\SendResponse |
||
67 | */ |
||
68 | 5 | public function message(string $recipient, $message, string $notificationType = self::NOTIFICATION_TYPE_REGULAR, $tag = null): SendResponse |
|
82 | |||
83 | /** |
||
84 | * @param string $recipient |
||
85 | * @param string $action |
||
86 | * @param string $notificationType |
||
87 | * @return \Kerox\Messenger\Response\SendResponse |
||
88 | */ |
||
89 | 2 | public function action(string $recipient, string $action, string $notificationType = self::NOTIFICATION_TYPE_REGULAR): SendResponse |
|
99 | |||
100 | /** |
||
101 | * @param \Kerox\Messenger\Model\Message\Attachment $attachment |
||
102 | * @return \Kerox\Messenger\Response\SendResponse |
||
103 | */ |
||
104 | 1 | public function attachment(Attachment $attachment): SendResponse |
|
113 | |||
114 | /** |
||
115 | * @param $message |
||
116 | * @return \Kerox\Messenger\Model\Message |
||
117 | * @throws \InvalidArgumentException |
||
118 | */ |
||
119 | 6 | private function isValidMessage($message): Message |
|
131 | |||
132 | /** |
||
133 | * @param string $notificationType |
||
134 | * @throws \InvalidArgumentException |
||
135 | */ |
||
136 | 5 | private function isValidNotificationType(string $notificationType) |
|
143 | |||
144 | /** |
||
145 | * @return array |
||
146 | */ |
||
147 | 5 | private function getAllowedNotificationType(): array |
|
155 | |||
156 | /** |
||
157 | * @param string $action |
||
158 | * @throws \InvalidArgumentException |
||
159 | */ |
||
160 | 2 | private function isValidAction(string $action) |
|
167 | |||
168 | /** |
||
169 | * @return array |
||
170 | */ |
||
171 | 2 | private function getAllowedSenderAction(): array |
|
179 | |||
180 | /** |
||
181 | * @param string $tag |
||
182 | * @throws \InvalidArgumentException |
||
183 | */ |
||
184 | private function isValidTag(string $tag) |
||
191 | |||
192 | /** |
||
193 | * @return array |
||
194 | */ |
||
195 | private function getAllowedTag(): array |
||
208 | } |
||
209 |