2021-12-17 11:58:15 +01:00
|
|
|
import { Account, AccountVideoRate, ActorFollow, HttpStatusCode, ResultList, VideoRateType } from '@shared/models'
|
2021-07-07 13:38:26 +02:00
|
|
|
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 },
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: false,
|
2021-07-07 13:38:26 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
get (options: OverrideCommandOptions & {
|
|
|
|
accountName: string
|
|
|
|
}) {
|
|
|
|
const path = '/api/v1/accounts/' + options.accountName
|
|
|
|
|
|
|
|
return this.getRequestBody<Account>({
|
|
|
|
...options,
|
|
|
|
|
|
|
|
path,
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: false,
|
2021-07-07 13:38:26 +02:00
|
|
|
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,
|
2021-07-08 10:55:16 +02:00
|
|
|
implicitToken: true,
|
2021-07-07 13:38:26 +02:00
|
|
|
defaultExpectedStatus: HttpStatusCode.OK_200
|
|
|
|
})
|
|
|
|
}
|
2021-10-19 09:44:43 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
})
|
|
|
|
}
|
2021-07-07 13:38:26 +02:00
|
|
|
}
|