@safercity/sdk 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/dist/index.cjs +120 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +157 -141
- package/dist/index.d.ts +157 -141
- package/dist/index.js +120 -105
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ function createSaferCityClient(options) {
|
|
|
48
48
|
/**
|
|
49
49
|
* Check API health status
|
|
50
50
|
*/
|
|
51
|
-
check: () => baseClient.get("/health")
|
|
51
|
+
check: () => baseClient.get("/health").then((r) => r.data)
|
|
52
52
|
},
|
|
53
53
|
// ==================
|
|
54
54
|
// Authentication
|
|
@@ -57,11 +57,11 @@ function createSaferCityClient(options) {
|
|
|
57
57
|
/**
|
|
58
58
|
* Get current authentication context
|
|
59
59
|
*/
|
|
60
|
-
whoami: () => baseClient.get("/auth/whoami"),
|
|
60
|
+
whoami: () => baseClient.get("/auth/whoami").then((r) => r.data),
|
|
61
61
|
/**
|
|
62
62
|
* Check if authenticated (optional auth)
|
|
63
63
|
*/
|
|
64
|
-
check: () => baseClient.get("/auth/optional")
|
|
64
|
+
check: () => baseClient.get("/auth/optional").then((r) => r.data)
|
|
65
65
|
},
|
|
66
66
|
// ==================
|
|
67
67
|
// Users (user-scoped)
|
|
@@ -70,15 +70,15 @@ function createSaferCityClient(options) {
|
|
|
70
70
|
/**
|
|
71
71
|
* Create user (used by tenant apps to register users)
|
|
72
72
|
*/
|
|
73
|
-
create: (body) => baseClient.post("/v1/users", body),
|
|
73
|
+
create: (body) => baseClient.post("/v1/users", body).then((r) => r.data),
|
|
74
74
|
/**
|
|
75
75
|
* Get user by ID
|
|
76
76
|
*/
|
|
77
|
-
get: (userId2) => baseClient.get(`/v1/users/${resolveUserId(userId2)}`),
|
|
77
|
+
get: (userId2) => baseClient.get(`/v1/users/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
78
78
|
/**
|
|
79
79
|
* Update user (user can update self)
|
|
80
80
|
*/
|
|
81
|
-
update: (userId2, body) => baseClient.put(`/v1/users/${resolveUserId(userId2)}`, body)
|
|
81
|
+
update: (userId2, body) => baseClient.put(`/v1/users/${resolveUserId(userId2)}`, body).then((r) => r.data)
|
|
82
82
|
},
|
|
83
83
|
// ==================
|
|
84
84
|
// Panics
|
|
@@ -87,9 +87,12 @@ function createSaferCityClient(options) {
|
|
|
87
87
|
/**
|
|
88
88
|
* Create panic
|
|
89
89
|
*/
|
|
90
|
-
create: (body) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
90
|
+
create: async (body) => {
|
|
91
|
+
const response = await baseClient.post("/v1/panic", {
|
|
92
|
+
...body,
|
|
93
|
+
userId: resolveUserId(body.userId)
|
|
94
|
+
}).then((r) => r.data);
|
|
95
|
+
return response;
|
|
93
96
|
},
|
|
94
97
|
/**
|
|
95
98
|
* Get panic by ID
|
|
@@ -99,25 +102,31 @@ function createSaferCityClient(options) {
|
|
|
99
102
|
...query,
|
|
100
103
|
userId: resolveUserId(query?.userId)
|
|
101
104
|
}
|
|
102
|
-
}),
|
|
105
|
+
}).then((r) => r.data),
|
|
103
106
|
/**
|
|
104
107
|
* Update panic location
|
|
105
108
|
*/
|
|
106
|
-
updateLocation: (panicId, body) => {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
+
updateLocation: async (panicId, body) => {
|
|
110
|
+
const response = await baseClient.put(`/v1/panic/${panicId}/location`, {
|
|
111
|
+
...body,
|
|
112
|
+
userId: resolveUserId(body.userId)
|
|
113
|
+
}).then((r) => r.data);
|
|
114
|
+
return response;
|
|
109
115
|
},
|
|
110
116
|
/**
|
|
111
117
|
* Cancel panic
|
|
112
118
|
*/
|
|
113
|
-
cancel: (panicId, body) => {
|
|
114
|
-
const
|
|
115
|
-
|
|
119
|
+
cancel: async (panicId, body) => {
|
|
120
|
+
const response = await baseClient.put(`/v1/panic/${panicId}/cancel`, {
|
|
121
|
+
...body,
|
|
122
|
+
userId: resolveUserId(body.userId)
|
|
123
|
+
}).then((r) => r.data);
|
|
124
|
+
return response;
|
|
116
125
|
},
|
|
117
126
|
/**
|
|
118
127
|
* Get available panic types for a user
|
|
119
128
|
*/
|
|
120
|
-
types: (userId2) => baseClient.get(`/v1/panic/types/${resolveUserId(userId2)}`),
|
|
129
|
+
types: (userId2) => baseClient.get(`/v1/panic/types/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
121
130
|
/**
|
|
122
131
|
* Stream panic updates (SSE)
|
|
123
132
|
*/
|
|
@@ -140,32 +149,35 @@ function createSaferCityClient(options) {
|
|
|
140
149
|
/**
|
|
141
150
|
* Create panic information profile
|
|
142
151
|
*/
|
|
143
|
-
create: (body) => {
|
|
144
|
-
const
|
|
145
|
-
|
|
152
|
+
create: async (body) => {
|
|
153
|
+
const response = await baseClient.post("/v1/panic-information", {
|
|
154
|
+
...body,
|
|
155
|
+
userId: resolveUserId(body.userId)
|
|
156
|
+
}).then((r) => r.data);
|
|
157
|
+
return response;
|
|
146
158
|
},
|
|
147
159
|
/**
|
|
148
160
|
* Get panic information by ID
|
|
149
161
|
*/
|
|
150
|
-
get: (id) => baseClient.get(`/v1/panic-information/${id}`),
|
|
162
|
+
get: (id) => baseClient.get(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
151
163
|
/**
|
|
152
164
|
* Get panic information by user ID
|
|
153
165
|
*/
|
|
154
|
-
getByUser: (userId2) => baseClient.get(`/v1/panic-information/user/${resolveUserId(userId2)}`),
|
|
166
|
+
getByUser: (userId2) => baseClient.get(`/v1/panic-information/user/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
155
167
|
/**
|
|
156
168
|
* Update panic information
|
|
157
169
|
*/
|
|
158
|
-
update: (id, body) => baseClient.put(`/v1/panic-information/${id}`, body),
|
|
170
|
+
update: (id, body) => baseClient.put(`/v1/panic-information/${id}`, body).then((r) => r.data),
|
|
159
171
|
/**
|
|
160
172
|
* Delete panic information
|
|
161
173
|
*/
|
|
162
|
-
delete: (id) => baseClient.delete(`/v1/panic-information/${id}`),
|
|
174
|
+
delete: (id) => baseClient.delete(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
163
175
|
/**
|
|
164
176
|
* Validate user eligibility for panic services
|
|
165
177
|
*/
|
|
166
178
|
validateEligibility: (userId2) => baseClient.get(
|
|
167
179
|
`/v1/panic-information/validation/${resolveUserId(userId2)}`
|
|
168
|
-
)
|
|
180
|
+
).then((r) => r.data)
|
|
169
181
|
},
|
|
170
182
|
// ==================
|
|
171
183
|
// Subscriptions
|
|
@@ -174,35 +186,38 @@ function createSaferCityClient(options) {
|
|
|
174
186
|
/**
|
|
175
187
|
* List subscription types
|
|
176
188
|
*/
|
|
177
|
-
listTypes: () => baseClient.get("/v1/subscriptions/types"),
|
|
189
|
+
listTypes: () => baseClient.get("/v1/subscriptions/types").then((r) => r.data),
|
|
178
190
|
/**
|
|
179
191
|
* Create subscription
|
|
180
192
|
*/
|
|
181
|
-
create: (body) => {
|
|
182
|
-
const
|
|
183
|
-
|
|
193
|
+
create: async (body) => {
|
|
194
|
+
const response = await baseClient.post("/v1/subscriptions", {
|
|
195
|
+
...body,
|
|
196
|
+
userId: resolveUserId(body.userId)
|
|
197
|
+
}).then((r) => r.data);
|
|
198
|
+
return response;
|
|
184
199
|
},
|
|
185
200
|
/**
|
|
186
201
|
* List subscriptions
|
|
187
202
|
*/
|
|
188
|
-
list: (query) => {
|
|
189
|
-
const
|
|
190
|
-
return baseClient.get("/v1/subscriptions", {
|
|
203
|
+
list: async (query) => {
|
|
204
|
+
const response = await baseClient.get("/v1/subscriptions", {
|
|
191
205
|
query: {
|
|
192
206
|
...query,
|
|
193
|
-
userId:
|
|
207
|
+
userId: resolveUserId(query?.userId)
|
|
194
208
|
}
|
|
195
|
-
});
|
|
209
|
+
}).then((r) => r.data);
|
|
210
|
+
return response;
|
|
196
211
|
},
|
|
197
212
|
/**
|
|
198
213
|
* Subscribe a user to a subscription type
|
|
199
214
|
*/
|
|
200
|
-
subscribeUser: (body) => {
|
|
201
|
-
const
|
|
202
|
-
return baseClient.post(
|
|
215
|
+
subscribeUser: async (body) => {
|
|
216
|
+
const response = await baseClient.post(
|
|
203
217
|
"/v1/subscriptions/subscribe-user",
|
|
204
|
-
{ ...body, userId:
|
|
205
|
-
);
|
|
218
|
+
{ ...body, userId: resolveUserId(body.userId) }
|
|
219
|
+
).then((r) => r.data);
|
|
220
|
+
return response;
|
|
206
221
|
}
|
|
207
222
|
},
|
|
208
223
|
// ==================
|
|
@@ -212,22 +227,22 @@ function createSaferCityClient(options) {
|
|
|
212
227
|
/**
|
|
213
228
|
* Create subscriber
|
|
214
229
|
*/
|
|
215
|
-
createSubscriber: (body) => {
|
|
216
|
-
const
|
|
217
|
-
return baseClient.post("/v1/notifications/subscribers", {
|
|
230
|
+
createSubscriber: async (body) => {
|
|
231
|
+
const response = await baseClient.post("/v1/notifications/subscribers", {
|
|
218
232
|
...body,
|
|
219
|
-
userId:
|
|
220
|
-
});
|
|
233
|
+
userId: resolveUserId(body.userId)
|
|
234
|
+
}).then((r) => r.data);
|
|
235
|
+
return response;
|
|
221
236
|
},
|
|
222
237
|
/**
|
|
223
238
|
* Trigger notification
|
|
224
239
|
*/
|
|
225
|
-
trigger: (body) => {
|
|
226
|
-
const
|
|
227
|
-
return baseClient.post("/v1/notifications/trigger", {
|
|
240
|
+
trigger: async (body) => {
|
|
241
|
+
const response = await baseClient.post("/v1/notifications/trigger", {
|
|
228
242
|
...body,
|
|
229
|
-
userId:
|
|
230
|
-
});
|
|
243
|
+
userId: resolveUserId(body.userId)
|
|
244
|
+
}).then((r) => r.data);
|
|
245
|
+
return response;
|
|
231
246
|
},
|
|
232
247
|
/**
|
|
233
248
|
* Bulk trigger notifications
|
|
@@ -235,20 +250,20 @@ function createSaferCityClient(options) {
|
|
|
235
250
|
bulkTrigger: (body) => baseClient.post(
|
|
236
251
|
"/v1/notifications/bulk-trigger",
|
|
237
252
|
body
|
|
238
|
-
),
|
|
253
|
+
).then((r) => r.data),
|
|
239
254
|
/**
|
|
240
255
|
* Get user preferences
|
|
241
256
|
*/
|
|
242
257
|
getPreferences: (userId2) => baseClient.get(
|
|
243
258
|
`/v1/notifications/preferences/${resolveUserId(userId2)}`
|
|
244
|
-
),
|
|
259
|
+
).then((r) => r.data),
|
|
245
260
|
/**
|
|
246
261
|
* Update user preferences
|
|
247
262
|
*/
|
|
248
263
|
updatePreferences: (userId2, body) => baseClient.put(
|
|
249
264
|
`/v1/notifications/preferences/${resolveUserId(userId2)}`,
|
|
250
265
|
body
|
|
251
|
-
)
|
|
266
|
+
).then((r) => r.data)
|
|
252
267
|
},
|
|
253
268
|
// ==================
|
|
254
269
|
// Location Safety
|
|
@@ -257,7 +272,7 @@ function createSaferCityClient(options) {
|
|
|
257
272
|
/**
|
|
258
273
|
* Check location safety
|
|
259
274
|
*/
|
|
260
|
-
check: (body) => baseClient.post("/v1/locations/safety-check", body)
|
|
275
|
+
check: (body) => baseClient.post("/v1/locations/safety-check", body).then((r) => r.data)
|
|
261
276
|
},
|
|
262
277
|
// ==================
|
|
263
278
|
// Banner
|
|
@@ -266,7 +281,7 @@ function createSaferCityClient(options) {
|
|
|
266
281
|
/**
|
|
267
282
|
* Get crime banner data for a location
|
|
268
283
|
*/
|
|
269
|
-
get: (body) => baseClient.post("/v1/banner", body)
|
|
284
|
+
get: (body) => baseClient.post("/v1/banner", body).then((r) => r.data)
|
|
270
285
|
},
|
|
271
286
|
// ==================
|
|
272
287
|
// Crimes
|
|
@@ -275,19 +290,19 @@ function createSaferCityClient(options) {
|
|
|
275
290
|
/**
|
|
276
291
|
* List crimes
|
|
277
292
|
*/
|
|
278
|
-
list: (query) => baseClient.get("/v1/crimes/list", { query }),
|
|
293
|
+
list: (query) => baseClient.get("/v1/crimes/list", { query }).then((r) => r.data),
|
|
279
294
|
/**
|
|
280
295
|
* Get crime categories
|
|
281
296
|
*/
|
|
282
|
-
categories: () => baseClient.get("/v1/crime-categories"),
|
|
297
|
+
categories: () => baseClient.get("/v1/crime-categories").then((r) => r.data),
|
|
283
298
|
/**
|
|
284
299
|
* Get crime types
|
|
285
300
|
*/
|
|
286
|
-
types: () => baseClient.get("/v1/crime-types"),
|
|
301
|
+
types: () => baseClient.get("/v1/crime-types").then((r) => r.data),
|
|
287
302
|
/**
|
|
288
303
|
* Get crime categories with their types
|
|
289
304
|
*/
|
|
290
|
-
categoriesWithTypes: () => baseClient.get("/v1/crime-categories/withTypes")
|
|
305
|
+
categoriesWithTypes: () => baseClient.get("/v1/crime-categories/withTypes").then((r) => r.data)
|
|
291
306
|
}
|
|
292
307
|
};
|
|
293
308
|
}
|
|
@@ -348,7 +363,7 @@ var ServerClient = class extends BaseClient {
|
|
|
348
363
|
*/
|
|
349
364
|
get health() {
|
|
350
365
|
return {
|
|
351
|
-
check: () => this.get("/health")
|
|
366
|
+
check: () => this.get("/health").then((r) => r.data)
|
|
352
367
|
};
|
|
353
368
|
}
|
|
354
369
|
// ==================
|
|
@@ -362,11 +377,11 @@ var ServerClient = class extends BaseClient {
|
|
|
362
377
|
/**
|
|
363
378
|
* Get current authentication context
|
|
364
379
|
*/
|
|
365
|
-
whoami: () => this.get("/auth/whoami"),
|
|
380
|
+
whoami: () => this.get("/auth/whoami").then((r) => r.data),
|
|
366
381
|
/**
|
|
367
382
|
* Check if authenticated (optional auth)
|
|
368
383
|
*/
|
|
369
|
-
check: () => this.get("/auth/optional")
|
|
384
|
+
check: () => this.get("/auth/optional").then((r) => r.data)
|
|
370
385
|
};
|
|
371
386
|
}
|
|
372
387
|
// ==================
|
|
@@ -380,19 +395,19 @@ var ServerClient = class extends BaseClient {
|
|
|
380
395
|
/**
|
|
381
396
|
* Get access token
|
|
382
397
|
*/
|
|
383
|
-
token: (body) => this.post("/v1/oauth/token", body),
|
|
398
|
+
token: (body) => this.post("/v1/oauth/token", body).then((r) => r.data),
|
|
384
399
|
/**
|
|
385
400
|
* Refresh access token
|
|
386
401
|
*/
|
|
387
|
-
refresh: (body) => this.post("/v1/oauth/refresh", body),
|
|
402
|
+
refresh: (body) => this.post("/v1/oauth/refresh", body).then((r) => r.data),
|
|
388
403
|
/**
|
|
389
404
|
* Introspect token
|
|
390
405
|
*/
|
|
391
|
-
introspect: (body) => this.post("/v1/oauth/introspect", body),
|
|
406
|
+
introspect: (body) => this.post("/v1/oauth/introspect", body).then((r) => r.data),
|
|
392
407
|
/**
|
|
393
408
|
* Revoke token
|
|
394
409
|
*/
|
|
395
|
-
revoke: (body) => this.post("/v1/oauth/revoke", body)
|
|
410
|
+
revoke: (body) => this.post("/v1/oauth/revoke", body).then((r) => r.data)
|
|
396
411
|
};
|
|
397
412
|
}
|
|
398
413
|
// ==================
|
|
@@ -406,11 +421,11 @@ var ServerClient = class extends BaseClient {
|
|
|
406
421
|
/**
|
|
407
422
|
* Create a new tenant
|
|
408
423
|
*/
|
|
409
|
-
create: (body) => this.post("/v1/tenants", body),
|
|
424
|
+
create: (body) => this.post("/v1/tenants", body).then((r) => r.data),
|
|
410
425
|
/**
|
|
411
426
|
* List tenants (admin)
|
|
412
427
|
*/
|
|
413
|
-
list: (query) => this.get("/v1/tenants", { query })
|
|
428
|
+
list: (query) => this.get("/v1/tenants", { query }).then((r) => r.data)
|
|
414
429
|
};
|
|
415
430
|
}
|
|
416
431
|
// ==================
|
|
@@ -424,15 +439,15 @@ var ServerClient = class extends BaseClient {
|
|
|
424
439
|
/**
|
|
425
440
|
* Exchange setup token for credentials
|
|
426
441
|
*/
|
|
427
|
-
setup: (body) => this.post("/v1/credentials", body),
|
|
442
|
+
setup: (body) => this.post("/v1/credentials", body).then((r) => r.data),
|
|
428
443
|
/**
|
|
429
444
|
* List credentials
|
|
430
445
|
*/
|
|
431
|
-
list: () => this.get("/v1/credentials"),
|
|
446
|
+
list: () => this.get("/v1/credentials").then((r) => r.data),
|
|
432
447
|
/**
|
|
433
448
|
* Revoke credential
|
|
434
449
|
*/
|
|
435
|
-
revoke: (credentialId) => this.delete(`/v1/credentials/${credentialId}`)
|
|
450
|
+
revoke: (credentialId) => this.delete(`/v1/credentials/${credentialId}`).then((r) => r.data)
|
|
436
451
|
};
|
|
437
452
|
}
|
|
438
453
|
// ==================
|
|
@@ -446,27 +461,27 @@ var ServerClient = class extends BaseClient {
|
|
|
446
461
|
/**
|
|
447
462
|
* Create user
|
|
448
463
|
*/
|
|
449
|
-
create: (body) => this.post("/v1/users", body),
|
|
464
|
+
create: (body) => this.post("/v1/users", body).then((r) => r.data),
|
|
450
465
|
/**
|
|
451
466
|
* List users
|
|
452
467
|
*/
|
|
453
|
-
list: (query) => this.get("/v1/users", { query }),
|
|
468
|
+
list: (query) => this.get("/v1/users", { query }).then((r) => r.data),
|
|
454
469
|
/**
|
|
455
470
|
* Get user by ID
|
|
456
471
|
*/
|
|
457
|
-
get: (userId) => this.get(`/v1/users/${userId}`),
|
|
472
|
+
get: (userId) => this.get(`/v1/users/${userId}`).then((r) => r.data),
|
|
458
473
|
/**
|
|
459
474
|
* Update user
|
|
460
475
|
*/
|
|
461
|
-
update: (userId, body) => this.put(`/v1/users/${userId}`, body),
|
|
476
|
+
update: (userId, body) => this.put(`/v1/users/${userId}`, body).then((r) => r.data),
|
|
462
477
|
/**
|
|
463
478
|
* Update user status
|
|
464
479
|
*/
|
|
465
|
-
updateStatus: (userId, body) => this.patch(`/v1/users/${userId}/status`, body),
|
|
480
|
+
updateStatus: (userId, body) => this.patch(`/v1/users/${userId}/status`, body).then((r) => r.data),
|
|
466
481
|
/**
|
|
467
482
|
* Delete user
|
|
468
483
|
*/
|
|
469
|
-
delete: (userId) => this.delete(`/v1/users/${userId}`)
|
|
484
|
+
delete: (userId) => this.delete(`/v1/users/${userId}`).then((r) => r.data)
|
|
470
485
|
};
|
|
471
486
|
}
|
|
472
487
|
// ==================
|
|
@@ -480,27 +495,27 @@ var ServerClient = class extends BaseClient {
|
|
|
480
495
|
/**
|
|
481
496
|
* Create panic
|
|
482
497
|
*/
|
|
483
|
-
create: (body) => this.post("/v1/panic", body),
|
|
498
|
+
create: (body) => this.post("/v1/panic", body).then((r) => r.data),
|
|
484
499
|
/**
|
|
485
500
|
* Get panic by ID
|
|
486
501
|
*/
|
|
487
|
-
get: (panicId, query) => this.get(`/v1/panic/${panicId}`, { query }),
|
|
502
|
+
get: (panicId, query) => this.get(`/v1/panic/${panicId}`, { query }).then((r) => r.data),
|
|
488
503
|
/**
|
|
489
504
|
* List panics
|
|
490
505
|
*/
|
|
491
|
-
list: (query) => this.get("/v1/panic", { query }),
|
|
506
|
+
list: (query) => this.get("/v1/panic", { query }).then((r) => r.data),
|
|
492
507
|
/**
|
|
493
508
|
* Update panic location
|
|
494
509
|
*/
|
|
495
|
-
updateLocation: (panicId, body) => this.put(`/v1/panic/${panicId}/location`, body),
|
|
510
|
+
updateLocation: (panicId, body) => this.put(`/v1/panic/${panicId}/location`, body).then((r) => r.data),
|
|
496
511
|
/**
|
|
497
512
|
* Cancel panic
|
|
498
513
|
*/
|
|
499
|
-
cancel: (panicId, body) => this.put(`/v1/panic/${panicId}/cancel`, body),
|
|
514
|
+
cancel: (panicId, body) => this.put(`/v1/panic/${panicId}/cancel`, body).then((r) => r.data),
|
|
500
515
|
/**
|
|
501
516
|
* Get available panic types for a user
|
|
502
517
|
*/
|
|
503
|
-
types: (userId) => this.get(`/v1/panic/types/${userId}`)
|
|
518
|
+
types: (userId) => this.get(`/v1/panic/types/${userId}`).then((r) => r.data)
|
|
504
519
|
};
|
|
505
520
|
}
|
|
506
521
|
// ==================
|
|
@@ -514,23 +529,23 @@ var ServerClient = class extends BaseClient {
|
|
|
514
529
|
/**
|
|
515
530
|
* List subscription types
|
|
516
531
|
*/
|
|
517
|
-
listTypes: () => this.get("/v1/subscriptions/types"),
|
|
532
|
+
listTypes: () => this.get("/v1/subscriptions/types").then((r) => r.data),
|
|
518
533
|
/**
|
|
519
534
|
* Create subscription
|
|
520
535
|
*/
|
|
521
|
-
create: (body) => this.post("/v1/subscriptions", body),
|
|
536
|
+
create: (body) => this.post("/v1/subscriptions", body).then((r) => r.data),
|
|
522
537
|
/**
|
|
523
538
|
* List subscriptions
|
|
524
539
|
*/
|
|
525
|
-
list: (query) => this.get("/v1/subscriptions", { query }),
|
|
540
|
+
list: (query) => this.get("/v1/subscriptions", { query }).then((r) => r.data),
|
|
526
541
|
/**
|
|
527
542
|
* Get subscription stats
|
|
528
543
|
*/
|
|
529
|
-
stats: () => this.get("/v1/subscriptions/stats"),
|
|
544
|
+
stats: () => this.get("/v1/subscriptions/stats").then((r) => r.data),
|
|
530
545
|
/**
|
|
531
546
|
* Subscribe a user to a subscription type
|
|
532
547
|
*/
|
|
533
|
-
subscribeUser: (body) => this.post("/v1/subscriptions/subscribe-user", body)
|
|
548
|
+
subscribeUser: (body) => this.post("/v1/subscriptions/subscribe-user", body).then((r) => r.data)
|
|
534
549
|
};
|
|
535
550
|
}
|
|
536
551
|
// ==================
|
|
@@ -544,28 +559,28 @@ var ServerClient = class extends BaseClient {
|
|
|
544
559
|
/**
|
|
545
560
|
* Create subscriber
|
|
546
561
|
*/
|
|
547
|
-
createSubscriber: (body) => this.post("/v1/notifications/subscribers", body),
|
|
562
|
+
createSubscriber: (body) => this.post("/v1/notifications/subscribers", body).then((r) => r.data),
|
|
548
563
|
/**
|
|
549
564
|
* Trigger notification
|
|
550
565
|
*/
|
|
551
|
-
trigger: (body) => this.post("/v1/notifications/trigger", body),
|
|
566
|
+
trigger: (body) => this.post("/v1/notifications/trigger", body).then((r) => r.data),
|
|
552
567
|
/**
|
|
553
568
|
* Bulk trigger notifications
|
|
554
569
|
*/
|
|
555
|
-
bulkTrigger: (body) => this.post("/v1/notifications/bulk-trigger", body),
|
|
570
|
+
bulkTrigger: (body) => this.post("/v1/notifications/bulk-trigger", body).then((r) => r.data),
|
|
556
571
|
/**
|
|
557
572
|
* Get user preferences
|
|
558
573
|
*/
|
|
559
574
|
getPreferences: (userId) => this.get(
|
|
560
575
|
`/v1/notifications/preferences/${userId}`
|
|
561
|
-
),
|
|
576
|
+
).then((r) => r.data),
|
|
562
577
|
/**
|
|
563
578
|
* Update user preferences
|
|
564
579
|
*/
|
|
565
580
|
updatePreferences: (userId, body) => this.put(
|
|
566
581
|
`/v1/notifications/preferences/${userId}`,
|
|
567
582
|
body
|
|
568
|
-
)
|
|
583
|
+
).then((r) => r.data)
|
|
569
584
|
};
|
|
570
585
|
}
|
|
571
586
|
// ==================
|
|
@@ -579,33 +594,33 @@ var ServerClient = class extends BaseClient {
|
|
|
579
594
|
/**
|
|
580
595
|
* Create panic information profile
|
|
581
596
|
*/
|
|
582
|
-
create: (body) => this.post("/v1/panic-information", body),
|
|
597
|
+
create: (body) => this.post("/v1/panic-information", body).then((r) => r.data),
|
|
583
598
|
/**
|
|
584
599
|
* List panic information records
|
|
585
600
|
*/
|
|
586
|
-
list: (query) => this.get("/v1/panic-information", { query }),
|
|
601
|
+
list: (query) => this.get("/v1/panic-information", { query }).then((r) => r.data),
|
|
587
602
|
/**
|
|
588
603
|
* Get panic information by ID
|
|
589
604
|
*/
|
|
590
|
-
get: (id) => this.get(`/v1/panic-information/${id}`),
|
|
605
|
+
get: (id) => this.get(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
591
606
|
/**
|
|
592
607
|
* Get panic information by user ID
|
|
593
608
|
*/
|
|
594
|
-
getByUser: (userId) => this.get(`/v1/panic-information/user/${userId}`),
|
|
609
|
+
getByUser: (userId) => this.get(`/v1/panic-information/user/${userId}`).then((r) => r.data),
|
|
595
610
|
/**
|
|
596
611
|
* Update panic information
|
|
597
612
|
*/
|
|
598
|
-
update: (id, body) => this.put(`/v1/panic-information/${id}`, body),
|
|
613
|
+
update: (id, body) => this.put(`/v1/panic-information/${id}`, body).then((r) => r.data),
|
|
599
614
|
/**
|
|
600
615
|
* Delete panic information
|
|
601
616
|
*/
|
|
602
|
-
delete: (id) => this.delete(`/v1/panic-information/${id}`),
|
|
617
|
+
delete: (id) => this.delete(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
603
618
|
/**
|
|
604
619
|
* Validate user eligibility for panic services
|
|
605
620
|
*/
|
|
606
621
|
validateEligibility: (userId) => this.get(
|
|
607
622
|
`/v1/panic-information/validation/${userId}`
|
|
608
|
-
)
|
|
623
|
+
).then((r) => r.data)
|
|
609
624
|
};
|
|
610
625
|
}
|
|
611
626
|
// ==================
|
|
@@ -619,7 +634,7 @@ var ServerClient = class extends BaseClient {
|
|
|
619
634
|
/**
|
|
620
635
|
* Check location safety
|
|
621
636
|
*/
|
|
622
|
-
check: (body) => this.post("/v1/locations/safety-check", body)
|
|
637
|
+
check: (body) => this.post("/v1/locations/safety-check", body).then((r) => r.data)
|
|
623
638
|
};
|
|
624
639
|
}
|
|
625
640
|
// ==================
|
|
@@ -633,7 +648,7 @@ var ServerClient = class extends BaseClient {
|
|
|
633
648
|
/**
|
|
634
649
|
* Get crime banner data for a location
|
|
635
650
|
*/
|
|
636
|
-
get: (body) => this.post("/v1/banner", body)
|
|
651
|
+
get: (body) => this.post("/v1/banner", body).then((r) => r.data)
|
|
637
652
|
};
|
|
638
653
|
}
|
|
639
654
|
// ==================
|
|
@@ -647,19 +662,19 @@ var ServerClient = class extends BaseClient {
|
|
|
647
662
|
/**
|
|
648
663
|
* List crimes
|
|
649
664
|
*/
|
|
650
|
-
list: (query) => this.get("/v1/crimes/list", { query }),
|
|
665
|
+
list: (query) => this.get("/v1/crimes/list", { query }).then((r) => r.data),
|
|
651
666
|
/**
|
|
652
667
|
* Get crime categories
|
|
653
668
|
*/
|
|
654
|
-
categories: () => this.get("/v1/crime-categories"),
|
|
669
|
+
categories: () => this.get("/v1/crime-categories").then((r) => r.data),
|
|
655
670
|
/**
|
|
656
671
|
* Get crime types
|
|
657
672
|
*/
|
|
658
|
-
types: () => this.get("/v1/crime-types"),
|
|
673
|
+
types: () => this.get("/v1/crime-types").then((r) => r.data),
|
|
659
674
|
/**
|
|
660
675
|
* Get crime categories with their types
|
|
661
676
|
*/
|
|
662
|
-
categoriesWithTypes: () => this.get("/v1/crime-categories/withTypes")
|
|
677
|
+
categoriesWithTypes: () => this.get("/v1/crime-categories/withTypes").then((r) => r.data)
|
|
663
678
|
};
|
|
664
679
|
}
|
|
665
680
|
};
|