1 | <?php |
||
9 | class Devices extends AbstractApi |
||
10 | { |
||
11 | public const IOS = 0; |
||
12 | public const ANDROID = 1; |
||
13 | public const AMAZON = 2; |
||
14 | public const WINDOWS_PHONE = 3; |
||
15 | public const WINDOWS_PHONE_MPNS = 3; |
||
16 | public const CHROME_APP = 4; |
||
17 | public const CHROME_WEB = 5; |
||
18 | public const WINDOWS_PHONE_WNS = 6; |
||
19 | public const SAFARI = 7; |
||
20 | public const FIREFOX = 8; |
||
21 | public const MACOS = 9; |
||
22 | public const ALEXA = 10; |
||
23 | public const EMAIL = 11; |
||
24 | public const HUAWEI = 13; |
||
25 | public const SMS = 14; |
||
26 | |||
27 | private $resolverFactory; |
||
28 | |||
29 | public function __construct(OneSignal $client, ResolverFactory $resolverFactory) |
||
35 | |||
36 | /** |
||
37 | * Get information about device with provided ID. |
||
38 | * |
||
39 | * @param string $id Device ID |
||
40 | */ |
||
41 | public function getOne(string $id): array |
||
47 | |||
48 | /** |
||
49 | * Get information about all registered devices for your application. |
||
50 | * |
||
51 | * Application auth key must be set. |
||
52 | * |
||
53 | * @param int $limit How many devices to return. Max is 300. Default is 300 |
||
54 | * @param int $offset Result offset. Default is 0. Results are sorted by id |
||
55 | */ |
||
56 | public function getAll(int $limit = null, int $offset = null): array |
||
73 | |||
74 | /** |
||
75 | * Register a device for your application. |
||
76 | * |
||
77 | * @param array $data Device data |
||
78 | */ |
||
79 | public function add(array $data): array |
||
89 | |||
90 | /** |
||
91 | * Update existing registered device for your application with provided data. |
||
92 | * |
||
93 | * @param string $id Device ID |
||
94 | * @param array $data New device data |
||
95 | */ |
||
96 | public function update(string $id, array $data): array |
||
106 | |||
107 | /** |
||
108 | * Delete existing registered device from your application. |
||
109 | * |
||
110 | * OneSignal supports DELETE on the players API endpoint which is not documented in their official documentation |
||
111 | * Reference: https://documentation.onesignal.com/docs/handling-personal-data#section-deleting-users-or-other-data-from-onesignal |
||
112 | * |
||
113 | * Application auth key must be set. |
||
114 | * |
||
115 | * @param string $id Device ID |
||
116 | */ |
||
117 | public function delete(string $id): array |
||
124 | |||
125 | /** |
||
126 | * Call on new device session in your app. |
||
127 | * |
||
128 | * @param string $id Device ID |
||
129 | * @param array $data Device data |
||
130 | */ |
||
131 | public function onSession(string $id, array $data): array |
||
141 | |||
142 | /** |
||
143 | * Track a new purchase. |
||
144 | * |
||
145 | * @param string $id Device ID |
||
146 | * @param array $data Device data |
||
147 | */ |
||
148 | public function onPurchase(string $id, array $data): array |
||
158 | |||
159 | /** |
||
160 | * Increment the device's total session length. |
||
161 | * |
||
162 | * @param string $id Device ID |
||
163 | * @param array $data Device data |
||
164 | */ |
||
165 | public function onFocus(string $id, array $data): array |
||
175 | |||
176 | /** |
||
177 | * Export all information about devices in a CSV format for your application. |
||
178 | * |
||
179 | * Application auth key must be set. |
||
180 | * |
||
181 | * @param array $extraFields Additional fields that you wish to include. |
||
182 | * Currently supports: "location", "country", "rooted" |
||
183 | * @param string $segmentName A segment name to filter the scv export by. |
||
184 | * Only devices from that segment will make it into the export |
||
185 | * @param int $lastActiveSince An epoch to filter results to users active after this time |
||
186 | */ |
||
187 | public function csvExport(array $extraFields = [], string $segmentName = null, int $lastActiveSince = null): array |
||
207 | } |
||
208 |