dl-commons 0.0.2-testing.47 → 0.0.2-testing.49
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/dist/models/interfaces/user-meta.interface.d.ts +1 -0
- package/dist/services/iam.service.d.ts +1 -0
- package/dist/services/iam.service.js +17 -0
- package/dist/services/iam.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/models/interfaces/user-meta.interface.ts +1 -0
- package/src/services/iam.service.ts +20 -0
package/package.json
CHANGED
|
@@ -98,5 +98,25 @@ export class IAMService {
|
|
|
98
98
|
throw RESTError.createFromCatch(e, { keyword: 'unknown', debug: e });
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
+
|
|
102
|
+
public async fetchUsername(id: string) : Promise<String> {
|
|
103
|
+
try {
|
|
104
|
+
const endpoint = `${this._baseUrl}/v1/users/${id}/username`;
|
|
105
|
+
const response$ = this._httpService.get<RESTResponseBody<IUser>>(endpoint);
|
|
106
|
+
const response = await firstValueFrom(response$);
|
|
107
|
+
|
|
108
|
+
if (response.data.errors) {
|
|
109
|
+
throw new RESTError('iam_api_error', response.data.errors);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (!response.data || !response.data.result || !response.data.result.data) {
|
|
113
|
+
throw new RESTError('iam_api_error', 'empty response');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return response.data.result.data.username;
|
|
117
|
+
} catch (e) {
|
|
118
|
+
throw RESTError.createFromCatch(e, { keyword: 'unknown', debug: e });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
101
121
|
//#endregion
|
|
102
122
|
}
|