events.ts•6.7 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 {
EventCreateBody,
EventCreateOKResponse,
EventGetOKResponse,
EventListOKResponse,
EventListParams,
EventParticipantUpdateBody,
EventUpdateBody,
EventUpdateOKResponse,
} from "../openapi-schema";
import { fetcher } from "../server";
/**
* List all events using the filtering options.
*/
export type eventListResponse = {
data: EventListOKResponse;
status: number;
};
export const getEventListUrl = (params?: EventListParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
return normalizedParams.size
? `/events?${normalizedParams.toString()}`
: `/events`;
};
export const eventList = async (
params?: EventListParams,
options?: RequestInit,
): Promise<eventListResponse> => {
return fetcher<Promise<eventListResponse>>(getEventListUrl(params), {
...options,
method: "GET",
});
};
/**
* Create a new event. When an event is created, a thread is also created
which provides the means for discussion via the thread and reply APIs.
*/
export type eventCreateResponse = {
data: EventCreateOKResponse;
status: number;
};
export const getEventCreateUrl = () => {
return `/events`;
};
export const eventCreate = async (
eventCreateBody: EventCreateBody,
options?: RequestInit,
): Promise<eventCreateResponse> => {
return fetcher<Promise<eventCreateResponse>>(getEventCreateUrl(), {
...options,
method: "POST",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(eventCreateBody),
});
};
/**
* Get an event by its ID.
*/
export type eventGetResponse = {
data: EventGetOKResponse;
status: number;
};
export const getEventGetUrl = (eventMark: string) => {
return `/events/${eventMark}`;
};
export const eventGet = async (
eventMark: string,
options?: RequestInit,
): Promise<eventGetResponse> => {
return fetcher<Promise<eventGetResponse>>(getEventGetUrl(eventMark), {
...options,
method: "GET",
});
};
/**
* Update an event. If the content field is updated, this is stored on the
thread associated with the event, rather than the event itself. It's
possible to update that thread directly using `threads` operations.
*/
export type eventUpdateResponse = {
data: EventUpdateOKResponse;
status: number;
};
export const getEventUpdateUrl = (eventMark: string) => {
return `/events/${eventMark}`;
};
export const eventUpdate = async (
eventMark: string,
eventUpdateBody: EventUpdateBody,
options?: RequestInit,
): Promise<eventUpdateResponse> => {
return fetcher<Promise<eventUpdateResponse>>(getEventUpdateUrl(eventMark), {
...options,
method: "PATCH",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(eventUpdateBody),
});
};
/**
* Delete an event.
*/
export type eventDeleteResponse = {
data: void;
status: number;
};
export const getEventDeleteUrl = (eventMark: string) => {
return `/events/${eventMark}`;
};
export const eventDelete = async (
eventMark: string,
options?: RequestInit,
): Promise<eventDeleteResponse> => {
return fetcher<Promise<eventDeleteResponse>>(getEventDeleteUrl(eventMark), {
...options,
method: "DELETE",
});
};
/**
* Add a participant to an event or change an existing participant's state.
If the requesting account is an admin or holds MANAGE_EVENTS permission,
they can change the participation properties of any account. Otherwise,
they can only change their own participation properties.
For non-managing members (i.e. not an admin and not a host) this will
follow a stricter state machine for the participation status. If the
participation status is not set (no participation record is present) or
set to "declined", the member may only set their status to "requested"
if the event policy is set to "invite_only". Otherwise, they may set it
to "attending". If the member is already set to one of these states,
they may change it to "declined".
A non-managing member cannot change their role and the default is
"attendee", only managing members can change participant roles.
If the event participation policy is set to "invite_only" then members
can only set their status to "requested" or delete their participation.
If the event participation policy is set to "closed", it's a no-op.
Requests to this resource are idempotent given identical request bodies.
It acts as a create-or-update action as participation is account-unique.
*/
export type eventParticipantUpdateResponse = {
data: void;
status: number;
};
export const getEventParticipantUpdateUrl = (
eventMark: string,
accountId: string,
) => {
return `/events/${eventMark}/participants/${accountId}`;
};
export const eventParticipantUpdate = async (
eventMark: string,
accountId: string,
eventParticipantUpdateBody: EventParticipantUpdateBody,
options?: RequestInit,
): Promise<eventParticipantUpdateResponse> => {
return fetcher<Promise<eventParticipantUpdateResponse>>(
getEventParticipantUpdateUrl(eventMark, accountId),
{
...options,
method: "PUT",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(eventParticipantUpdateBody),
},
);
};
/**
* Remove a participant from an event. Same rules as EventParticipantUpdate
where non-managing members may only remove themselves. Not soft-delete.
*/
export type eventParticipantRemoveResponse = {
data: void;
status: number;
};
export const getEventParticipantRemoveUrl = (
eventMark: string,
accountId: string,
) => {
return `/events/${eventMark}/participants/${accountId}`;
};
export const eventParticipantRemove = async (
eventMark: string,
accountId: string,
options?: RequestInit,
): Promise<eventParticipantRemoveResponse> => {
return fetcher<Promise<eventParticipantRemoveResponse>>(
getEventParticipantRemoveUrl(eventMark, accountId),
{
...options,
method: "DELETE",
},
);
};