Files
ncd-fe/packages/pl-api/lib/client/scheduled-statuses.ts
nicole mikołajczyk d5d453e645 pl-api: allow importing parts of the client
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
2026-02-23 10:39:26 +01:00

58 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import * as v from 'valibot';
import { scheduledStatusSchema } from '../entities';
import type { PlApiBaseClient } from '../client-base';
import type { GetScheduledStatusesParams } from '../params/scheduled-statuses';
type EmptyObject = Record<string, never>;
const scheduledStatuses = (client: PlApiBaseClient) => ({
/**
* View scheduled statuses
* @see {@link https://docs.joinmastodon.org/methods/scheduled_statuses/#get}
*/
getScheduledStatuses: (params?: GetScheduledStatusesParams) =>
client.paginatedGet('/api/v1/scheduled_statuses', { params }, scheduledStatusSchema),
/**
* View a single scheduled status
* @see {@link https://docs.joinmastodon.org/methods/scheduled_statuses/#get-one}
*/
getScheduledStatus: async (scheduledStatusId: string) => {
const response = await client.request(`/api/v1/scheduled_statuses/${scheduledStatusId}`);
return v.parse(scheduledStatusSchema, response.json);
},
/**
* Update a scheduled statuss publishing date
* @see {@link https://docs.joinmastodon.org/methods/scheduled_statuses/#update}
*/
updateScheduledStatus: async (scheduledStatusId: string, scheduled_at: string) => {
const response = await client.request(`/api/v1/scheduled_statuses/${scheduledStatusId}`, {
method: 'PUT',
body: { scheduled_at },
});
return v.parse(scheduledStatusSchema, response.json);
},
/**
* Cancel a scheduled status
* @see {@link https://docs.joinmastodon.org/methods/scheduled_statuses/#cancel}
*/
cancelScheduledStatus: async (scheduledStatusId: string) => {
const response = await client.request<EmptyObject>(
`/api/v1/scheduled_statuses/${scheduledStatusId}`,
{
method: 'DELETE',
},
);
return response.json;
},
});
export { scheduledStatuses };