/**
* 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.12-canary
*/
import type {
PostLocationGetOKResponse,
PostLocationGetParams,
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",
},
);
};
/**
* Locate a post just from its ID. This will tell you what kind of post it
is and where to find it. Where "a post is" is simple for threads, just
the slug. For replies, it will give you the thread slug and the position
within the thread: the index, the page and the position on the page.
*/
export type postLocationGetResponse = {
data: PostLocationGetOKResponse;
status: number;
};
export const getPostLocationGetUrl = (params: PostLocationGetParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
return normalizedParams.size
? `/posts/location?${normalizedParams.toString()}`
: `/posts/location`;
};
export const postLocationGet = async (
params: PostLocationGetParams,
options?: RequestInit,
): Promise<postLocationGetResponse> => {
return fetcher<Promise<postLocationGetResponse>>(
getPostLocationGetUrl(params),
{
...options,
method: "GET",
},
);
};