1 import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models'
2 import { AbstractCommand, OverrideCommandOptions } from '../shared'
4 export class AccountsCommand extends AbstractCommand {
6 list (options: OverrideCommandOptions & {
7 sort?: string // default -createdAt
9 const { sort = '-createdAt' } = options
10 const path = '/api/v1/accounts'
12 return this.getRequestBody<ResultList<Account>>({
18 defaultExpectedStatus: HttpStatusCode.OK_200
22 get (options: OverrideCommandOptions & {
25 const path = '/api/v1/accounts/' + options.accountName
27 return this.getRequestBody<Account>({
32 defaultExpectedStatus: HttpStatusCode.OK_200
36 listRatings (options: OverrideCommandOptions & {
38 rating?: VideoRateType
40 const { rating, accountName } = options
41 const path = '/api/v1/accounts/' + accountName + '/ratings'
43 const query = { rating }
45 return this.getRequestBody<ResultList<AccountVideoRate>>({
51 defaultExpectedStatus: HttpStatusCode.OK_200
55 listFollowers (options: OverrideCommandOptions & {
62 const { accountName, start, count, sort, search } = options
63 const path = '/api/v1/accounts/' + accountName + '/followers'
65 const query = { start, count, sort, search }
67 return this.getRequestBody<ResultList<ActorFollow>>({
73 defaultExpectedStatus: HttpStatusCode.OK_200