1 | <?php |
||
18 | class Client |
||
19 | { |
||
20 | /** |
||
21 | * Array of notifications. |
||
22 | * |
||
23 | * @var Notification[] |
||
24 | */ |
||
25 | private $notifications = []; |
||
26 | |||
27 | /** |
||
28 | * Authentication provider. |
||
29 | * |
||
30 | * @var AuthProviderInterface |
||
31 | */ |
||
32 | private $authProvider; |
||
33 | |||
34 | /** |
||
35 | * Production or sandbox environment. |
||
36 | * |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $isProductionEnv; |
||
40 | |||
41 | /** |
||
42 | * Client constructor. |
||
43 | * |
||
44 | * @param AuthProviderInterface $authProvider |
||
45 | * @param bool $isProductionEnv |
||
46 | */ |
||
47 | public function __construct(AuthProviderInterface $authProvider, bool $isProductionEnv = false) |
||
52 | |||
53 | /** |
||
54 | * Push notifications to APNs. |
||
55 | * |
||
56 | * @return array |
||
57 | */ |
||
58 | public function push(): array |
||
81 | |||
82 | /** |
||
83 | * Send request. |
||
84 | * |
||
85 | * @param $curlHandle |
||
86 | * @param Request $request |
||
87 | * |
||
88 | * @return mixed Return the result on success, false on failure |
||
89 | */ |
||
90 | private function send($curlHandle, Request $request) |
||
97 | |||
98 | /** |
||
99 | * Add notification in queue for sending. |
||
100 | * |
||
101 | * @param Notification $notification |
||
102 | */ |
||
103 | public function addNotification(Notification $notification) |
||
107 | |||
108 | /** |
||
109 | * Add several notifications in queue for sending. |
||
110 | * |
||
111 | * @param Notification[] $notifications |
||
112 | */ |
||
113 | public function addNotifications(array $notifications) |
||
117 | |||
118 | /** |
||
119 | * Get already added notifications. |
||
120 | * |
||
121 | * @return Notification[] |
||
122 | */ |
||
123 | public function getNotifications() |
||
127 | } |
||
128 |