import type { APIClient } from '@wireapp/api-client' ; import type { Self } from '@wireapp/api-client/src/self/' ; export class SelfService { constructor ( private readonly apiClient ) { } public async checkUsername ( username ) { const [ availableUsername ] = await this . checkUsernames ( [ username ] ) ; return ! ! availableUsername ; } public checkUsernames ( usernames ) { return this . apiClient . user . api . postHandles ( { handles : usernames , } ) ; } public async getName ( ) { const { name } = await this . apiClient . self . api . getName ( ) ; return name ; } public async getSelf ( ) { const selfData = await this . apiClient . self . api . getSelf ( ) ; return selfData ; } public async getUsername ( ) { const { handle } = await this . getSelf ( ) ; return handle ; } public setName ( name ) { return this . apiClient . self . api . putSelf ( { name } ) ; } public setUsername ( username ) { return this . apiClient . self . api . putHandle ( { handle : username } ) ; } }