posts.ts•2.94 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 {
PostReactAddBody,
PostReactAddOKResponse,
PostUpdateBody,
PostUpdateOKResponse,
} from "../openapi-schema";
import { fetcher } from "../server";
/**
* Publish changes to a single post.
*/
export type postUpdateResponse = {
data: PostUpdateOKResponse;
status: number;
};
export const getPostUpdateUrl = (postId: string) => {
return `/posts/${postId}`;
};
export const postUpdate = async (
postId: string,
postUpdateBody: PostUpdateBody,
options?: RequestInit,
): Promise<postUpdateResponse> => {
return fetcher<Promise<postUpdateResponse>>(getPostUpdateUrl(postId), {
...options,
method: "PATCH",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(postUpdateBody),
});
};
/**
* Archive a post using soft-delete.
*/
export type postDeleteResponse = {
data: void;
status: number;
};
export const getPostDeleteUrl = (postId: string) => {
return `/posts/${postId}`;
};
export const postDelete = async (
postId: string,
options?: RequestInit,
): Promise<postDeleteResponse> => {
return fetcher<Promise<postDeleteResponse>>(getPostDeleteUrl(postId), {
...options,
method: "DELETE",
});
};
/**
* Add a reaction to a post.
*/
export type postReactAddResponse = {
data: PostReactAddOKResponse;
status: number;
};
export const getPostReactAddUrl = (postId: string) => {
return `/posts/${postId}/reacts`;
};
export const postReactAdd = async (
postId: string,
postReactAddBody: PostReactAddBody,
options?: RequestInit,
): Promise<postReactAddResponse> => {
return fetcher<Promise<postReactAddResponse>>(getPostReactAddUrl(postId), {
...options,
method: "PUT",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(postReactAddBody),
});
};
/**
* Remove a reaction from a post.
*/
export type postReactRemoveResponse = {
data: void;
status: number;
};
export const getPostReactRemoveUrl = (postId: string, reactId: string) => {
return `/posts/${postId}/reacts/${reactId}`;
};
export const postReactRemove = async (
postId: string,
reactId: string,
options?: RequestInit,
): Promise<postReactRemoveResponse> => {
return fetcher<Promise<postReactRemoveResponse>>(
getPostReactRemoveUrl(postId, reactId),
{
...options,
method: "DELETE",
},
);
};