1 | <?php |
||
12 | class Messenger implements UserProfileInterface |
||
13 | { |
||
14 | |||
15 | const API_URL = 'https://graph.facebook.com/'; |
||
16 | const API_VERSION = 'v2.6'; |
||
17 | |||
18 | const SENDER_ACTION_TYPING_ON = 'typing_on'; |
||
19 | const SENDER_ACTION_TYPING_OFF = 'typing_off'; |
||
20 | const SENDER_ACTION_MARK_SEEN = 'mark_seen'; |
||
21 | |||
22 | const NOTIFICATION_TYPE_REGULAR = 'REGULAR'; |
||
23 | const NOTIFICATION_TYPE_SILENT_PUSH = 'SILENT_PUSH'; |
||
24 | const NOTIFICATION_TYPE_NO_PUSH = 'NO_PUSH'; |
||
25 | |||
26 | /** |
||
27 | * var string |
||
28 | */ |
||
29 | protected $pageToken; |
||
30 | |||
31 | /** |
||
32 | * @var \GuzzleHttp\Client |
||
33 | */ |
||
34 | protected $client; |
||
35 | |||
36 | /** |
||
37 | * @var Message |
||
38 | */ |
||
39 | protected $message; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | protected $senderAction; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | protected $notificationType = self::NOTIFICATION_TYPE_REGULAR; |
||
50 | |||
51 | /** |
||
52 | * Messenger constructor. |
||
53 | * |
||
54 | * @param string $pageToken |
||
55 | */ |
||
56 | public function __construct(string $pageToken) |
||
63 | |||
64 | /** |
||
65 | * @param mixed $message |
||
66 | * @return Messenger |
||
67 | * @throws \Exception |
||
68 | */ |
||
69 | public function setMessage($message): Messenger |
||
78 | |||
79 | /** |
||
80 | * @param mixed $senderAction |
||
81 | * @return Messenger |
||
82 | * @throws \Exception |
||
83 | */ |
||
84 | public function setSenderAction(string $senderAction): Messenger |
||
98 | |||
99 | /** |
||
100 | * @return array |
||
101 | */ |
||
102 | private function getAllowedSenderAction(): array |
||
110 | |||
111 | /** |
||
112 | * @param mixed $notificationType |
||
113 | * @return Messenger |
||
114 | */ |
||
115 | public function setNotificationType(string $notificationType): Messenger |
||
125 | |||
126 | /** |
||
127 | * @return array |
||
128 | */ |
||
129 | private function getAllowedNotificationType(): array |
||
137 | |||
138 | /** |
||
139 | * @param $message |
||
140 | * @return mixed |
||
141 | * @throws \InvalidArgumentException |
||
142 | */ |
||
143 | private function isValidMessage($message) |
||
155 | |||
156 | /** |
||
157 | * @param string $recipient |
||
158 | * @return \Kerox\Messenger\Response\MessageResponse |
||
159 | * @throws \Exception |
||
160 | */ |
||
161 | public function sendTo(string $recipient): MessageResponse |
||
172 | |||
173 | /** |
||
174 | * @param string $userId |
||
175 | * @param array|null $userProfileFields |
||
176 | * @return \Kerox\Messenger\Response\UserProfileResponse |
||
177 | */ |
||
178 | public function getUserProfile(string $userId, array $userProfileFields = null): UserProfileResponse |
||
196 | |||
197 | /** |
||
198 | * @return array |
||
199 | */ |
||
200 | private function getAllowedUserProfileFields(): array |
||
212 | } |