import { API , DEFAULT_API_OPTIONS } from '../core/api' ; import Config from './config' ; import Files from './files' ; import { Peer , ApiOptions } from '../models' ; /**
 * Profile is an API module for accessing public profile information
 */ export default class Profile extends API { private config : Config ; private files : Files ; constructor ( opts = DEFAULT_API_OPTIONS ) { super ( opts ) ; this . config = new Config ( opts ) ; this . files = new Files ( opts ) ; } returns async get ( ) { const response = await this . sendGet ( 'profile' ) ; return response . json ( ) as Promise < Peer > ; } returns async name ( ) { const contact = await this . get ( ) ; return contact . name ; } param name returns async setName ( name ) { const response = await this . sendPost ( 'profile/name' , [ name ] ) ; return response . status === 201 ; } returns async avatar ( ) { const contact = await this . get ( ) ; return contact . avatar ; } param image returns async setAvatar ( image ) { const thread = await this . config . get ( 'Account.Thread' ) ; await this . files . add ( image , 'avatar' , thread as string ) ; const response = await this . sendPost ( 'profile/avatar' ) ; return response . status === 201 ; } }