-
Notifications
You must be signed in to change notification settings - Fork 0
/
EzOnRailsHttpClient.ts
692 lines (612 loc) · 25.8 KB
/
EzOnRailsHttpClient.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
import { EzOnRailsHttpUtils } from '../utils/EzOnRailsUtils';
import { RailsFileBlob } from '../../components/ActiveStorageDropzone/ActiveStorageDropzone';
import { EzOnRailsHttpError } from './EzOnRailsHttpError';
/**
* Describes the header information needed to authenticate as user on an EzOnRails application.
*/
interface EzOnRailsAuthHeader {
uid: string;
client: string;
expiry: string;
'token-type': string;
'access-token': string;
}
/**
* Auth information for http requests and responses.
* If a route is protected and needs authentication, this information must be passed to the http
* client to authenticate againsgt the EzOnRails endpoint. If the server changes the authentication
* information, those will be send back to the client. The resulting new auth information will
* be returned by the http client, in addition to the normal result.
*/
export interface EzOnRailsAuthInfo {
uid: string;
client: string;
expiry: string;
tokenType: string;
accessToken: string;
}
/**
* Type for a user registered in an ez-on-rails system.
* Used by the actions to get and update the own user.
*/
export interface EzOnRailsUser {
// The email of the user
email: string;
// An unconfirmed email, if the user has not yet confirmed his email
unconfirmedEmail?: string;
// The optional username of the user
username?: string;
// The users avatar as blob, holding the url and signedId and filename
avatar?: RailsFileBlob | null;
}
/**
* Type for a updating an registered in an ez-on-rails system.
* Used by the actions to get and update the own user.
* The unconfirmedEmail is not needed to be submitted, since this is only used to show the user if he
* has provided any unconfirmed email yet.
*/
export type EzOnRailsUpdateUserParams = Partial<Omit<EzOnRailsUser, 'unconfirmedEmail'>> & {
// The new password, must only be passed if the user wants to change the password
password?: string;
// The confirmed new password, must match password, must only be passed if the user wants to change the password
passwordConfirmation?: string;
};
/**
* Describes the parameters that are needed for signup.
* The interface allows any data to be passed, but requires the parameters to be set that are minimum
* needed by ez-on-rails for signUp. This makes it possible to append any data on the user model that is also saved
* on signUp, but also gets sure that the needed data for registration process is passed.
*/
export interface EzOnRailsSignUpParams {
// The users email
email: string;
// The users password
password: string;
// The password confirmation, this must match the password
passwordConfirmation: string;
// Indicates whether the user accepted the privacy policy. Needs to be true to register.
privacyPolicyAccepted: boolean;
// The optional username, can be anything
username?: string;
// Any additional data if your model has additional data on registration
[key: string]: unknown;
}
/**
* Descibes the parameters needed to sign in.
*/
export interface EzOnRailsSignInParams {
// The email of the user
email: string;
// The users password
password: string;
}
/**
* Describes the parameters needed for the password reset instructions endpoint.
*/
export interface EzOnRailsPasswordResetInstructionsParams {
// The email the instructions are send to
email: string;
}
/**
* Describes the parameters needed for the password reset endpoint.
*/
export interface EzOnRailsPasswordResetParams {
// The password the user wants to set
password: string;
// The password confirmation of the password, must match the password
passwordConfirmation: string;
// The token that was send via email to the user to reset the password
resetPasswordToken: string;
}
/**
* Describes the parameters needed for the endpoint to resend the confirmation instructions.
*/
export interface EzOnRailsConfirmationInstructionsParams {
// The email the instructions are requested for
email: string;
}
/**
* Describes the parameters needed to confirm an account using the confirmation link that was
* send via email.
*/
export interface EzOnRailsConfirmParams {
// The token that was send to the users email
confirmationToken: string;
}
/**
* Changes the specified authInfo object to an AuthHeader object, that can be passed via the
* request to the server.
* If undefined is passsed, the method will returned undefined, too.
*
* @param authInfo
*/
const authInfoToHeader = (authInfo: EzOnRailsAuthInfo | null): EzOnRailsAuthHeader | undefined => {
if (!authInfo) return undefined;
return {
uid: authInfo.uid,
client: authInfo.client,
expiry: authInfo.expiry,
'token-type': authInfo.tokenType,
'access-token': authInfo.accessToken
};
};
/**
* Extracts the authentication information from the specified header and returns
* a resulting EzOnRailsAuthInfo object. If no auth info are provided, undefined will be
* returned.
*
* @param headers
*/
const getAuthInfoFromHeader = (headers: Record<string, string>): EzOnRailsAuthInfo => {
return {
uid: headers['uid'],
client: headers['client'],
expiry: headers['expiry'],
tokenType: headers['token-type'],
accessToken: headers['access-token']
};
};
/**
* Returns the default http header needed for communication to some EzOnRails server instance.
*/
export const defaultHttpHeader = (authInfo: EzOnRailsAuthInfo | null, apiVersion: string) => {
return {
'Content-Type': 'application/json',
Accept: 'application/json',
'api-version': apiVersion,
...authInfoToHeader(authInfo)
};
};
/**
* Describes the response object of the fetchWithThrow function.
* TRes describes the type of the expected response body.
*/
interface FetchWithThrowResponse<TRes> {
// The response headers
headers: Record<string, string>;
// The response body
body: TRes;
}
/**
* Uses the fetch api to execute a http request specified by the given http method, body and headers.
* The difference between normal fetch and this method is, that an exception is thrown if the status
* code is >= 400. The result of the request will be returned.
* This method returns an object having the keys headers and body. Headers is the key value pair object
* of header information from the response. Body is the json content, if given.
*
* @param method
* @param url
* @param body
* @param headers
*/
const fetchWithThrow = async <TRes>(
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',
url: string,
body: unknown,
headers: Record<string, string>
): Promise<FetchWithThrowResponse<TRes>> => {
const response = await fetch(url, {
method: method,
headers: headers,
body: body ? JSON.stringify(body) : null
});
// throw if something went wrong
if (!response.ok) {
throw new EzOnRailsHttpError(await response.text(), response.status);
}
// get header and data and return result
const responseHeaders: Record<string, string> = {};
let responseBody = null;
try {
// build headers
response.headers.forEach((value, key) => {
responseHeaders[key] = value;
});
// build body
responseBody = await response.json();
} catch (e) {}
return {
headers: responseHeaders,
body: responseBody
};
};
/**
* Contains some Request related Methods to some EzOnRails api.
* EzOnRails uses the localStorage to read and write the Configuration.
* The Storage is expected to contain the followingValues.
*/
export const EzOnRailsHttpClient = {
/**
* Sends a signup request to the EzOnRails application at the specified backendUrl.
* The specified data is the user data passed to the sign_up action of the EzOnRails endpoint.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* Since this differs from service to service, the data is mentioned to be "any" data.
* This is a async function, hence returning a promise of the response of the action.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
signUp: async (backendUrl: string, data: EzOnRailsSignUpParams, apiVersion: string) => {
data = EzOnRailsHttpUtils.toBackendParams(data);
await fetchWithThrow(
'POST',
EzOnRailsHttpUtils.toBaseUrl(backendUrl, 'users'),
{ user: data },
defaultHttpHeader(null, apiVersion)
);
},
/**
* Sends a sign in request to the EzOnRails application at the specified backendUrl.
* The user given by the specified data.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* The method returns an EzOnRailsAuthInfo object if the request was successfull and the server responded with authentication
* information for the next request. This information has to be saved and used by the next request to authenticate.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
signIn: async (backendUrl: string, data: EzOnRailsSignInParams, apiVersion: string): Promise<EzOnRailsAuthInfo> => {
data = EzOnRailsHttpUtils.toBackendParams(data);
const result = await fetchWithThrow(
'POST',
EzOnRailsHttpUtils.toApiUrl(backendUrl, 'auth/sign_in'),
data,
defaultHttpHeader(null, apiVersion)
);
return getAuthInfoFromHeader(result.headers);
},
/**
* Sends a signout request for the current user to the EzOnRails application at the specified backendUrl.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param authInfo
* @param apiVersion
*/
signOut: async (backendUrl: string, authInfo: EzOnRailsAuthInfo, apiVersion: string) => {
await fetchWithThrow(
'DELETE',
EzOnRailsHttpUtils.toApiUrl(backendUrl, 'auth/sign_out'),
null,
defaultHttpHeader(authInfo, apiVersion)
);
},
/**
* Sends a request to send password reset instructions via email to the EzOnRails application at the specified backendUrl.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
passwordResetInstructions: async (
backendUrl: string,
data: EzOnRailsPasswordResetInstructionsParams,
apiVersion: string
) => {
data = EzOnRailsHttpUtils.toBackendParams(data);
await fetchWithThrow(
'POST',
EzOnRailsHttpUtils.toBaseUrl(backendUrl, 'users/password'),
{ user: data },
defaultHttpHeader(null, apiVersion)
);
},
/**
* Sends a request to reset the password to the EzOnRails application at the specified backendUrl.
* This is the request to change the password, after the user filled out the form with the new password.
* This method also clears all auth headers.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
passwordReset: async (backendUrl: string, data: EzOnRailsPasswordResetParams, apiVersion: string) => {
data = EzOnRailsHttpUtils.toBackendParams(data);
await fetchWithThrow(
'PUT',
EzOnRailsHttpUtils.toBaseUrl(backendUrl, 'users/password'),
{ user: data },
defaultHttpHeader(null, apiVersion)
);
},
/**
* Requests and returns the own user information from the EzOnRails application at the specified backendUrl.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param authInfo
* @param apiVersion
*/
getUser: async (backendUrl: string, authInfo: EzOnRailsAuthInfo, apiVersion: string): Promise<EzOnRailsUser> => {
const result = await fetchWithThrow<EzOnRailsUser>(
'GET',
EzOnRailsHttpUtils.toApiUrl(backendUrl, 'users/me'),
null,
defaultHttpHeader(authInfo, apiVersion)
);
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Updates the user with the specified data on the EzOnRails application at the specified backendUrl
* side and returns the updated profile.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param authInfo
* @param apiVersion
*/
updateUser: async (
backendUrl: string,
data: EzOnRailsUpdateUserParams,
authInfo: EzOnRailsAuthInfo,
apiVersion: string
): Promise<EzOnRailsUser> => {
// Only the signedId must be passed to the update action
const avatarSignedId = data.avatar?.signedId;
const submitData = { ...EzOnRailsHttpUtils.toBackendParams(data), avatar: avatarSignedId };
const result = await fetchWithThrow<EzOnRailsUser>(
'PATCH',
EzOnRailsHttpUtils.toApiUrl(backendUrl, 'users/me'),
{ user: submitData },
defaultHttpHeader(authInfo, apiVersion)
);
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Sends a request to resend the confirmation email to the EzOnRails application at the specified backendUrl.
* This method also clears all auth headers.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
confirmationInstructions: async (
backendUrl: string,
data: EzOnRailsConfirmationInstructionsParams,
apiVersion: string
) => {
data = EzOnRailsHttpUtils.toBackendParams(data);
await fetchWithThrow(
'POST',
EzOnRailsHttpUtils.toBaseUrl(backendUrl, 'users/confirmation'),
{ user: data },
defaultHttpHeader(null, apiVersion)
);
},
/**
* Sends a request to confirm the account to the EzOnRails application at the specified backendUrl.
* The apiVersion is the current api version at the backend that must match.
*
* @param backendUrl
* @param data
* @param apiVersion
*/
confirmation: async (backendUrl: string, data: EzOnRailsConfirmParams, apiVersion: string) => {
let url = EzOnRailsHttpUtils.toBaseUrl(backendUrl, 'users/confirmation');
data = EzOnRailsHttpUtils.toBackendParams(data);
// @ts-ignore This works because the type only is a default json object
url = `${url}?${EzOnRailsHttpUtils.toGetParameters(data)}`;
await fetchWithThrow('GET', url, null, defaultHttpHeader(null, apiVersion));
},
/**
* Calls a http GET action to the api at the specified path of an EzOnRails application at the backendUrl.
* The backendUrl and the path are expected not to have the api suffix / prefix included.
* The data object is expected to be an json object containing the body information of the request.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* In this case, the data object will be serialized to a get parameter string and will be appended to the url.
* The call includes the auth headers for the current user.
* If the authInfo is passed, the request will send authentication headers to authenticate the user defined by
* the authInfo object.
* The apiVersion is the current api version of the backend.
* If the beforeRequest function is passed, those will be called after the data has been converted to snake_case and
* before the data is send to the server. This can be used to manipulate the data right before the request.
* The response json will be automatically converted to camelCase. ISO Date Strings will be automatically converted to date objects.
*
* @param backendUrl
* @param path
* @param data
* @param authInfo
* @param apiVersion
* @param beforeRequest
*/
get: async <TParams, TResponse>(
backendUrl: string,
path: string,
data: TParams,
authInfo: EzOnRailsAuthInfo | null = null,
apiVersion = '1.0',
beforeRequest: ((data: TParams) => TParams) | undefined = undefined
): Promise<TResponse> => {
let url = EzOnRailsHttpUtils.toApiUrl(backendUrl, path);
if (data) {
data = EzOnRailsHttpUtils.toBackendParams(data);
}
if (beforeRequest) {
data = beforeRequest(data);
}
if (data) {
url = `${url}?${EzOnRailsHttpUtils.toGetParameters(data)}`;
}
const result = await fetchWithThrow<TResponse>('GET', url, null, defaultHttpHeader(authInfo, apiVersion));
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Calls a http POST action to the api at the specified path of an EzOnRails application at the backendUrl.
* The backendUrl and the path are expected not to have the api suffix / prefix included.
* The url is expected to be the path without the system and the api prefix.
* The data object is expected to be an json object containing the body information of the request.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* The call includes the auth headers for the current user.
* If the authInfo is passed, the request will send authentication headers to authenticate the user defined by
* the authInfo object.
* The apiVersion is the current api version of the backend.
* If the beforeRequest function is passed, those will be called after the data has been converted to snake_case and
* before the data is send to the server. This can be used to manipulate the data right before the request.
* The response json will be automatically converted to camelCase. ISO Date Strings will be automatically converted to date objects.
*
* @param backendUrl
* @param path
* @param data
* @param authInfo
* @param apiVersion
* @param beforeRequest
*/
post: async <TParams, TResponse>(
backendUrl: string,
path: string,
data: TParams,
authInfo: EzOnRailsAuthInfo | null = null,
apiVersion = '1.0',
beforeRequest: ((data: TParams) => TParams) | undefined = undefined
): Promise<TResponse> => {
const url = EzOnRailsHttpUtils.toApiUrl(backendUrl, path);
if (data) {
data = EzOnRailsHttpUtils.toBackendParams(data);
}
if (beforeRequest) {
data = beforeRequest(data);
}
const result = await fetchWithThrow<TResponse>('POST', url, data, defaultHttpHeader(authInfo, apiVersion));
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Calls a http PATCH action to the api at the specified path of an EzOnRails application at the backendUrl.
* The backendUrl and the path are expected not to have the api suffix / prefix included.
* The url is expected to be the path without the system and the api prefix.
* The data object is expected to be an json object containing the body information of the request.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* The call includes the auth headers for the current user.
* If the authInfo is passed, the request will send authentication headers to authenticate the user defined by
* the authInfo object.
* The apiVersion is the current api version of the backend.
* If the beforeRequest function is passed, those will be called after the data has been converted to snake_case and
* before the data is send to the server. This can be used to manipulate the data right before the request.
* The response json will be automatically converted to camelCase. ISO Date Strings will be automatically converted to date objects.
*
* @param backendUrl
* @param path
* @param data
* @param authInfo
* @param apiVersion
* @param beforeRequest
*/
patch: async <TParams, TResponse>(
backendUrl: string,
path: string,
data: TParams,
authInfo: EzOnRailsAuthInfo | null = null,
apiVersion = '1.0',
beforeRequest: ((data: TParams) => TParams) | undefined = undefined
): Promise<TResponse> => {
const url = EzOnRailsHttpUtils.toApiUrl(backendUrl, path);
if (data) {
data = EzOnRailsHttpUtils.toBackendParams(data);
}
if (beforeRequest) {
data = beforeRequest(data);
}
const result = await fetchWithThrow<TResponse>('PATCH', url, data, defaultHttpHeader(authInfo, apiVersion));
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Calls a http PUT action to the api at the specified path of an EzOnRails application at the backendUrl.
* The backendUrl and the path are expected not to have the api suffix / prefix included.
* The url is expected to be the path without the system and the api prefix.
* The data object is expected to be an json object containing the body information of the request.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* The call includes the auth headers for the current user.
* If the authInfo is passed, the request will send authentication headers to authenticate the user defined by
* the authInfo object.
* The apiVersion is the current api version of the backend.
* If the beforeRequest function is passed, those will be called after the data has been converted to snake_case and
* before the data is send to the server. This can be used to manipulate the data right before the request.
* The response json will be automatically converted to camelCase. ISO Date Strings will be automatically converted to date objects.
*
* @param backendUrl
* @param path
* @param data
* @param authInfo
* @param apiVersion
* @param beforeRequest
*/
put: async <TParams, TResponse>(
backendUrl: string,
path: string,
data: TParams,
authInfo: EzOnRailsAuthInfo | null = null,
apiVersion = '1.0',
beforeRequest: ((data: TParams) => TParams) | undefined = undefined
): Promise<TResponse> => {
const url = EzOnRailsHttpUtils.toApiUrl(backendUrl, path);
if (data) {
data = EzOnRailsHttpUtils.toBackendParams(data);
}
if (beforeRequest) {
data = beforeRequest(data);
}
const result = await fetchWithThrow<TResponse>('PUT', url, data, defaultHttpHeader(authInfo, apiVersion));
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Calls a http DELETE action to the api at the specified path of an EzOnRails application at the backendUrl.
* The backendUrl and the path are expected not to have the api suffix / prefix included.
* The url is expected to be the path without the system and the api prefix.
* The call includes the auth headers for the current user.
* The data object is expected to be an json object containing the body information of the request.
* The data object is automatically converted to snake case. Date objects are automatically converted to iso strings.
* In this case, the data object will be serialized to a get parameter string and will be appended to the url.
* The call includes the auth headers for the current user.
* If the authInfo is passed, the request will send authentication headers to authenticate the user defined by
* the authInfo object.
* The apiVersion is the current api version of the backend.
* If the beforeRequest function is passed, those will be called after the data has been converted to snake_case and
* before the data is send to the server. This can be used to manipulate the data right before the request.
* The response json will be automatically converted to camelCase. ISO Date Strings will be automatically converted to date objects.
*
* @param backendUrl
* @param path
* @param data
* @param authInfo
* @param apiVersion
* @param beforeRequest
*/
delete: async <TParams, TResponse>(
backendUrl: string,
path: string,
data: TParams,
authInfo: EzOnRailsAuthInfo | null = null,
apiVersion = '1.0',
beforeRequest: ((data: TParams) => TParams) | undefined = undefined
): Promise<TResponse> => {
let url = EzOnRailsHttpUtils.toApiUrl(backendUrl, path);
if (data) {
data = EzOnRailsHttpUtils.toBackendParams(data);
}
if (beforeRequest) {
data = beforeRequest(data);
}
if (data) {
url = `${url}?${EzOnRailsHttpUtils.toGetParameters(data)}`;
}
const result = await fetchWithThrow<TResponse>('DELETE', url, null, defaultHttpHeader(authInfo, apiVersion));
return EzOnRailsHttpUtils.toFrontendParams(result.body);
},
/**
* Returns the default headers used to make an authorized request.
* Can be used for custom requests without the ez-on-rails-react client.
*
* @param authInfo
* @param apiVersion
*/
defaultHttpHeader: (authInfo: EzOnRailsAuthInfo | null, apiVersion: string): Record<string, string> => {
return defaultHttpHeader(authInfo, apiVersion);
}
};