mezon-sdk 2.7.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/api.gen.ts ADDED
@@ -0,0 +1,783 @@
1
+ // tslint:disable
2
+ /* Code generated by openapi-gen/main.go. DO NOT EDIT. */
3
+
4
+ import { buildFetchOptions } from './utils';
5
+ import { encode } from 'js-base64';
6
+
7
+ /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
8
+ export interface ApiAuthenticateLogoutRequest {
9
+ //Refresh token to invalidate.
10
+ refresh_token?: string;
11
+ //Session token to log out.
12
+ token?: string;
13
+ }
14
+
15
+ /** Authenticate against the server with a refresh token. */
16
+ export interface ApiAuthenticateRefreshRequest {
17
+ //Refresh token.
18
+ refresh_token?: string;
19
+ }
20
+
21
+ /** */
22
+ export interface ApiAuthenticateRequest {
23
+ //Optional custom properties to update with this call. If not set, properties are left as they are on the server.
24
+ custom?: Record<string, string>;
25
+ //Optional default properties to update with this call. If not set, properties are left as they are on the server.
26
+ default?: Record<string, string>;
27
+ //Identity ID. Must be between eight and 128 characters (inclusive). Must be an alphanumeric string with only underscores and hyphens allowed.
28
+ id?: string;
29
+ }
30
+
31
+ /** A single event. Usually, but not necessarily, part of a batch. */
32
+ export interface ApiEvent {
33
+ //Optional event ID assigned by the client, used to de-duplicate in retransmission scenarios. If not supplied the server will assign a randomly generated unique event identifier.
34
+ id?: string;
35
+ //Event metadata, if any.
36
+ metadata?: Record<string, string>;
37
+ //Event name.
38
+ name?: string;
39
+ //The time when the event was triggered on the producer side.
40
+ timestamp?: string;
41
+ //Optional value.
42
+ value?: string;
43
+ }
44
+
45
+ /** */
46
+ export interface ApiEventRequest {
47
+ //Some number of events produced by a client.
48
+ events?: Array<ApiEvent>;
49
+ }
50
+
51
+ /** An experiment that this user is partaking. */
52
+ export interface ApiExperiment {
53
+ //
54
+ name?: string;
55
+ //Value associated with this Experiment.
56
+ value?: string;
57
+ }
58
+
59
+ /** All experiments that this identity is involved with. */
60
+ export interface ApiExperimentList {
61
+ //All experiments for this identity.
62
+ experiments?: Array<ApiExperiment>;
63
+ }
64
+
65
+ /** Feature flag available to the identity. */
66
+ export interface ApiFlag {
67
+ //Whether the value for this flag has conditionally changed from the default state.
68
+ condition_changed?: boolean;
69
+ //
70
+ name?: string;
71
+ //Value associated with this flag.
72
+ value?: string;
73
+ }
74
+
75
+ /** */
76
+ export interface ApiFlagList {
77
+ //
78
+ flags?: Array<ApiFlag>;
79
+ }
80
+
81
+ /** A response containing all the messages for an identity. */
82
+ export interface ApiGetMessageListResponse {
83
+ //Cacheable cursor to list newer messages. Durable and designed to be stored, unlike next/prev cursors.
84
+ cacheable_cursor?: string;
85
+ //The list of messages.
86
+ messages?: Array<ApiMessage>;
87
+ //The cursor to send when retrieving the next page, if any.
88
+ next_cursor?: string;
89
+ //The cursor to send when retrieving the previous page, if any.
90
+ prev_cursor?: string;
91
+ }
92
+
93
+ /** Enrich/replace the current session with a new ID. */
94
+ export interface ApiIdentifyRequest {
95
+ //Optional custom properties to update with this call. If not set, properties are left as they are on the server.
96
+ custom?: Record<string, string>;
97
+ //Optional default properties to update with this call. If not set, properties are left as they are on the server.
98
+ default?: Record<string, string>;
99
+ //Identity ID to enrich the current session and return a new session. Old session will no longer be usable.
100
+ id?: string;
101
+ }
102
+
103
+ /** A single live event. */
104
+ export interface ApiLiveEvent {
105
+ //End time of current event run.
106
+ active_end_time_sec?: string;
107
+ //Start time of current event run.
108
+ active_start_time_sec?: string;
109
+ //Description.
110
+ description?: string;
111
+ //The live event identifier.
112
+ id?: string;
113
+ //Name.
114
+ name?: string;
115
+ //Event value.
116
+ value?: string;
117
+ }
118
+
119
+ /** List of Live events. */
120
+ export interface ApiLiveEventList {
121
+ //Live events.
122
+ live_events?: Array<ApiLiveEvent>;
123
+ }
124
+
125
+ /** A scheduled message. */
126
+ export interface ApiMessage {
127
+ //The time the message was consumed by the identity.
128
+ consume_time?: string;
129
+ //The time the message was created.
130
+ create_time?: string;
131
+ //A key-value pairs of metadata.
132
+ metadata?: Record<string, string>;
133
+ //The time the message was read by the client.
134
+ read_time?: string;
135
+ //The identifier of the schedule.
136
+ schedule_id?: string;
137
+ //The send time for the message.
138
+ send_time?: string;
139
+ //The message's text.
140
+ text?: string;
141
+ //The time the message was updated.
142
+ update_time?: string;
143
+ }
144
+
145
+ /** Properties associated with an identity. */
146
+ export interface ApiProperties {
147
+ //Event computed properties.
148
+ computed?: Record<string, string>;
149
+ //Event custom properties.
150
+ custom?: Record<string, string>;
151
+ //Event default properties.
152
+ default?: Record<string, string>;
153
+ }
154
+
155
+ /** A session. */
156
+ export interface ApiSession {
157
+ //Properties associated with this identity.
158
+ properties?: ApiProperties;
159
+ //Refresh token.
160
+ refresh_token?: string;
161
+ //Token credential.
162
+ token?: string;
163
+ }
164
+
165
+ /** The request to update the status of a message. */
166
+ export interface ApiUpdateMessageRequest {
167
+ //The time the message was consumed by the identity.
168
+ consume_time?: string;
169
+ //The identifier of the messages.
170
+ id?: string;
171
+ //The time the message was read at the client.
172
+ read_time?: string;
173
+ }
174
+
175
+ /** Update Properties associated with this identity. */
176
+ export interface ApiUpdatePropertiesRequest {
177
+ //Event custom properties.
178
+ custom?: Record<string, string>;
179
+ //Event default properties.
180
+ default?: Record<string, string>;
181
+ //Informs the server to recompute the audience membership of the identity.
182
+ recompute?: boolean;
183
+ }
184
+
185
+ /** */
186
+ export interface ProtobufAny {
187
+ //
188
+ type_url?: string;
189
+ //
190
+ value?: string;
191
+ }
192
+
193
+ /** */
194
+ export interface RpcStatus {
195
+ //
196
+ code?: number;
197
+ //
198
+ details?: Array<ProtobufAny>;
199
+ //
200
+ message?: string;
201
+ }
202
+
203
+ export class SatoriApi {
204
+
205
+ constructor(readonly apiKey: string, readonly basePath: string, readonly timeoutMs: number) {}
206
+
207
+ /** A healthcheck which load balancers can use to check the service. */
208
+ satoriHealthcheck(bearerToken: string,
209
+ options: any = {}): Promise<any> {
210
+
211
+ const urlPath = "/healthcheck";
212
+ const queryParams = new Map<string, any>();
213
+
214
+ let bodyJson : string = "";
215
+
216
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
217
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
218
+ if (bearerToken) {
219
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
220
+ }
221
+
222
+ return Promise.race([
223
+ fetch(fullUrl, fetchOptions).then((response) => {
224
+ if (response.status == 204) {
225
+ return response;
226
+ } else if (response.status >= 200 && response.status < 300) {
227
+ return response.json();
228
+ } else {
229
+ throw response;
230
+ }
231
+ }),
232
+ new Promise((_, reject) =>
233
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
234
+ ),
235
+ ]);
236
+ }
237
+
238
+ /** A readycheck which load balancers can use to check the service. */
239
+ satoriReadycheck(bearerToken: string,
240
+ options: any = {}): Promise<any> {
241
+
242
+ const urlPath = "/readycheck";
243
+ const queryParams = new Map<string, any>();
244
+
245
+ let bodyJson : string = "";
246
+
247
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
248
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
249
+ if (bearerToken) {
250
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
251
+ }
252
+
253
+ return Promise.race([
254
+ fetch(fullUrl, fetchOptions).then((response) => {
255
+ if (response.status == 204) {
256
+ return response;
257
+ } else if (response.status >= 200 && response.status < 300) {
258
+ return response.json();
259
+ } else {
260
+ throw response;
261
+ }
262
+ }),
263
+ new Promise((_, reject) =>
264
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
265
+ ),
266
+ ]);
267
+ }
268
+
269
+ /** Authenticate against the server. */
270
+ satoriAuthenticate(basicAuthUsername: string,
271
+ basicAuthPassword: string,
272
+ body:ApiAuthenticateRequest,
273
+ options: any = {}): Promise<ApiSession> {
274
+
275
+ if (body === null || body === undefined) {
276
+ throw new Error("'body' is a required parameter but is null or undefined.");
277
+ }
278
+ const urlPath = "/v1/authenticate";
279
+ const queryParams = new Map<string, any>();
280
+
281
+ let bodyJson : string = "";
282
+ bodyJson = JSON.stringify(body || {});
283
+
284
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
285
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
286
+ if (basicAuthUsername) {
287
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
288
+ }
289
+
290
+ return Promise.race([
291
+ fetch(fullUrl, fetchOptions).then((response) => {
292
+ if (response.status == 204) {
293
+ return response;
294
+ } else if (response.status >= 200 && response.status < 300) {
295
+ return response.json();
296
+ } else {
297
+ throw response;
298
+ }
299
+ }),
300
+ new Promise((_, reject) =>
301
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
302
+ ),
303
+ ]);
304
+ }
305
+
306
+ /** Log out a session, invalidate a refresh token, or log out all sessions/refresh tokens for a user. */
307
+ satoriAuthenticateLogout(bearerToken: string,
308
+ body:ApiAuthenticateLogoutRequest,
309
+ options: any = {}): Promise<any> {
310
+
311
+ if (body === null || body === undefined) {
312
+ throw new Error("'body' is a required parameter but is null or undefined.");
313
+ }
314
+ const urlPath = "/v1/authenticate/logout";
315
+ const queryParams = new Map<string, any>();
316
+
317
+ let bodyJson : string = "";
318
+ bodyJson = JSON.stringify(body || {});
319
+
320
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
321
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
322
+ if (bearerToken) {
323
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
324
+ }
325
+
326
+ return Promise.race([
327
+ fetch(fullUrl, fetchOptions).then((response) => {
328
+ if (response.status == 204) {
329
+ return response;
330
+ } else if (response.status >= 200 && response.status < 300) {
331
+ return response.json();
332
+ } else {
333
+ throw response;
334
+ }
335
+ }),
336
+ new Promise((_, reject) =>
337
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
338
+ ),
339
+ ]);
340
+ }
341
+
342
+ /** Refresh a user's session using a refresh token retrieved from a previous authentication request. */
343
+ satoriAuthenticateRefresh(basicAuthUsername: string,
344
+ basicAuthPassword: string,
345
+ body:ApiAuthenticateRefreshRequest,
346
+ options: any = {}): Promise<ApiSession> {
347
+
348
+ if (body === null || body === undefined) {
349
+ throw new Error("'body' is a required parameter but is null or undefined.");
350
+ }
351
+ const urlPath = "/v1/authenticate/refresh";
352
+ const queryParams = new Map<string, any>();
353
+
354
+ let bodyJson : string = "";
355
+ bodyJson = JSON.stringify(body || {});
356
+
357
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
358
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
359
+ if (basicAuthUsername) {
360
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
361
+ }
362
+
363
+ return Promise.race([
364
+ fetch(fullUrl, fetchOptions).then((response) => {
365
+ if (response.status == 204) {
366
+ return response;
367
+ } else if (response.status >= 200 && response.status < 300) {
368
+ return response.json();
369
+ } else {
370
+ throw response;
371
+ }
372
+ }),
373
+ new Promise((_, reject) =>
374
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
375
+ ),
376
+ ]);
377
+ }
378
+
379
+ /** Publish an event for this session. */
380
+ satoriEvent(bearerToken: string,
381
+ body:ApiEventRequest,
382
+ options: any = {}): Promise<any> {
383
+
384
+ if (body === null || body === undefined) {
385
+ throw new Error("'body' is a required parameter but is null or undefined.");
386
+ }
387
+ const urlPath = "/v1/event";
388
+ const queryParams = new Map<string, any>();
389
+
390
+ let bodyJson : string = "";
391
+ bodyJson = JSON.stringify(body || {});
392
+
393
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
394
+ const fetchOptions = buildFetchOptions("POST", options, bodyJson);
395
+ if (bearerToken) {
396
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
397
+ }
398
+
399
+ return Promise.race([
400
+ fetch(fullUrl, fetchOptions).then((response) => {
401
+ if (response.status == 204) {
402
+ return response;
403
+ } else if (response.status >= 200 && response.status < 300) {
404
+ return response.json();
405
+ } else {
406
+ throw response;
407
+ }
408
+ }),
409
+ new Promise((_, reject) =>
410
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
411
+ ),
412
+ ]);
413
+ }
414
+
415
+ /** Get or list all available experiments for this identity. */
416
+ satoriGetExperiments(bearerToken: string,
417
+ names?:Array<string>,
418
+ options: any = {}): Promise<ApiExperimentList> {
419
+
420
+ const urlPath = "/v1/experiment";
421
+ const queryParams = new Map<string, any>();
422
+ queryParams.set("names", names);
423
+
424
+ let bodyJson : string = "";
425
+
426
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
427
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
428
+ if (bearerToken) {
429
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
430
+ }
431
+
432
+ return Promise.race([
433
+ fetch(fullUrl, fetchOptions).then((response) => {
434
+ if (response.status == 204) {
435
+ return response;
436
+ } else if (response.status >= 200 && response.status < 300) {
437
+ return response.json();
438
+ } else {
439
+ throw response;
440
+ }
441
+ }),
442
+ new Promise((_, reject) =>
443
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
444
+ ),
445
+ ]);
446
+ }
447
+
448
+ /** List all available flags for this identity. */
449
+ satoriGetFlags(bearerToken: string,basicAuthUsername: string,
450
+ basicAuthPassword: string,
451
+ names?:Array<string>,
452
+ options: any = {}): Promise<ApiFlagList> {
453
+
454
+ const urlPath = "/v1/flag";
455
+ const queryParams = new Map<string, any>();
456
+ queryParams.set("names", names);
457
+
458
+ let bodyJson : string = "";
459
+
460
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
461
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
462
+ if (bearerToken) {
463
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
464
+ }
465
+ if (basicAuthUsername) {
466
+ fetchOptions.headers["Authorization"] = "Basic " + encode(basicAuthUsername + ":" + basicAuthPassword);
467
+ }
468
+
469
+ return Promise.race([
470
+ fetch(fullUrl, fetchOptions).then((response) => {
471
+ if (response.status == 204) {
472
+ return response;
473
+ } else if (response.status >= 200 && response.status < 300) {
474
+ return response.json();
475
+ } else {
476
+ throw response;
477
+ }
478
+ }),
479
+ new Promise((_, reject) =>
480
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
481
+ ),
482
+ ]);
483
+ }
484
+
485
+ /** Enrich/replace the current session with new identifier. */
486
+ satoriIdentify(bearerToken: string,
487
+ body:ApiIdentifyRequest,
488
+ options: any = {}): Promise<ApiSession> {
489
+
490
+ if (body === null || body === undefined) {
491
+ throw new Error("'body' is a required parameter but is null or undefined.");
492
+ }
493
+ const urlPath = "/v1/identify";
494
+ const queryParams = new Map<string, any>();
495
+
496
+ let bodyJson : string = "";
497
+ bodyJson = JSON.stringify(body || {});
498
+
499
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
500
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
501
+ if (bearerToken) {
502
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
503
+ }
504
+
505
+ return Promise.race([
506
+ fetch(fullUrl, fetchOptions).then((response) => {
507
+ if (response.status == 204) {
508
+ return response;
509
+ } else if (response.status >= 200 && response.status < 300) {
510
+ return response.json();
511
+ } else {
512
+ throw response;
513
+ }
514
+ }),
515
+ new Promise((_, reject) =>
516
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
517
+ ),
518
+ ]);
519
+ }
520
+
521
+ /** Delete the caller's identity and associated data. */
522
+ satoriDeleteIdentity(bearerToken: string,
523
+ options: any = {}): Promise<any> {
524
+
525
+ const urlPath = "/v1/identity";
526
+ const queryParams = new Map<string, any>();
527
+
528
+ let bodyJson : string = "";
529
+
530
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
531
+ const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
532
+ if (bearerToken) {
533
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
534
+ }
535
+
536
+ return Promise.race([
537
+ fetch(fullUrl, fetchOptions).then((response) => {
538
+ if (response.status == 204) {
539
+ return response;
540
+ } else if (response.status >= 200 && response.status < 300) {
541
+ return response.json();
542
+ } else {
543
+ throw response;
544
+ }
545
+ }),
546
+ new Promise((_, reject) =>
547
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
548
+ ),
549
+ ]);
550
+ }
551
+
552
+ /** List available live events. */
553
+ satoriGetLiveEvents(bearerToken: string,
554
+ names?:Array<string>,
555
+ options: any = {}): Promise<ApiLiveEventList> {
556
+
557
+ const urlPath = "/v1/live-event";
558
+ const queryParams = new Map<string, any>();
559
+ queryParams.set("names", names);
560
+
561
+ let bodyJson : string = "";
562
+
563
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
564
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
565
+ if (bearerToken) {
566
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
567
+ }
568
+
569
+ return Promise.race([
570
+ fetch(fullUrl, fetchOptions).then((response) => {
571
+ if (response.status == 204) {
572
+ return response;
573
+ } else if (response.status >= 200 && response.status < 300) {
574
+ return response.json();
575
+ } else {
576
+ throw response;
577
+ }
578
+ }),
579
+ new Promise((_, reject) =>
580
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
581
+ ),
582
+ ]);
583
+ }
584
+
585
+ /** Get the list of messages for the identity. */
586
+ satoriGetMessageList(bearerToken: string,
587
+ limit?:number,
588
+ forward?:boolean,
589
+ cursor?:string,
590
+ options: any = {}): Promise<ApiGetMessageListResponse> {
591
+
592
+ const urlPath = "/v1/message";
593
+ const queryParams = new Map<string, any>();
594
+ queryParams.set("limit", limit);
595
+ queryParams.set("forward", forward);
596
+ queryParams.set("cursor", cursor);
597
+
598
+ let bodyJson : string = "";
599
+
600
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
601
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
602
+ if (bearerToken) {
603
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
604
+ }
605
+
606
+ return Promise.race([
607
+ fetch(fullUrl, fetchOptions).then((response) => {
608
+ if (response.status == 204) {
609
+ return response;
610
+ } else if (response.status >= 200 && response.status < 300) {
611
+ return response.json();
612
+ } else {
613
+ throw response;
614
+ }
615
+ }),
616
+ new Promise((_, reject) =>
617
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
618
+ ),
619
+ ]);
620
+ }
621
+
622
+ /** Deletes a message for an identity. */
623
+ satoriDeleteMessage(bearerToken: string,
624
+ id:string,
625
+ options: any = {}): Promise<any> {
626
+
627
+ if (id === null || id === undefined) {
628
+ throw new Error("'id' is a required parameter but is null or undefined.");
629
+ }
630
+ const urlPath = "/v1/message/{id}"
631
+ .replace("{id}", encodeURIComponent(String(id)));
632
+ const queryParams = new Map<string, any>();
633
+
634
+ let bodyJson : string = "";
635
+
636
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
637
+ const fetchOptions = buildFetchOptions("DELETE", options, bodyJson);
638
+ if (bearerToken) {
639
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
640
+ }
641
+
642
+ return Promise.race([
643
+ fetch(fullUrl, fetchOptions).then((response) => {
644
+ if (response.status == 204) {
645
+ return response;
646
+ } else if (response.status >= 200 && response.status < 300) {
647
+ return response.json();
648
+ } else {
649
+ throw response;
650
+ }
651
+ }),
652
+ new Promise((_, reject) =>
653
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
654
+ ),
655
+ ]);
656
+ }
657
+
658
+ /** Updates a message for an identity. */
659
+ satoriUpdateMessage(bearerToken: string,
660
+ id:string,
661
+ body:ApiUpdateMessageRequest,
662
+ options: any = {}): Promise<any> {
663
+
664
+ if (id === null || id === undefined) {
665
+ throw new Error("'id' is a required parameter but is null or undefined.");
666
+ }
667
+ if (body === null || body === undefined) {
668
+ throw new Error("'body' is a required parameter but is null or undefined.");
669
+ }
670
+ const urlPath = "/v1/message/{id}"
671
+ .replace("{id}", encodeURIComponent(String(id)));
672
+ const queryParams = new Map<string, any>();
673
+
674
+ let bodyJson : string = "";
675
+ bodyJson = JSON.stringify(body || {});
676
+
677
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
678
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
679
+ if (bearerToken) {
680
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
681
+ }
682
+
683
+ return Promise.race([
684
+ fetch(fullUrl, fetchOptions).then((response) => {
685
+ if (response.status == 204) {
686
+ return response;
687
+ } else if (response.status >= 200 && response.status < 300) {
688
+ return response.json();
689
+ } else {
690
+ throw response;
691
+ }
692
+ }),
693
+ new Promise((_, reject) =>
694
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
695
+ ),
696
+ ]);
697
+ }
698
+
699
+ /** List properties associated with this identity. */
700
+ satoriListProperties(bearerToken: string,
701
+ options: any = {}): Promise<ApiProperties> {
702
+
703
+ const urlPath = "/v1/properties";
704
+ const queryParams = new Map<string, any>();
705
+
706
+ let bodyJson : string = "";
707
+
708
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
709
+ const fetchOptions = buildFetchOptions("GET", options, bodyJson);
710
+ if (bearerToken) {
711
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
712
+ }
713
+
714
+ return Promise.race([
715
+ fetch(fullUrl, fetchOptions).then((response) => {
716
+ if (response.status == 204) {
717
+ return response;
718
+ } else if (response.status >= 200 && response.status < 300) {
719
+ return response.json();
720
+ } else {
721
+ throw response;
722
+ }
723
+ }),
724
+ new Promise((_, reject) =>
725
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
726
+ ),
727
+ ]);
728
+ }
729
+
730
+ /** Update identity properties. */
731
+ satoriUpdateProperties(bearerToken: string,
732
+ body:ApiUpdatePropertiesRequest,
733
+ options: any = {}): Promise<any> {
734
+
735
+ if (body === null || body === undefined) {
736
+ throw new Error("'body' is a required parameter but is null or undefined.");
737
+ }
738
+ const urlPath = "/v1/properties";
739
+ const queryParams = new Map<string, any>();
740
+
741
+ let bodyJson : string = "";
742
+ bodyJson = JSON.stringify(body || {});
743
+
744
+ const fullUrl = this.buildFullUrl(this.basePath, urlPath, queryParams);
745
+ const fetchOptions = buildFetchOptions("PUT", options, bodyJson);
746
+ if (bearerToken) {
747
+ fetchOptions.headers["Authorization"] = "Bearer " + bearerToken;
748
+ }
749
+
750
+ return Promise.race([
751
+ fetch(fullUrl, fetchOptions).then((response) => {
752
+ if (response.status == 204) {
753
+ return response;
754
+ } else if (response.status >= 200 && response.status < 300) {
755
+ return response.json();
756
+ } else {
757
+ throw response;
758
+ }
759
+ }),
760
+ new Promise((_, reject) =>
761
+ setTimeout(reject, this.timeoutMs, "Request timed out.")
762
+ ),
763
+ ]);
764
+ }
765
+
766
+ buildFullUrl(basePath: string, fragment: string, queryParams: Map<string, any>) {
767
+ let fullPath = basePath + fragment + "?";
768
+
769
+ for (let [k, v] of queryParams) {
770
+ if (v instanceof Array) {
771
+ fullPath += v.reduce((prev: any, curr: any) => {
772
+ return prev + encodeURIComponent(k) + "=" + encodeURIComponent(curr) + "&";
773
+ }, "");
774
+ } else {
775
+ if (v != null) {
776
+ fullPath += encodeURIComponent(k) + "=" + encodeURIComponent(v) + "&";
777
+ }
778
+ }
779
+ }
780
+
781
+ return fullPath;
782
+ }
783
+ };