PeerTube/shared/extra-utils/custom-pages/custom-pages-command.ts

35 lines
904 B
TypeScript
Raw Normal View History

2021-07-06 09:55:05 +02:00
import { CustomPage } from '@shared/models'
2021-07-06 10:22:37 +02:00
import { HttpStatusCode } from '../../core-utils/miscs/http-error-codes'
2021-07-06 09:55:05 +02:00
import { AbstractCommand, OverrideCommandOptions } from '../shared'
2021-07-06 09:55:05 +02:00
export class CustomPagesCommand extends AbstractCommand {
2021-07-06 09:55:05 +02:00
getInstanceHomepage (options: OverrideCommandOptions = {}) {
const path = '/api/v1/custom-pages/homepage/instance'
2021-07-06 09:55:05 +02:00
return this.getRequestBody<CustomPage>({
...options,
2021-07-06 09:55:05 +02:00
path,
implicitToken: false,
2021-07-06 09:55:05 +02:00
defaultExpectedStatus: HttpStatusCode.OK_200
})
}
2021-07-06 09:55:05 +02:00
updateInstanceHomepage (options: OverrideCommandOptions & {
content: string
}) {
const { content } = options
const path = '/api/v1/custom-pages/homepage/instance'
2021-07-06 09:55:05 +02:00
return this.putBodyRequest({
...options,
2021-07-06 09:55:05 +02:00
path,
fields: { content },
implicitToken: true,
2021-07-06 09:55:05 +02:00
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
}