@safercity/sdk 0.3.0 → 0.3.2
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 +32 -7
- package/dist/index.cjs +120 -105
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -143
- package/dist/index.d.ts +159 -143
- package/dist/index.js +120 -105
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,11 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
Official SaferCity API client for TypeScript/JavaScript.
|
|
4
4
|
|
|
5
|
+
## What's New in v0.3.2
|
|
6
|
+
|
|
7
|
+
- **Proxy Mode Enhanced** - `ProxyModeConfig` now supports `tenantId`, `userId`, and custom `headers`. White-label apps can pass tenant context through the proxy without exposing credentials.
|
|
8
|
+
- **Banner API Fix** - Fixed `banner.get()` parameter from `radius` to `days` to match the API schema.
|
|
9
|
+
|
|
10
|
+
```tsx
|
|
11
|
+
// New proxy mode with tenant support
|
|
12
|
+
<SaferCityProvider
|
|
13
|
+
mode="proxy"
|
|
14
|
+
proxyBaseUrl="/api/safercity"
|
|
15
|
+
tenantId="tenant-123" // Sent as X-Tenant-ID header
|
|
16
|
+
userId="user-456" // For user-scoped operations
|
|
17
|
+
headers={{ 'X-App': 'my-app' }}
|
|
18
|
+
>
|
|
19
|
+
<App />
|
|
20
|
+
</SaferCityProvider>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## What's New in v0.3.1
|
|
24
|
+
|
|
25
|
+
- **Simplified Return Types** - Domain methods now return the API response body directly instead of wrapping in `ApiResponse<T>`. For example, `client.health.check()` returns `Promise<{ status: string; timestamp: string }>` directly. No more `result.data.data.id` — just `result.data.id`.
|
|
26
|
+
- **Strongly Typed Errors** - All SDK methods throw `SaferCityApiError` on non-2xx responses with typed `status`, `error`, `message`, and `details` fields. Error handling is unchanged from v0.3.0.
|
|
27
|
+
- **Low-Level Access Preserved** - `client._client.get()` and `ServerClient.get()` still return the full `ApiResponse<T>` with `{ data, status, headers }` for cases where you need HTTP metadata.
|
|
28
|
+
|
|
5
29
|
## What's New in v0.3.0
|
|
6
30
|
|
|
7
31
|
- **Typed SDK via OpenAPI Codegen** - All request/response types are now auto-generated from the API's OpenAPI spec using `@hey-api/openapi-ts`. This guarantees 1:1 type alignment between the SDK and API — no more manual type mismatches.
|
|
8
32
|
- **Re-exported Generated Types** - All generated API types (request bodies, response shapes, error types) are re-exported from `@safercity/sdk` for direct use in your application.
|
|
9
33
|
- **Correct Field Names** - Request bodies now use the exact API field names (`emailAddress` not `email`, `panicType` not `panicTypeId`, `phoneNumber` not `phone`).
|
|
34
|
+
- **Simplified Return Types** - Domain methods now return the API response body directly instead of wrapping in `ApiResponse<T>`. Access `result.data.id` instead of `result.data.data.id`.
|
|
10
35
|
- **Richer Response Types** - Response types now include the full API response structure (e.g., `{ success: boolean; data: {...}; message?: string }`).
|
|
11
36
|
|
|
12
37
|
## What's New in v0.2.0
|
|
@@ -93,22 +118,22 @@ const client = createSaferCityClient({
|
|
|
93
118
|
});
|
|
94
119
|
|
|
95
120
|
// Health check
|
|
96
|
-
const
|
|
121
|
+
const health = await client.health.check();
|
|
97
122
|
console.log('API Status:', health.status);
|
|
98
123
|
|
|
99
124
|
// Get user (auto-resolves userId from client if not passed)
|
|
100
|
-
const
|
|
101
|
-
console.log('User:', user);
|
|
125
|
+
const user = await client.users.get();
|
|
126
|
+
console.log('User:', user.data.firstName);
|
|
102
127
|
|
|
103
128
|
// Create panic (userId is optional if set on client)
|
|
104
|
-
const
|
|
129
|
+
const panic = await client.panics.create({
|
|
105
130
|
userId: 'user-123',
|
|
106
131
|
panicType: 'emergency',
|
|
107
132
|
latitude: -26.2041,
|
|
108
133
|
longitude: 28.0473,
|
|
109
134
|
});
|
|
110
135
|
|
|
111
|
-
console.log('Panic created:', panic.id);
|
|
136
|
+
console.log('Panic created:', panic.data.id);
|
|
112
137
|
```
|
|
113
138
|
|
|
114
139
|
## Server Client
|
|
@@ -130,8 +155,8 @@ const client = createServerClient({
|
|
|
130
155
|
|
|
131
156
|
// All requests are automatically authenticated with OAuth tokens
|
|
132
157
|
// Tokens are refreshed automatically before expiration
|
|
133
|
-
const
|
|
134
|
-
const
|
|
158
|
+
const users = await client.users.list(); // Admin only
|
|
159
|
+
const panic = await client.panics.create({
|
|
135
160
|
userId: 'user-123',
|
|
136
161
|
panicType: 'emergency',
|
|
137
162
|
latitude: -26.2041,
|
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,7 @@ function createSaferCityClient(options) {
|
|
|
49
49
|
/**
|
|
50
50
|
* Check API health status
|
|
51
51
|
*/
|
|
52
|
-
check: () => baseClient.get("/health")
|
|
52
|
+
check: () => baseClient.get("/health").then((r) => r.data)
|
|
53
53
|
},
|
|
54
54
|
// ==================
|
|
55
55
|
// Authentication
|
|
@@ -58,11 +58,11 @@ function createSaferCityClient(options) {
|
|
|
58
58
|
/**
|
|
59
59
|
* Get current authentication context
|
|
60
60
|
*/
|
|
61
|
-
whoami: () => baseClient.get("/auth/whoami"),
|
|
61
|
+
whoami: () => baseClient.get("/auth/whoami").then((r) => r.data),
|
|
62
62
|
/**
|
|
63
63
|
* Check if authenticated (optional auth)
|
|
64
64
|
*/
|
|
65
|
-
check: () => baseClient.get("/auth/optional")
|
|
65
|
+
check: () => baseClient.get("/auth/optional").then((r) => r.data)
|
|
66
66
|
},
|
|
67
67
|
// ==================
|
|
68
68
|
// Users (user-scoped)
|
|
@@ -71,15 +71,15 @@ function createSaferCityClient(options) {
|
|
|
71
71
|
/**
|
|
72
72
|
* Create user (used by tenant apps to register users)
|
|
73
73
|
*/
|
|
74
|
-
create: (body) => baseClient.post("/v1/users", body),
|
|
74
|
+
create: (body) => baseClient.post("/v1/users", body).then((r) => r.data),
|
|
75
75
|
/**
|
|
76
76
|
* Get user by ID
|
|
77
77
|
*/
|
|
78
|
-
get: (userId2) => baseClient.get(`/v1/users/${resolveUserId(userId2)}`),
|
|
78
|
+
get: (userId2) => baseClient.get(`/v1/users/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
79
79
|
/**
|
|
80
80
|
* Update user (user can update self)
|
|
81
81
|
*/
|
|
82
|
-
update: (userId2, body) => baseClient.put(`/v1/users/${resolveUserId(userId2)}`, body)
|
|
82
|
+
update: (userId2, body) => baseClient.put(`/v1/users/${resolveUserId(userId2)}`, body).then((r) => r.data)
|
|
83
83
|
},
|
|
84
84
|
// ==================
|
|
85
85
|
// Panics
|
|
@@ -88,9 +88,12 @@ function createSaferCityClient(options) {
|
|
|
88
88
|
/**
|
|
89
89
|
* Create panic
|
|
90
90
|
*/
|
|
91
|
-
create: (body) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
91
|
+
create: async (body) => {
|
|
92
|
+
const response = await baseClient.post("/v1/panic", {
|
|
93
|
+
...body,
|
|
94
|
+
userId: resolveUserId(body.userId)
|
|
95
|
+
}).then((r) => r.data);
|
|
96
|
+
return response;
|
|
94
97
|
},
|
|
95
98
|
/**
|
|
96
99
|
* Get panic by ID
|
|
@@ -100,25 +103,31 @@ function createSaferCityClient(options) {
|
|
|
100
103
|
...query,
|
|
101
104
|
userId: resolveUserId(query?.userId)
|
|
102
105
|
}
|
|
103
|
-
}),
|
|
106
|
+
}).then((r) => r.data),
|
|
104
107
|
/**
|
|
105
108
|
* Update panic location
|
|
106
109
|
*/
|
|
107
|
-
updateLocation: (panicId, body) => {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
+
updateLocation: async (panicId, body) => {
|
|
111
|
+
const response = await baseClient.put(`/v1/panic/${panicId}/location`, {
|
|
112
|
+
...body,
|
|
113
|
+
userId: resolveUserId(body.userId)
|
|
114
|
+
}).then((r) => r.data);
|
|
115
|
+
return response;
|
|
110
116
|
},
|
|
111
117
|
/**
|
|
112
118
|
* Cancel panic
|
|
113
119
|
*/
|
|
114
|
-
cancel: (panicId, body) => {
|
|
115
|
-
const
|
|
116
|
-
|
|
120
|
+
cancel: async (panicId, body) => {
|
|
121
|
+
const response = await baseClient.put(`/v1/panic/${panicId}/cancel`, {
|
|
122
|
+
...body,
|
|
123
|
+
userId: resolveUserId(body.userId)
|
|
124
|
+
}).then((r) => r.data);
|
|
125
|
+
return response;
|
|
117
126
|
},
|
|
118
127
|
/**
|
|
119
128
|
* Get available panic types for a user
|
|
120
129
|
*/
|
|
121
|
-
types: (userId2) => baseClient.get(`/v1/panic/types/${resolveUserId(userId2)}`),
|
|
130
|
+
types: (userId2) => baseClient.get(`/v1/panic/types/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
122
131
|
/**
|
|
123
132
|
* Stream panic updates (SSE)
|
|
124
133
|
*/
|
|
@@ -141,32 +150,35 @@ function createSaferCityClient(options) {
|
|
|
141
150
|
/**
|
|
142
151
|
* Create panic information profile
|
|
143
152
|
*/
|
|
144
|
-
create: (body) => {
|
|
145
|
-
const
|
|
146
|
-
|
|
153
|
+
create: async (body) => {
|
|
154
|
+
const response = await baseClient.post("/v1/panic-information", {
|
|
155
|
+
...body,
|
|
156
|
+
userId: resolveUserId(body.userId)
|
|
157
|
+
}).then((r) => r.data);
|
|
158
|
+
return response;
|
|
147
159
|
},
|
|
148
160
|
/**
|
|
149
161
|
* Get panic information by ID
|
|
150
162
|
*/
|
|
151
|
-
get: (id) => baseClient.get(`/v1/panic-information/${id}`),
|
|
163
|
+
get: (id) => baseClient.get(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
152
164
|
/**
|
|
153
165
|
* Get panic information by user ID
|
|
154
166
|
*/
|
|
155
|
-
getByUser: (userId2) => baseClient.get(`/v1/panic-information/user/${resolveUserId(userId2)}`),
|
|
167
|
+
getByUser: (userId2) => baseClient.get(`/v1/panic-information/user/${resolveUserId(userId2)}`).then((r) => r.data),
|
|
156
168
|
/**
|
|
157
169
|
* Update panic information
|
|
158
170
|
*/
|
|
159
|
-
update: (id, body) => baseClient.put(`/v1/panic-information/${id}`, body),
|
|
171
|
+
update: (id, body) => baseClient.put(`/v1/panic-information/${id}`, body).then((r) => r.data),
|
|
160
172
|
/**
|
|
161
173
|
* Delete panic information
|
|
162
174
|
*/
|
|
163
|
-
delete: (id) => baseClient.delete(`/v1/panic-information/${id}`),
|
|
175
|
+
delete: (id) => baseClient.delete(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
164
176
|
/**
|
|
165
177
|
* Validate user eligibility for panic services
|
|
166
178
|
*/
|
|
167
179
|
validateEligibility: (userId2) => baseClient.get(
|
|
168
180
|
`/v1/panic-information/validation/${resolveUserId(userId2)}`
|
|
169
|
-
)
|
|
181
|
+
).then((r) => r.data)
|
|
170
182
|
},
|
|
171
183
|
// ==================
|
|
172
184
|
// Subscriptions
|
|
@@ -175,35 +187,38 @@ function createSaferCityClient(options) {
|
|
|
175
187
|
/**
|
|
176
188
|
* List subscription types
|
|
177
189
|
*/
|
|
178
|
-
listTypes: () => baseClient.get("/v1/subscriptions/types"),
|
|
190
|
+
listTypes: () => baseClient.get("/v1/subscriptions/types").then((r) => r.data),
|
|
179
191
|
/**
|
|
180
192
|
* Create subscription
|
|
181
193
|
*/
|
|
182
|
-
create: (body) => {
|
|
183
|
-
const
|
|
184
|
-
|
|
194
|
+
create: async (body) => {
|
|
195
|
+
const response = await baseClient.post("/v1/subscriptions", {
|
|
196
|
+
...body,
|
|
197
|
+
userId: resolveUserId(body.userId)
|
|
198
|
+
}).then((r) => r.data);
|
|
199
|
+
return response;
|
|
185
200
|
},
|
|
186
201
|
/**
|
|
187
202
|
* List subscriptions
|
|
188
203
|
*/
|
|
189
|
-
list: (query) => {
|
|
190
|
-
const
|
|
191
|
-
return baseClient.get("/v1/subscriptions", {
|
|
204
|
+
list: async (query) => {
|
|
205
|
+
const response = await baseClient.get("/v1/subscriptions", {
|
|
192
206
|
query: {
|
|
193
207
|
...query,
|
|
194
|
-
userId:
|
|
208
|
+
userId: resolveUserId(query?.userId)
|
|
195
209
|
}
|
|
196
|
-
});
|
|
210
|
+
}).then((r) => r.data);
|
|
211
|
+
return response;
|
|
197
212
|
},
|
|
198
213
|
/**
|
|
199
214
|
* Subscribe a user to a subscription type
|
|
200
215
|
*/
|
|
201
|
-
subscribeUser: (body) => {
|
|
202
|
-
const
|
|
203
|
-
return baseClient.post(
|
|
216
|
+
subscribeUser: async (body) => {
|
|
217
|
+
const response = await baseClient.post(
|
|
204
218
|
"/v1/subscriptions/subscribe-user",
|
|
205
|
-
{ ...body, userId:
|
|
206
|
-
);
|
|
219
|
+
{ ...body, userId: resolveUserId(body.userId) }
|
|
220
|
+
).then((r) => r.data);
|
|
221
|
+
return response;
|
|
207
222
|
}
|
|
208
223
|
},
|
|
209
224
|
// ==================
|
|
@@ -213,22 +228,22 @@ function createSaferCityClient(options) {
|
|
|
213
228
|
/**
|
|
214
229
|
* Create subscriber
|
|
215
230
|
*/
|
|
216
|
-
createSubscriber: (body) => {
|
|
217
|
-
const
|
|
218
|
-
return baseClient.post("/v1/notifications/subscribers", {
|
|
231
|
+
createSubscriber: async (body) => {
|
|
232
|
+
const response = await baseClient.post("/v1/notifications/subscribers", {
|
|
219
233
|
...body,
|
|
220
|
-
userId:
|
|
221
|
-
});
|
|
234
|
+
userId: resolveUserId(body.userId)
|
|
235
|
+
}).then((r) => r.data);
|
|
236
|
+
return response;
|
|
222
237
|
},
|
|
223
238
|
/**
|
|
224
239
|
* Trigger notification
|
|
225
240
|
*/
|
|
226
|
-
trigger: (body) => {
|
|
227
|
-
const
|
|
228
|
-
return baseClient.post("/v1/notifications/trigger", {
|
|
241
|
+
trigger: async (body) => {
|
|
242
|
+
const response = await baseClient.post("/v1/notifications/trigger", {
|
|
229
243
|
...body,
|
|
230
|
-
userId:
|
|
231
|
-
});
|
|
244
|
+
userId: resolveUserId(body.userId)
|
|
245
|
+
}).then((r) => r.data);
|
|
246
|
+
return response;
|
|
232
247
|
},
|
|
233
248
|
/**
|
|
234
249
|
* Bulk trigger notifications
|
|
@@ -236,20 +251,20 @@ function createSaferCityClient(options) {
|
|
|
236
251
|
bulkTrigger: (body) => baseClient.post(
|
|
237
252
|
"/v1/notifications/bulk-trigger",
|
|
238
253
|
body
|
|
239
|
-
),
|
|
254
|
+
).then((r) => r.data),
|
|
240
255
|
/**
|
|
241
256
|
* Get user preferences
|
|
242
257
|
*/
|
|
243
258
|
getPreferences: (userId2) => baseClient.get(
|
|
244
259
|
`/v1/notifications/preferences/${resolveUserId(userId2)}`
|
|
245
|
-
),
|
|
260
|
+
).then((r) => r.data),
|
|
246
261
|
/**
|
|
247
262
|
* Update user preferences
|
|
248
263
|
*/
|
|
249
264
|
updatePreferences: (userId2, body) => baseClient.put(
|
|
250
265
|
`/v1/notifications/preferences/${resolveUserId(userId2)}`,
|
|
251
266
|
body
|
|
252
|
-
)
|
|
267
|
+
).then((r) => r.data)
|
|
253
268
|
},
|
|
254
269
|
// ==================
|
|
255
270
|
// Location Safety
|
|
@@ -258,7 +273,7 @@ function createSaferCityClient(options) {
|
|
|
258
273
|
/**
|
|
259
274
|
* Check location safety
|
|
260
275
|
*/
|
|
261
|
-
check: (body) => baseClient.post("/v1/locations/safety-check", body)
|
|
276
|
+
check: (body) => baseClient.post("/v1/locations/safety-check", body).then((r) => r.data)
|
|
262
277
|
},
|
|
263
278
|
// ==================
|
|
264
279
|
// Banner
|
|
@@ -267,7 +282,7 @@ function createSaferCityClient(options) {
|
|
|
267
282
|
/**
|
|
268
283
|
* Get crime banner data for a location
|
|
269
284
|
*/
|
|
270
|
-
get: (body) => baseClient.post("/v1/banner", body)
|
|
285
|
+
get: (body) => baseClient.post("/v1/banner", body).then((r) => r.data)
|
|
271
286
|
},
|
|
272
287
|
// ==================
|
|
273
288
|
// Crimes
|
|
@@ -276,19 +291,19 @@ function createSaferCityClient(options) {
|
|
|
276
291
|
/**
|
|
277
292
|
* List crimes
|
|
278
293
|
*/
|
|
279
|
-
list: (query) => baseClient.get("/v1/crimes/list", { query }),
|
|
294
|
+
list: (query) => baseClient.get("/v1/crimes/list", { query }).then((r) => r.data),
|
|
280
295
|
/**
|
|
281
296
|
* Get crime categories
|
|
282
297
|
*/
|
|
283
|
-
categories: () => baseClient.get("/v1/crime-categories"),
|
|
298
|
+
categories: () => baseClient.get("/v1/crime-categories").then((r) => r.data),
|
|
284
299
|
/**
|
|
285
300
|
* Get crime types
|
|
286
301
|
*/
|
|
287
|
-
types: () => baseClient.get("/v1/crime-types"),
|
|
302
|
+
types: () => baseClient.get("/v1/crime-types").then((r) => r.data),
|
|
288
303
|
/**
|
|
289
304
|
* Get crime categories with their types
|
|
290
305
|
*/
|
|
291
|
-
categoriesWithTypes: () => baseClient.get("/v1/crime-categories/withTypes")
|
|
306
|
+
categoriesWithTypes: () => baseClient.get("/v1/crime-categories/withTypes").then((r) => r.data)
|
|
292
307
|
}
|
|
293
308
|
};
|
|
294
309
|
}
|
|
@@ -349,7 +364,7 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
349
364
|
*/
|
|
350
365
|
get health() {
|
|
351
366
|
return {
|
|
352
|
-
check: () => this.get("/health")
|
|
367
|
+
check: () => this.get("/health").then((r) => r.data)
|
|
353
368
|
};
|
|
354
369
|
}
|
|
355
370
|
// ==================
|
|
@@ -363,11 +378,11 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
363
378
|
/**
|
|
364
379
|
* Get current authentication context
|
|
365
380
|
*/
|
|
366
|
-
whoami: () => this.get("/auth/whoami"),
|
|
381
|
+
whoami: () => this.get("/auth/whoami").then((r) => r.data),
|
|
367
382
|
/**
|
|
368
383
|
* Check if authenticated (optional auth)
|
|
369
384
|
*/
|
|
370
|
-
check: () => this.get("/auth/optional")
|
|
385
|
+
check: () => this.get("/auth/optional").then((r) => r.data)
|
|
371
386
|
};
|
|
372
387
|
}
|
|
373
388
|
// ==================
|
|
@@ -381,19 +396,19 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
381
396
|
/**
|
|
382
397
|
* Get access token
|
|
383
398
|
*/
|
|
384
|
-
token: (body) => this.post("/v1/oauth/token", body),
|
|
399
|
+
token: (body) => this.post("/v1/oauth/token", body).then((r) => r.data),
|
|
385
400
|
/**
|
|
386
401
|
* Refresh access token
|
|
387
402
|
*/
|
|
388
|
-
refresh: (body) => this.post("/v1/oauth/refresh", body),
|
|
403
|
+
refresh: (body) => this.post("/v1/oauth/refresh", body).then((r) => r.data),
|
|
389
404
|
/**
|
|
390
405
|
* Introspect token
|
|
391
406
|
*/
|
|
392
|
-
introspect: (body) => this.post("/v1/oauth/introspect", body),
|
|
407
|
+
introspect: (body) => this.post("/v1/oauth/introspect", body).then((r) => r.data),
|
|
393
408
|
/**
|
|
394
409
|
* Revoke token
|
|
395
410
|
*/
|
|
396
|
-
revoke: (body) => this.post("/v1/oauth/revoke", body)
|
|
411
|
+
revoke: (body) => this.post("/v1/oauth/revoke", body).then((r) => r.data)
|
|
397
412
|
};
|
|
398
413
|
}
|
|
399
414
|
// ==================
|
|
@@ -407,11 +422,11 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
407
422
|
/**
|
|
408
423
|
* Create a new tenant
|
|
409
424
|
*/
|
|
410
|
-
create: (body) => this.post("/v1/tenants", body),
|
|
425
|
+
create: (body) => this.post("/v1/tenants", body).then((r) => r.data),
|
|
411
426
|
/**
|
|
412
427
|
* List tenants (admin)
|
|
413
428
|
*/
|
|
414
|
-
list: (query) => this.get("/v1/tenants", { query })
|
|
429
|
+
list: (query) => this.get("/v1/tenants", { query }).then((r) => r.data)
|
|
415
430
|
};
|
|
416
431
|
}
|
|
417
432
|
// ==================
|
|
@@ -425,15 +440,15 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
425
440
|
/**
|
|
426
441
|
* Exchange setup token for credentials
|
|
427
442
|
*/
|
|
428
|
-
setup: (body) => this.post("/v1/credentials", body),
|
|
443
|
+
setup: (body) => this.post("/v1/credentials", body).then((r) => r.data),
|
|
429
444
|
/**
|
|
430
445
|
* List credentials
|
|
431
446
|
*/
|
|
432
|
-
list: () => this.get("/v1/credentials"),
|
|
447
|
+
list: () => this.get("/v1/credentials").then((r) => r.data),
|
|
433
448
|
/**
|
|
434
449
|
* Revoke credential
|
|
435
450
|
*/
|
|
436
|
-
revoke: (credentialId) => this.delete(`/v1/credentials/${credentialId}`)
|
|
451
|
+
revoke: (credentialId) => this.delete(`/v1/credentials/${credentialId}`).then((r) => r.data)
|
|
437
452
|
};
|
|
438
453
|
}
|
|
439
454
|
// ==================
|
|
@@ -447,27 +462,27 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
447
462
|
/**
|
|
448
463
|
* Create user
|
|
449
464
|
*/
|
|
450
|
-
create: (body) => this.post("/v1/users", body),
|
|
465
|
+
create: (body) => this.post("/v1/users", body).then((r) => r.data),
|
|
451
466
|
/**
|
|
452
467
|
* List users
|
|
453
468
|
*/
|
|
454
|
-
list: (query) => this.get("/v1/users", { query }),
|
|
469
|
+
list: (query) => this.get("/v1/users", { query }).then((r) => r.data),
|
|
455
470
|
/**
|
|
456
471
|
* Get user by ID
|
|
457
472
|
*/
|
|
458
|
-
get: (userId) => this.get(`/v1/users/${userId}`),
|
|
473
|
+
get: (userId) => this.get(`/v1/users/${userId}`).then((r) => r.data),
|
|
459
474
|
/**
|
|
460
475
|
* Update user
|
|
461
476
|
*/
|
|
462
|
-
update: (userId, body) => this.put(`/v1/users/${userId}`, body),
|
|
477
|
+
update: (userId, body) => this.put(`/v1/users/${userId}`, body).then((r) => r.data),
|
|
463
478
|
/**
|
|
464
479
|
* Update user status
|
|
465
480
|
*/
|
|
466
|
-
updateStatus: (userId, body) => this.patch(`/v1/users/${userId}/status`, body),
|
|
481
|
+
updateStatus: (userId, body) => this.patch(`/v1/users/${userId}/status`, body).then((r) => r.data),
|
|
467
482
|
/**
|
|
468
483
|
* Delete user
|
|
469
484
|
*/
|
|
470
|
-
delete: (userId) => this.delete(`/v1/users/${userId}`)
|
|
485
|
+
delete: (userId) => this.delete(`/v1/users/${userId}`).then((r) => r.data)
|
|
471
486
|
};
|
|
472
487
|
}
|
|
473
488
|
// ==================
|
|
@@ -481,27 +496,27 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
481
496
|
/**
|
|
482
497
|
* Create panic
|
|
483
498
|
*/
|
|
484
|
-
create: (body) => this.post("/v1/panic", body),
|
|
499
|
+
create: (body) => this.post("/v1/panic", body).then((r) => r.data),
|
|
485
500
|
/**
|
|
486
501
|
* Get panic by ID
|
|
487
502
|
*/
|
|
488
|
-
get: (panicId, query) => this.get(`/v1/panic/${panicId}`, { query }),
|
|
503
|
+
get: (panicId, query) => this.get(`/v1/panic/${panicId}`, { query }).then((r) => r.data),
|
|
489
504
|
/**
|
|
490
505
|
* List panics
|
|
491
506
|
*/
|
|
492
|
-
list: (query) => this.get("/v1/panic", { query }),
|
|
507
|
+
list: (query) => this.get("/v1/panic", { query }).then((r) => r.data),
|
|
493
508
|
/**
|
|
494
509
|
* Update panic location
|
|
495
510
|
*/
|
|
496
|
-
updateLocation: (panicId, body) => this.put(`/v1/panic/${panicId}/location`, body),
|
|
511
|
+
updateLocation: (panicId, body) => this.put(`/v1/panic/${panicId}/location`, body).then((r) => r.data),
|
|
497
512
|
/**
|
|
498
513
|
* Cancel panic
|
|
499
514
|
*/
|
|
500
|
-
cancel: (panicId, body) => this.put(`/v1/panic/${panicId}/cancel`, body),
|
|
515
|
+
cancel: (panicId, body) => this.put(`/v1/panic/${panicId}/cancel`, body).then((r) => r.data),
|
|
501
516
|
/**
|
|
502
517
|
* Get available panic types for a user
|
|
503
518
|
*/
|
|
504
|
-
types: (userId) => this.get(`/v1/panic/types/${userId}`)
|
|
519
|
+
types: (userId) => this.get(`/v1/panic/types/${userId}`).then((r) => r.data)
|
|
505
520
|
};
|
|
506
521
|
}
|
|
507
522
|
// ==================
|
|
@@ -515,23 +530,23 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
515
530
|
/**
|
|
516
531
|
* List subscription types
|
|
517
532
|
*/
|
|
518
|
-
listTypes: () => this.get("/v1/subscriptions/types"),
|
|
533
|
+
listTypes: () => this.get("/v1/subscriptions/types").then((r) => r.data),
|
|
519
534
|
/**
|
|
520
535
|
* Create subscription
|
|
521
536
|
*/
|
|
522
|
-
create: (body) => this.post("/v1/subscriptions", body),
|
|
537
|
+
create: (body) => this.post("/v1/subscriptions", body).then((r) => r.data),
|
|
523
538
|
/**
|
|
524
539
|
* List subscriptions
|
|
525
540
|
*/
|
|
526
|
-
list: (query) => this.get("/v1/subscriptions", { query }),
|
|
541
|
+
list: (query) => this.get("/v1/subscriptions", { query }).then((r) => r.data),
|
|
527
542
|
/**
|
|
528
543
|
* Get subscription stats
|
|
529
544
|
*/
|
|
530
|
-
stats: () => this.get("/v1/subscriptions/stats"),
|
|
545
|
+
stats: () => this.get("/v1/subscriptions/stats").then((r) => r.data),
|
|
531
546
|
/**
|
|
532
547
|
* Subscribe a user to a subscription type
|
|
533
548
|
*/
|
|
534
|
-
subscribeUser: (body) => this.post("/v1/subscriptions/subscribe-user", body)
|
|
549
|
+
subscribeUser: (body) => this.post("/v1/subscriptions/subscribe-user", body).then((r) => r.data)
|
|
535
550
|
};
|
|
536
551
|
}
|
|
537
552
|
// ==================
|
|
@@ -545,28 +560,28 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
545
560
|
/**
|
|
546
561
|
* Create subscriber
|
|
547
562
|
*/
|
|
548
|
-
createSubscriber: (body) => this.post("/v1/notifications/subscribers", body),
|
|
563
|
+
createSubscriber: (body) => this.post("/v1/notifications/subscribers", body).then((r) => r.data),
|
|
549
564
|
/**
|
|
550
565
|
* Trigger notification
|
|
551
566
|
*/
|
|
552
|
-
trigger: (body) => this.post("/v1/notifications/trigger", body),
|
|
567
|
+
trigger: (body) => this.post("/v1/notifications/trigger", body).then((r) => r.data),
|
|
553
568
|
/**
|
|
554
569
|
* Bulk trigger notifications
|
|
555
570
|
*/
|
|
556
|
-
bulkTrigger: (body) => this.post("/v1/notifications/bulk-trigger", body),
|
|
571
|
+
bulkTrigger: (body) => this.post("/v1/notifications/bulk-trigger", body).then((r) => r.data),
|
|
557
572
|
/**
|
|
558
573
|
* Get user preferences
|
|
559
574
|
*/
|
|
560
575
|
getPreferences: (userId) => this.get(
|
|
561
576
|
`/v1/notifications/preferences/${userId}`
|
|
562
|
-
),
|
|
577
|
+
).then((r) => r.data),
|
|
563
578
|
/**
|
|
564
579
|
* Update user preferences
|
|
565
580
|
*/
|
|
566
581
|
updatePreferences: (userId, body) => this.put(
|
|
567
582
|
`/v1/notifications/preferences/${userId}`,
|
|
568
583
|
body
|
|
569
|
-
)
|
|
584
|
+
).then((r) => r.data)
|
|
570
585
|
};
|
|
571
586
|
}
|
|
572
587
|
// ==================
|
|
@@ -580,33 +595,33 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
580
595
|
/**
|
|
581
596
|
* Create panic information profile
|
|
582
597
|
*/
|
|
583
|
-
create: (body) => this.post("/v1/panic-information", body),
|
|
598
|
+
create: (body) => this.post("/v1/panic-information", body).then((r) => r.data),
|
|
584
599
|
/**
|
|
585
600
|
* List panic information records
|
|
586
601
|
*/
|
|
587
|
-
list: (query) => this.get("/v1/panic-information", { query }),
|
|
602
|
+
list: (query) => this.get("/v1/panic-information", { query }).then((r) => r.data),
|
|
588
603
|
/**
|
|
589
604
|
* Get panic information by ID
|
|
590
605
|
*/
|
|
591
|
-
get: (id) => this.get(`/v1/panic-information/${id}`),
|
|
606
|
+
get: (id) => this.get(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
592
607
|
/**
|
|
593
608
|
* Get panic information by user ID
|
|
594
609
|
*/
|
|
595
|
-
getByUser: (userId) => this.get(`/v1/panic-information/user/${userId}`),
|
|
610
|
+
getByUser: (userId) => this.get(`/v1/panic-information/user/${userId}`).then((r) => r.data),
|
|
596
611
|
/**
|
|
597
612
|
* Update panic information
|
|
598
613
|
*/
|
|
599
|
-
update: (id, body) => this.put(`/v1/panic-information/${id}`, body),
|
|
614
|
+
update: (id, body) => this.put(`/v1/panic-information/${id}`, body).then((r) => r.data),
|
|
600
615
|
/**
|
|
601
616
|
* Delete panic information
|
|
602
617
|
*/
|
|
603
|
-
delete: (id) => this.delete(`/v1/panic-information/${id}`),
|
|
618
|
+
delete: (id) => this.delete(`/v1/panic-information/${id}`).then((r) => r.data),
|
|
604
619
|
/**
|
|
605
620
|
* Validate user eligibility for panic services
|
|
606
621
|
*/
|
|
607
622
|
validateEligibility: (userId) => this.get(
|
|
608
623
|
`/v1/panic-information/validation/${userId}`
|
|
609
|
-
)
|
|
624
|
+
).then((r) => r.data)
|
|
610
625
|
};
|
|
611
626
|
}
|
|
612
627
|
// ==================
|
|
@@ -620,7 +635,7 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
620
635
|
/**
|
|
621
636
|
* Check location safety
|
|
622
637
|
*/
|
|
623
|
-
check: (body) => this.post("/v1/locations/safety-check", body)
|
|
638
|
+
check: (body) => this.post("/v1/locations/safety-check", body).then((r) => r.data)
|
|
624
639
|
};
|
|
625
640
|
}
|
|
626
641
|
// ==================
|
|
@@ -634,7 +649,7 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
634
649
|
/**
|
|
635
650
|
* Get crime banner data for a location
|
|
636
651
|
*/
|
|
637
|
-
get: (body) => this.post("/v1/banner", body)
|
|
652
|
+
get: (body) => this.post("/v1/banner", body).then((r) => r.data)
|
|
638
653
|
};
|
|
639
654
|
}
|
|
640
655
|
// ==================
|
|
@@ -648,19 +663,19 @@ var ServerClient = class extends sdkCore.BaseClient {
|
|
|
648
663
|
/**
|
|
649
664
|
* List crimes
|
|
650
665
|
*/
|
|
651
|
-
list: (query) => this.get("/v1/crimes/list", { query }),
|
|
666
|
+
list: (query) => this.get("/v1/crimes/list", { query }).then((r) => r.data),
|
|
652
667
|
/**
|
|
653
668
|
* Get crime categories
|
|
654
669
|
*/
|
|
655
|
-
categories: () => this.get("/v1/crime-categories"),
|
|
670
|
+
categories: () => this.get("/v1/crime-categories").then((r) => r.data),
|
|
656
671
|
/**
|
|
657
672
|
* Get crime types
|
|
658
673
|
*/
|
|
659
|
-
types: () => this.get("/v1/crime-types"),
|
|
674
|
+
types: () => this.get("/v1/crime-types").then((r) => r.data),
|
|
660
675
|
/**
|
|
661
676
|
* Get crime categories with their types
|
|
662
677
|
*/
|
|
663
|
-
categoriesWithTypes: () => this.get("/v1/crime-categories/withTypes")
|
|
678
|
+
categoriesWithTypes: () => this.get("/v1/crime-categories/withTypes").then((r) => r.data)
|
|
664
679
|
};
|
|
665
680
|
}
|
|
666
681
|
};
|