reports.ts•3.45 kB
/**
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* storyden
* Storyden social API for building community driven platforms.
The Storyden API does not adhere to semantic versioning but instead applies a rolling strategy with deprecations and minimal breaking changes. This has been done mainly for a simpler development process and it may be changed to a more fixed versioning strategy in the future. Ultimately, the primary way Storyden tracks versions is dates, there are no set release tags currently.
* OpenAPI spec version: v1.25.8-canary
*/
import type {
ReportCreateBody,
ReportCreateOKResponse,
ReportListOKResponse,
ReportListParams,
ReportUpdateBody,
ReportUpdateOKResponse,
} from "../openapi-schema";
import { fetcher } from "../server";
/**
* Create a new report for content or user violations.
Reports can be against any kind of user-generated content as well as
members themselves. The kind of report is specified in the request body
which dictates which resource the `id` field refers to.
*/
export type reportCreateResponse = {
data: ReportCreateOKResponse;
status: number;
};
export const getReportCreateUrl = () => {
return `/reports`;
};
export const reportCreate = async (
reportCreateBody: ReportCreateBody,
options?: RequestInit,
): Promise<reportCreateResponse> => {
return fetcher<Promise<reportCreateResponse>>(getReportCreateUrl(), {
...options,
method: "POST",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(reportCreateBody),
});
};
/**
* List reports. Regular members see only their own reports. Members with
`MANAGE_REPORTS` permission will see all submitted reports. Reports can
be filtered by status. By default filters open and acknowledged reports.
Returns a list ordered by most recently updated.
*/
export type reportListResponse = {
data: ReportListOKResponse;
status: number;
};
export const getReportListUrl = (params?: ReportListParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
return normalizedParams.size
? `/reports?${normalizedParams.toString()}`
: `/reports`;
};
export const reportList = async (
params?: ReportListParams,
options?: RequestInit,
): Promise<reportListResponse> => {
return fetcher<Promise<reportListResponse>>(getReportListUrl(params), {
...options,
method: "GET",
});
};
/**
* Update a report's status and optionally assign handler. Requires the
`MANAGE_REPORTS` permission to set the status to anything other than
closed. In other words, regular members can only close their own reports
while "moderators" can acknowledge, assign and resolve reports.
*/
export type reportUpdateResponse = {
data: ReportUpdateOKResponse;
status: number;
};
export const getReportUpdateUrl = (reportId: string) => {
return `/reports/${reportId}`;
};
export const reportUpdate = async (
reportId: string,
reportUpdateBody: ReportUpdateBody,
options?: RequestInit,
): Promise<reportUpdateResponse> => {
return fetcher<Promise<reportUpdateResponse>>(getReportUpdateUrl(reportId), {
...options,
method: "PATCH",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(reportUpdateBody),
});
};