import { ApiClient } from './base'

export interface Profile {
  name: string
}

export interface ProfileProperty {
  property: string
  value: string
}

export class ProfileApiClient extends ApiClient {
  async getProfiles(): Promise<Profile[]> {
    return await super.getJson('/profiles')
  }

  async getProfile(name: string): Promise<Profile> {
    return await super.getJson('/profiles/' + name)
  }

  async createProfile(name: string): Promise<Profile> {
    return await super.postJson('/profiles', { name })
  }

  async deleteProfile(name: string): Promise<void> {
    return await super.delete(`/profiles/${name}`)
  }

  async getProperties(profileName: string): Promise<ProfileProperty[]> {
    return await super.getJson(`/profiles/${profileName}/properties`)
  }
}
