@@ -141,17 +141,17 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
141
141
// not throwing a `PushNotificationsAPIBadRequest` here so that it still retries this request.
142
142
// it would make the code that calls this more complex to handle it.
143
143
// this really shouldn't happen anyway
144
- log.e(" Critical error when registering a new device (error body: ${response? .errorBody()} )" )
144
+ log.e(" Critical error when registering a new device (error body: ${response.errorBody()} )" )
145
145
}
146
146
147
- val responseBody = response? .body()
147
+ val responseBody = response.body()
148
148
if (responseBody != null && response.code() in 200 .. 299 ) {
149
149
return RegisterDeviceResult (
150
150
deviceId = responseBody.id,
151
151
initialInterests = responseBody.initialInterestSet)
152
152
}
153
153
154
- val responseErrorBody = response? .errorBody()
154
+ val responseErrorBody = response.errorBody()
155
155
if (responseErrorBody != null ) {
156
156
val error = safeExtractJsonError(responseErrorBody.string())
157
157
log.w(" Failed to register device: $error " )
@@ -173,12 +173,12 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
173
173
throw PushNotificationsAPIDeviceNotFound ()
174
174
}
175
175
if (response.code() == 400 ) {
176
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
176
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
177
177
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
178
178
}
179
179
180
180
if (response.code() !in 200 .. 299 ) {
181
- val responseErrorBody = response? .errorBody()
181
+ val responseErrorBody = response.errorBody()
182
182
if (responseErrorBody != null ) {
183
183
val error = safeExtractJsonError(responseErrorBody.string())
184
184
log.w(" Failed to subscribe to interest: $error " )
@@ -201,12 +201,12 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
201
201
throw PushNotificationsAPIDeviceNotFound ()
202
202
}
203
203
if (response.code() == 400 ) {
204
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
204
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
205
205
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
206
206
}
207
207
208
208
if (response.code() !in 200 .. 299 ) {
209
- val responseErrorBody = response? .errorBody()
209
+ val responseErrorBody = response.errorBody()
210
210
if (responseErrorBody != null ) {
211
211
val error = safeExtractJsonError(responseErrorBody.string())
212
212
log.w(" Failed to unsubscribe from interest: $error " )
@@ -229,12 +229,12 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
229
229
throw PushNotificationsAPIDeviceNotFound ()
230
230
}
231
231
if (response.code() == 400 ) {
232
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
232
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
233
233
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
234
234
}
235
235
236
236
if (response.code() !in 200 .. 299 ) {
237
- val responseErrorBody = response? .errorBody()
237
+ val responseErrorBody = response.errorBody()
238
238
if (responseErrorBody != null ) {
239
239
val error = safeExtractJsonError(responseErrorBody.string())
240
240
log.w(" Failed to set subscriptions: $error " )
@@ -257,12 +257,12 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
257
257
throw PushNotificationsAPIDeviceNotFound ()
258
258
}
259
259
if (response.code() == 400 ) {
260
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
260
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
261
261
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
262
262
}
263
263
264
264
if (response.code() !in 200 .. 299 ) {
265
- val responseErrorBody = response? .errorBody()
265
+ val responseErrorBody = response.errorBody()
266
266
if (responseErrorBody != null ) {
267
267
val error = safeExtractJsonError(responseErrorBody.string())
268
268
log.w(" Failed to refresh FCM token: $error " )
@@ -289,12 +289,12 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
289
289
throw PushNotificationsAPIDeviceNotFound ()
290
290
}
291
291
if (response.code() == 400 ) {
292
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
292
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
293
293
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
294
294
}
295
295
296
296
if (response.code() !in 200 .. 299 ) {
297
- val responseErrorBody = response? .errorBody()
297
+ val responseErrorBody = response.errorBody()
298
298
if (responseErrorBody != null ) {
299
299
val error = safeExtractJsonError(responseErrorBody.string())
300
300
log.w(" Failed to set device metadata: $error " )
@@ -318,30 +318,30 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
318
318
throw PushNotificationsAPIDeviceNotFound ()
319
319
}
320
320
if (response.code() == 400 ) {
321
- val reason = response? .errorBody()?.let { safeExtractJsonError(it.string()).description }
321
+ val reason = response.errorBody()?.let { safeExtractJsonError(it.string()).description }
322
322
throw PushNotificationsAPIBadRequest (reason ? : " Unknown reason" )
323
323
}
324
324
if (response.code() == 401 || response.code() == 403 ) {
325
- val responseErrorBody = response? .errorBody()
325
+ val responseErrorBody = response.errorBody()
326
326
if (responseErrorBody != null ) {
327
327
val error = safeExtractJsonError(responseErrorBody.string())
328
- throw PushNotificationsAPIBadJWT (" ${error? .error} : ${error? .description} " )
328
+ throw PushNotificationsAPIBadJWT (" ${error.error} : ${error.description} " )
329
329
}
330
330
331
331
throw PushNotificationsAPIBadJWT (" Unknown reason" )
332
332
}
333
333
if (response.code() == 422 ) {
334
- val responseErrorBody = response? .errorBody()
334
+ val responseErrorBody = response.errorBody()
335
335
if (responseErrorBody != null ) {
336
336
val error = safeExtractJsonError(responseErrorBody.string())
337
- throw PushNotificationsAPIUnprocessableEntity (" ${error? .error} : ${error? .description} " )
337
+ throw PushNotificationsAPIUnprocessableEntity (" ${error.error} : ${error.description} " )
338
338
}
339
339
340
340
throw PushNotificationsAPIUnprocessableEntity (" Unknown reason" )
341
341
}
342
342
343
343
if (response.code() !in 200 .. 299 ) {
344
- val responseErrorBody = response? .errorBody()
344
+ val responseErrorBody = response.errorBody()
345
345
if (responseErrorBody != null ) {
346
346
val error = safeExtractJsonError(responseErrorBody.string())
347
347
log.w(" Failed to set user id: $error " )
@@ -369,11 +369,11 @@ class PushNotificationsAPI(private val instanceId: String, overrideHostURL: Stri
369
369
// not throwing a `PushNotificationsAPIBadRequest` here so that it still retries this request.
370
370
// it would make the code that calls this more complex to handle it.
371
371
// this really shouldn't happen anyway
372
- log.e(" Critical error when deleting a device (error body: ${response? .errorBody()} )" )
372
+ log.e(" Critical error when deleting a device (error body: ${response.errorBody()} )" )
373
373
}
374
374
375
375
if (response.code() !in 200 .. 299 ) {
376
- val responseErrorBody = response? .errorBody()
376
+ val responseErrorBody = response.errorBody()
377
377
if (responseErrorBody != null ) {
378
378
val error = safeExtractJsonError(responseErrorBody.string())
379
379
log.w(" Failed to delete device: $error " )
0 commit comments