1 import { ResultList } from '@shared/models'
2 import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
3 import { Account } from '../../models/actors'
4 import { AccountVideoRate, VideoRateType } from '../../models/videos'
5 import { AbstractCommand, OverrideCommandOptions } from '../shared'
7 export class AccountsCommand extends AbstractCommand {
9 list (options: OverrideCommandOptions & {
10 sort?: string // default -createdAt
12 const { sort = '-createdAt' } = options
13 const path = '/api/v1/accounts'
15 return this.getRequestBody<ResultList<Account>>({
21 defaultExpectedStatus: HttpStatusCode.OK_200
25 get (options: OverrideCommandOptions & {
28 const path = '/api/v1/accounts/' + options.accountName
30 return this.getRequestBody<Account>({
35 defaultExpectedStatus: HttpStatusCode.OK_200
39 listRatings (options: OverrideCommandOptions & {
41 rating?: VideoRateType
43 const { rating, accountName } = options
44 const path = '/api/v1/accounts/' + accountName + '/ratings'
46 const query = { rating }
48 return this.getRequestBody<ResultList<AccountVideoRate>>({
54 defaultExpectedStatus: HttpStatusCode.OK_200