@@ -142,7 +142,7 @@ public function readNotification(array $params): int
142
142
* @throws GuzzleException
143
143
* @throws RequestValidationException
144
144
*/
145
- public function deleteNotification (array $ params )
145
+ public function deleteNotification (array $ params ): int
146
146
{
147
147
$ params = CodemashPushNotificationParams::prepGetByIdParams ($ params );
148
148
@@ -153,4 +153,164 @@ public function deleteNotification(array $params)
153
153
],
154
154
]);
155
155
}
156
+
157
+ /**
158
+ * @throws GuzzleException
159
+ * @throws RequestValidationException
160
+ */
161
+ public function registerDevice (array $ params = []): array
162
+ {
163
+ $ params = CodemashPushNotificationParams::prepRegisterDeviceParams ($ params );
164
+
165
+ $ response = $ this ->client ->request ('POST ' , $ this ->uriPrefix . 'devices ' , [
166
+ 'headers ' => [
167
+ 'Accept ' => 'application/json ' ,
168
+ 'Content-Type ' => 'application/json ' ,
169
+ ],
170
+ 'body ' => toJson ($ params ),
171
+ ]);
172
+
173
+ return $ response ['result ' ];
174
+ }
175
+
176
+ /**
177
+ * @throws GuzzleException
178
+ * @throws RequestValidationException
179
+ */
180
+ public function registerExpoToken (array $ params ): string
181
+ {
182
+ $ params = CodemashPushNotificationParams::prepRegisterExpoTokenParams ($ params );
183
+
184
+ $ response = $ this ->client ->request ('POST ' , $ this ->uriPrefix . 'token/expo ' , [
185
+ 'headers ' => [
186
+ 'Accept ' => 'application/json ' ,
187
+ 'Content-Type ' => 'application/json ' ,
188
+ ],
189
+ 'body ' => toJson ($ params ),
190
+ ]);
191
+
192
+ return $ response ['result ' ];
193
+ }
194
+
195
+ /**
196
+ * @throws GuzzleException
197
+ * @throws RequestValidationException
198
+ */
199
+ public function getDevice (array $ params ): array
200
+ {
201
+ $ params = CodemashPushNotificationParams::prepGetByIdParams ($ params );
202
+
203
+ $ response = $ this ->client ->request ('GET ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ], [
204
+ 'headers ' => [
205
+ 'Accept ' => 'application/json ' ,
206
+ 'Content-Type ' => 'application/json ' ,
207
+ ],
208
+ ]);
209
+
210
+ return $ response ['result ' ];
211
+ }
212
+
213
+ /**
214
+ * @throws GuzzleException
215
+ */
216
+ public function getDevices (): array
217
+ {
218
+ $ response = $ this ->client ->request ('GET ' , $ this ->uriPrefix . 'devices ' , [
219
+ 'headers ' => [
220
+ 'Accept ' => 'application/json ' ,
221
+ 'Content-Type ' => 'application/json ' ,
222
+ ],
223
+ ]);
224
+
225
+ return $ response ['result ' ];
226
+ }
227
+
228
+ /**
229
+ * @throws GuzzleException
230
+ * @throws RequestValidationException
231
+ */
232
+ public function deleteDevice (array $ params ): int
233
+ {
234
+ $ params = CodemashPushNotificationParams::prepGetByIdParams ($ params );
235
+
236
+ return $ this ->client ->request ('DELETE ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ], [
237
+ 'headers ' => [
238
+ 'Accept ' => 'application/json ' ,
239
+ 'Content-Type ' => 'application/json ' ,
240
+ ],
241
+ ]);
242
+ }
243
+
244
+ /**
245
+ * @throws GuzzleException
246
+ * @throws RequestValidationException
247
+ */
248
+ public function deleteDeviceToken (array $ params ): int
249
+ {
250
+ $ params = CodemashPushNotificationParams::prepGetByIdParams ($ params );
251
+
252
+ return $ this ->client ->request ('DELETE ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ] . '/token ' , [
253
+ 'headers ' => [
254
+ 'Accept ' => 'application/json ' ,
255
+ 'Content-Type ' => 'application/json ' ,
256
+ ],
257
+ ]);
258
+ }
259
+
260
+ /**
261
+ * @throws GuzzleException
262
+ * @throws RequestValidationException
263
+ */
264
+ public function updateDeviceMeta (array $ params ): bool
265
+ {
266
+ $ params = CodemashPushNotificationParams::prepUpdateDeviceMetaParams ($ params );
267
+
268
+ $ response = $ this ->client ->request ('PATCH ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ] . '/metadata ' , [
269
+ 'headers ' => [
270
+ 'Accept ' => 'application/json ' ,
271
+ 'Content-Type ' => 'application/json ' ,
272
+ ],
273
+ 'body ' => toJson ($ params ),
274
+ ]);
275
+
276
+ return $ response ['result ' ];
277
+ }
278
+
279
+ /**
280
+ * @throws GuzzleException
281
+ * @throws RequestValidationException
282
+ */
283
+ public function updateDeviceTimezone (array $ params ): bool
284
+ {
285
+ $ params = CodemashPushNotificationParams::prepUpdateDeviceTimezoneParams ($ params );
286
+
287
+ $ response = $ this ->client ->request ('PATCH ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ] . '/timezone ' , [
288
+ 'headers ' => [
289
+ 'Accept ' => 'application/json ' ,
290
+ 'Content-Type ' => 'application/json ' ,
291
+ ],
292
+ 'body ' => toJson ($ params ),
293
+ ]);
294
+
295
+ return $ response ['result ' ];
296
+ }
297
+
298
+ /**
299
+ * @throws GuzzleException
300
+ * @throws RequestValidationException
301
+ */
302
+ public function updateDeviceUser (array $ params ): bool
303
+ {
304
+ $ params = CodemashPushNotificationParams::prepUpdateDeviceUserParams ($ params );
305
+
306
+ $ response = $ this ->client ->request ('PATCH ' , $ this ->uriPrefix . 'devices/ ' . $ params ['id ' ] . '/user ' , [
307
+ 'headers ' => [
308
+ 'Accept ' => 'application/json ' ,
309
+ 'Content-Type ' => 'application/json ' ,
310
+ ],
311
+ 'body ' => toJson ($ params ),
312
+ ]);
313
+
314
+ return $ response ['result ' ];
315
+ }
156
316
}
0 commit comments