mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +02:00
shared/ typescript types dir server-commands
This commit is contained in:
parent
6b5f72beda
commit
bf54587a3e
242 changed files with 228 additions and 172 deletions
78
shared/server-commands/users/accounts-command.ts
Normal file
78
shared/server-commands/users/accounts-command.ts
Normal file
|
@ -0,0 +1,78 @@
|
|||
import { HttpStatusCode, ResultList } from '@shared/models'
|
||||
import { Account, ActorFollow } from '../../models/actors'
|
||||
import { AccountVideoRate, VideoRateType } from '../../models/videos'
|
||||
import { AbstractCommand, OverrideCommandOptions } from '../shared'
|
||||
|
||||
export class AccountsCommand extends AbstractCommand {
|
||||
|
||||
list (options: OverrideCommandOptions & {
|
||||
sort?: string // default -createdAt
|
||||
} = {}) {
|
||||
const { sort = '-createdAt' } = options
|
||||
const path = '/api/v1/accounts'
|
||||
|
||||
return this.getRequestBody<ResultList<Account>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
query: { sort },
|
||||
implicitToken: false,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
get (options: OverrideCommandOptions & {
|
||||
accountName: string
|
||||
}) {
|
||||
const path = '/api/v1/accounts/' + options.accountName
|
||||
|
||||
return this.getRequestBody<Account>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
implicitToken: false,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
listRatings (options: OverrideCommandOptions & {
|
||||
accountName: string
|
||||
rating?: VideoRateType
|
||||
}) {
|
||||
const { rating, accountName } = options
|
||||
const path = '/api/v1/accounts/' + accountName + '/ratings'
|
||||
|
||||
const query = { rating }
|
||||
|
||||
return this.getRequestBody<ResultList<AccountVideoRate>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
query,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
|
||||
listFollowers (options: OverrideCommandOptions & {
|
||||
accountName: string
|
||||
start?: number
|
||||
count?: number
|
||||
sort?: string
|
||||
search?: string
|
||||
}) {
|
||||
const { accountName, start, count, sort, search } = options
|
||||
const path = '/api/v1/accounts/' + accountName + '/followers'
|
||||
|
||||
const query = { start, count, sort, search }
|
||||
|
||||
return this.getRequestBody<ResultList<ActorFollow>>({
|
||||
...options,
|
||||
|
||||
path,
|
||||
query,
|
||||
implicitToken: true,
|
||||
defaultExpectedStatus: HttpStatusCode.OK_200
|
||||
})
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue