Add and document `timeline.compose`

This commit is contained in:
Roj Serbest 2021-10-25 11:28:23 +03:00
parent d00dc1e1b5
commit ee736c633c
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
import { Request } from "../request.ts";
import { Document, Post } from "../types.ts";
import { MethodBase } from "./method_base.ts";
export class Timeline extends MethodBase {
/**
* Composes a new post to push to the timeline
* @param text The text contents of the post that is to be composed.
* @param attachments An array of Document ID or instances to be attached to the post.
*/
compose(text: string, attachments?: (string | Document)[]): Promise<Post> {
return this.client.invokeRequest(
new Request("timeline.compose", {
text,
attachments: typeof attachments !== "undefined"
? attachments.map((attachment) => {
if (typeof attachment === "string") {
return attachment;
}
return attachment.id;
})
: undefined,
}),
true,
);
}
}