accounts.ts•9.48 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 {
AccountAuthProviderListOKResponse,
AccountEmailAddBody,
AccountEmailUpdateOKResponse,
AccountGetAvatarResponse,
AccountGetOKResponse,
AccountSetAvatarBody,
AccountUpdateBody,
AccountUpdateOKResponse,
} from "../openapi-schema";
import { fetcher } from "../server";
/**
* Get the information for the currently authenticated account.
*/
export type accountGetResponse = {
data: AccountGetOKResponse;
status: number;
};
export const getAccountGetUrl = () => {
return `/accounts`;
};
export const accountGet = async (
options?: RequestInit,
): Promise<accountGetResponse> => {
return fetcher<Promise<accountGetResponse>>(getAccountGetUrl(), {
...options,
method: "GET",
});
};
/**
* Update the information for the currently authenticated account.
*/
export type accountUpdateResponse = {
data: AccountUpdateOKResponse;
status: number;
};
export const getAccountUpdateUrl = () => {
return `/accounts`;
};
export const accountUpdate = async (
accountUpdateBody: AccountUpdateBody,
options?: RequestInit,
): Promise<accountUpdateResponse> => {
return fetcher<Promise<accountUpdateResponse>>(getAccountUpdateUrl(), {
...options,
method: "PATCH",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(accountUpdateBody),
});
};
/**
* Get detailed account information by ID. Requires either the permissions
VIEW_ACCOUNTS or ADMINISTRATOR. Users with VIEW_ACCOUNTS can view any
account that is not ADMINISTRATOR including those with VIEW_ACCOUNTS.
Only members with ADMINISTRATOR can view other ADMINISTRATOR accounts.
*/
export type accountViewResponse = {
data: AccountGetOKResponse;
status: number;
};
export const getAccountViewUrl = (accountId: string) => {
return `/accounts/${accountId}`;
};
export const accountView = async (
accountId: string,
options?: RequestInit,
): Promise<accountViewResponse> => {
return fetcher<Promise<accountViewResponse>>(getAccountViewUrl(accountId), {
...options,
method: "GET",
});
};
/**
* Retrieve a list of authentication providers with a flag indicating which
ones are active for the currently authenticated account.
*/
export type accountAuthProviderListResponse = {
data: AccountAuthProviderListOKResponse;
status: number;
};
export const getAccountAuthProviderListUrl = () => {
return `/accounts/self/auth-methods`;
};
export const accountAuthProviderList = async (
options?: RequestInit,
): Promise<accountAuthProviderListResponse> => {
return fetcher<Promise<accountAuthProviderListResponse>>(
getAccountAuthProviderListUrl(),
{
...options,
method: "GET",
},
);
};
/**
* Deletes the specified authentication method from the account. This is
irreversible however if this authentication method is the only remaining
method for the account, this operation will fail with a 400 bad request.
*/
export type accountAuthMethodDeleteResponse = {
data: AccountAuthProviderListOKResponse;
status: number;
};
export const getAccountAuthMethodDeleteUrl = (authMethodId: string) => {
return `/accounts/self/auth-methods/${authMethodId}`;
};
export const accountAuthMethodDelete = async (
authMethodId: string,
options?: RequestInit,
): Promise<accountAuthMethodDeleteResponse> => {
return fetcher<Promise<accountAuthMethodDeleteResponse>>(
getAccountAuthMethodDeleteUrl(authMethodId),
{
...options,
method: "DELETE",
},
);
};
/**
* Add an email address to the authenticated account.
*/
export type accountEmailAddResponse = {
data: AccountEmailUpdateOKResponse;
status: number;
};
export const getAccountEmailAddUrl = () => {
return `/accounts/self/emails`;
};
export const accountEmailAdd = async (
accountEmailAddBody: AccountEmailAddBody,
options?: RequestInit,
): Promise<accountEmailAddResponse> => {
return fetcher<Promise<accountEmailAddResponse>>(getAccountEmailAddUrl(), {
...options,
method: "POST",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(accountEmailAddBody),
});
};
/**
* Remove an email address from the authenticated account.
*/
export type accountEmailRemoveResponse = {
data: void;
status: number;
};
export const getAccountEmailRemoveUrl = (emailAddressId: string) => {
return `/accounts/self/emails/${emailAddressId}`;
};
export const accountEmailRemove = async (
emailAddressId: string,
options?: RequestInit,
): Promise<accountEmailRemoveResponse> => {
return fetcher<Promise<accountEmailRemoveResponse>>(
getAccountEmailRemoveUrl(emailAddressId),
{
...options,
method: "DELETE",
},
);
};
/**
* Upload an avatar for the authenticated account.
*/
export type accountSetAvatarResponse = {
data: void;
status: number;
};
export const getAccountSetAvatarUrl = () => {
return `/accounts/self/avatar`;
};
export const accountSetAvatar = async (
accountSetAvatarBody: AccountSetAvatarBody,
options?: RequestInit,
): Promise<accountSetAvatarResponse> => {
return fetcher<Promise<accountSetAvatarResponse>>(getAccountSetAvatarUrl(), {
...options,
method: "POST",
headers: {
"Content-Type": "application/octet-stream",
...options?.headers,
},
body: JSON.stringify(accountSetAvatarBody),
});
};
/**
* Get an avatar for the specified account.
*/
export type accountGetAvatarResponse = {
data: AccountGetAvatarResponse;
status: number;
};
export const getAccountGetAvatarUrl = (accountHandle: string) => {
return `/accounts/${accountHandle}/avatar`;
};
export const accountGetAvatar = async (
accountHandle: string,
options?: RequestInit,
): Promise<accountGetAvatarResponse> => {
return fetcher<Promise<accountGetAvatarResponse>>(
getAccountGetAvatarUrl(accountHandle),
{
...options,
method: "GET",
},
);
};
/**
* Adds a role to an account. Members without the MANAGE_ROLES permission
cannot use this operation.
*/
export type accountAddRoleResponse = {
data: AccountUpdateOKResponse;
status: number;
};
export const getAccountAddRoleUrl = (accountHandle: string, roleId: string) => {
return `/accounts/${accountHandle}/roles/${roleId}`;
};
export const accountAddRole = async (
accountHandle: string,
roleId: string,
options?: RequestInit,
): Promise<accountAddRoleResponse> => {
return fetcher<Promise<accountAddRoleResponse>>(
getAccountAddRoleUrl(accountHandle, roleId),
{
...options,
method: "PUT",
},
);
};
/**
* Removes a role from an account. Members without the MANAGE_ROLES cannot
use this operation. Admins cannot remove the admin role from themselves.
*/
export type accountRemoveRoleResponse = {
data: AccountUpdateOKResponse;
status: number;
};
export const getAccountRemoveRoleUrl = (
accountHandle: string,
roleId: string,
) => {
return `/accounts/${accountHandle}/roles/${roleId}`;
};
export const accountRemoveRole = async (
accountHandle: string,
roleId: string,
options?: RequestInit,
): Promise<accountRemoveRoleResponse> => {
return fetcher<Promise<accountRemoveRoleResponse>>(
getAccountRemoveRoleUrl(accountHandle, roleId),
{
...options,
method: "DELETE",
},
);
};
/**
* Desgiantes the specified role as a badge for the profile. Only one role
may be set as a badge for the profile. Setting a role as a badge is
entirely aesthetic and does not grant any additional permissions. Roles
may be created without any permissions in order to be used as badges.
*/
export type accountRoleSetBadgeResponse = {
data: AccountUpdateOKResponse;
status: number;
};
export const getAccountRoleSetBadgeUrl = (
accountHandle: string,
roleId: string,
) => {
return `/accounts/${accountHandle}/roles/${roleId}/badge`;
};
export const accountRoleSetBadge = async (
accountHandle: string,
roleId: string,
options?: RequestInit,
): Promise<accountRoleSetBadgeResponse> => {
return fetcher<Promise<accountRoleSetBadgeResponse>>(
getAccountRoleSetBadgeUrl(accountHandle, roleId),
{
...options,
method: "PUT",
},
);
};
/**
* Removes the badge from the profile. This does not remove the role from
the account, only the visual badge-status representation of the role.
*/
export type accountRoleRemoveBadgeResponse = {
data: AccountUpdateOKResponse;
status: number;
};
export const getAccountRoleRemoveBadgeUrl = (
accountHandle: string,
roleId: string,
) => {
return `/accounts/${accountHandle}/roles/${roleId}/badge`;
};
export const accountRoleRemoveBadge = async (
accountHandle: string,
roleId: string,
options?: RequestInit,
): Promise<accountRoleRemoveBadgeResponse> => {
return fetcher<Promise<accountRoleRemoveBadgeResponse>>(
getAccountRoleRemoveBadgeUrl(accountHandle, roleId),
{
...options,
method: "DELETE",
},
);
};