Skip to content

Commit

Permalink
add file conversion response types
Browse files Browse the repository at this point in the history
  • Loading branch information
altaywtf committed Jan 16, 2022
1 parent 7a02cec commit 4bdcf35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/resources/Files/File.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import URI from 'urijs'
import { PutioAPIClient } from '../../client'
import { IGetStartFromResponse } from './types'
import { IFileConversionStatusResponse, IGetStartFromResponse } from './types'
export default class File {
private client: PutioAPIClient

Expand Down Expand Up @@ -78,11 +78,13 @@ export default class File {
}

public ConvertToMp4(fileId: number) {
return this.client.post(`/files/${fileId}/mp4`)
return this.client.post<{ count: number }>(`/files/${fileId}/mp4`)
}

public ConvertStatus(fileId: number) {
return this.client.get(`/files/${fileId}/mp4`)
return this.client.get<IFileConversionStatusResponse>(
`/files/${fileId}/mp4`,
)
}

public DeleteMp4(fileId: number) {
Expand Down
13 changes: 13 additions & 0 deletions src/resources/Files/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,16 @@ export interface IFileDeleteResponse {
skipped: number
cursor: string
}

export type FileConversionStatus =
| { status: 'NOT_AVAILABLE' }
| { status: 'IN_QUEUE' }
| { status: 'CONVERTING'; percent_done: number }
| { status: 'COMPLETED'; size: IFile['size'] }
| { status: 'ERROR' }

export interface IFileConversionStatusResponse {
mp4: FileConversionStatus & {
id: IFile['id']
}
}

0 comments on commit 4bdcf35

Please sign in to comment.