2026-01-23 14:51:39 +01:00
|
|
|
import {
|
|
|
|
|
apiRequestPost,
|
|
|
|
|
apiRequestPut,
|
|
|
|
|
apiRequestGet,
|
|
|
|
|
apiRequestDelete,
|
|
|
|
|
} from 'mastodon/api';
|
|
|
|
|
|
|
|
|
|
import type {
|
|
|
|
|
ApiWrappedCollectionJSON,
|
|
|
|
|
ApiCollectionWithAccountsJSON,
|
|
|
|
|
ApiCreateCollectionPayload,
|
2026-01-29 12:01:40 +01:00
|
|
|
ApiUpdateCollectionPayload,
|
2026-01-23 14:51:39 +01:00
|
|
|
ApiCollectionsJSON,
|
2026-02-16 19:17:20 +01:00
|
|
|
WrappedCollectionAccountItem,
|
2026-01-23 14:51:39 +01:00
|
|
|
} from '../api_types/collections';
|
|
|
|
|
|
|
|
|
|
export const apiCreateCollection = (collection: ApiCreateCollectionPayload) =>
|
|
|
|
|
apiRequestPost<ApiWrappedCollectionJSON>('v1_alpha/collections', collection);
|
|
|
|
|
|
|
|
|
|
export const apiUpdateCollection = ({
|
|
|
|
|
id,
|
|
|
|
|
...collection
|
2026-01-29 12:01:40 +01:00
|
|
|
}: ApiUpdateCollectionPayload) =>
|
2026-01-23 14:51:39 +01:00
|
|
|
apiRequestPut<ApiWrappedCollectionJSON>(
|
|
|
|
|
`v1_alpha/collections/${id}`,
|
|
|
|
|
collection,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export const apiDeleteCollection = (collectionId: string) =>
|
|
|
|
|
apiRequestDelete(`v1_alpha/collections/${collectionId}`);
|
|
|
|
|
|
|
|
|
|
export const apiGetCollection = (collectionId: string) =>
|
2026-01-29 12:01:40 +01:00
|
|
|
apiRequestGet<ApiCollectionWithAccountsJSON>(
|
2026-01-23 14:51:39 +01:00
|
|
|
`v1_alpha/collections/${collectionId}`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export const apiGetAccountCollections = (accountId: string) =>
|
|
|
|
|
apiRequestGet<ApiCollectionsJSON>(
|
|
|
|
|
`v1_alpha/accounts/${accountId}/collections`,
|
|
|
|
|
);
|
2026-02-16 19:17:20 +01:00
|
|
|
|
|
|
|
|
export const apiAddCollectionItem = (collectionId: string, accountId: string) =>
|
|
|
|
|
apiRequestPost<WrappedCollectionAccountItem>(
|
|
|
|
|
`v1_alpha/collections/${collectionId}/items`,
|
|
|
|
|
{ account_id: accountId },
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export const apiRemoveCollectionItem = (collectionId: string, itemId: string) =>
|
|
|
|
|
apiRequestDelete<WrappedCollectionAccountItem>(
|
|
|
|
|
`v1_alpha/collections/${collectionId}/items/${itemId}`,
|
|
|
|
|
);
|
2026-03-09 10:54:17 +01:00
|
|
|
|
|
|
|
|
export const apiRevokeCollectionInclusion = (
|
|
|
|
|
collectionId: string,
|
|
|
|
|
itemId: string,
|
|
|
|
|
) =>
|
|
|
|
|
apiRequestPost(`v1_alpha/collections/${collectionId}/items/${itemId}/revoke`);
|