import config from '../config'
import ProfileService, {
  Video,
  VideoDirectUpload
} from '@komi-app/profiles-sdk'

export interface IVideoService {
  init(profileId: string): void
  createVideoDirectUpload(): Promise<VideoDirectUpload>
  getVideo(videoId: string): Promise<Video>
}

export class VideoService implements IVideoService {
  private profileService: ProfileService

  constructor() {
    this.profileService = new ProfileService({
      targetUrl: config.profiles.url,
      serviceName: config.service.name,
      serviceVersion: config.service.version,
      authUrl: config.auth.url
    })
  }

  init(profileId: string) {
    this.profileService.init(profileId)
  }

  createVideoDirectUpload(): Promise<VideoDirectUpload> {
    return this.profileService.createVideoDirectUpload()
  }

  getVideo(videoId: string): Promise<Video> {
    return this.profileService.getVideo(videoId)
  }
}
