import { inject , injectable } from 'inversify' ; import * as apid from '../../../../../api' ; import IRepositoryModel from '../IRepositoryModel' ; import IVideoApiModel from './IVideoApiModel' ; @ injectable ( ) export default class VideoApiModel implements IVideoApiModel { private repository : IRepositoryModel ; constructor ( @ inject ( 'IRepositoryModel' ) repository ) { this . repository = repository ; } param videoFileId return public async delete ( videoFileId ) { await this . repository . delete ( `/videos/${ videoFileId }` ) ; } param videoFileId return public async getDuration ( videoFileId ) { const result = await this . repository . get ( `/videos/${ videoFileId }/duration` ) ; return result . data . duration ; } param hostName param videoFileId return public async sendToKodi ( hostName , videoFileId ) { await this . repository . post ( `/videos/${ videoFileId }/kodi` , { kodiName : hostName , } ) ; } param option return public async uploadedVideoFile ( option ) { const formData = new FormData ( ) ; formData . append ( 'recordedId' , option . recordedId . toString ( 10 ) ) ; formData . append ( 'parentDirectoryName' , option . parentDirectoryName ) ; if ( typeof option . subDirectory !== 'undefined' ) { formData . append ( 'subDirectory' , option . subDirectory ) ; } formData . append ( 'viewName' , option . viewName ) ; formData . append ( 'fileType' , option . fileType ) ; formData . append ( 'file' , option . file ) ; await this . repository . post ( '/videos/upload' , formData , { headers : { 'Content-Type' : 'multipart/form-data' , } , } ) ; } }