Skip to content

Commit

Permalink
Merge 5f5ff55 into b4d90c8
Browse files Browse the repository at this point in the history
  • Loading branch information
BatuAksoy committed Apr 27, 2021
2 parents b4d90c8 + 5f5ff55 commit 30bc698
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 18 deletions.
3 changes: 3 additions & 0 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
IPutioAPIClientResponse,
} from './types'
import Auth from '../resources/Auth/Auth'
import DownloadLinks from '../resources/DownloadLinks/DownloadLinks'
import Config from '../resources/Config'
import Events from '../resources/Events/Events'
import Family from '../resources/Family'
Expand Down Expand Up @@ -46,6 +47,7 @@ export class PutioAPIClient {
public http: AxiosInstance

public Auth: Auth
public DownloadLinks: DownloadLinks
public Config: Config
public Events: Events
public Family: Family
Expand All @@ -67,6 +69,7 @@ export class PutioAPIClient {
this.options = { ...PutioAPIClient.DEFAULT_OPTIONS, ...options }
this.http = this.createHTTPClient()
this.Auth = new Auth(this)
this.DownloadLinks = new DownloadLinks(this)
this.Config = new Config(this)
this.Events = new Events(this)
this.Files = new Files(this)
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export * from './resources/Friends/types'
export * from './resources/Payment/types'
export * from './resources/User/types'
export * from './resources/Transfers/types'
export * from './resources/DownloadLinks/types'
export { isPutioAPIError } from './utils'
export { PutioAPIClient as default } from './client'
40 changes: 40 additions & 0 deletions src/resources/DownloadLinks/DownloadLinks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { PutioAPIClient } from '../../client'
import {
IDownloadLinksCreateResponse,
IDownloadLinksInfoResponse,
} from './types'

export default class DownloadLinks {
private client: PutioAPIClient

constructor(client: PutioAPIClient) {
this.client = client
}

public Create({
ids = [],
cursor,
excludeIds = [],
}: {
ids?: number[]
cursor?: string
excludeIds?: number[]
}) {
return this.client.post<IDownloadLinksCreateResponse>(
'/download_links/create',
{
data: {
file_ids: ids.join(','),
exclude_ids: excludeIds.join(','),
cursor,
},
},
)
}

public Get(downloadLinksId: number) {
return this.client.get<IDownloadLinksInfoResponse>(
`/download_links/${downloadLinksId}`,
)
}
}
16 changes: 16 additions & 0 deletions src/resources/DownloadLinks/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export interface IDownloadLinksCreateResponse {
id: number
}

export interface IDownloadLinksInfoResponse {
links: IDownloadLinks
links_status: DownloadLinksStatuses
}

interface IDownloadLinks {
download_links: string[]
mp4_links: string[]
media_links: string[]
}

export type DownloadLinksStatuses = 'NEW' | 'PROCESSING' | 'DONE' | 'ERROR'
18 changes: 0 additions & 18 deletions src/resources/Files/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,24 +271,6 @@ export default class Files {
})
}

public DownloadLinks({
ids = [],
cursor,
excludeIds = [],
}: {
ids?: number[]
cursor?: string
excludeIds?: number[]
}) {
return this.client.post('/files/get-download-links', {
data: {
file_ids: ids.join(','),
exclude_ids: excludeIds.join(','),
cursor,
},
})
}

public ConvertToMp4({
ids = [],
cursor,
Expand Down

0 comments on commit 30bc698

Please sign in to comment.