You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wattpad-deno/src/classes/Wattpad.ts

39 lines
1.1 KiB

import Story from "./Story.ts";
import Search, { SearchParameters as QuerySearchParams } from "./Search.ts";
import TagSearch, { SearchParameters as TagSearchParams } from "./TagSearch.ts";
import { newSession, Options } from "../utils/http.ts";
import { Session } from "../types.d.ts";
export default class Wattpad {
session: Session;
/**
* a representation of Wattpad in class form
*/
constructor(opts?: Options) {
if (opts && !opts.headers) {
opts.headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; rv:108.0) Gecko/20100101 Firefox/108.0",
};
}
this.session = newSession(opts ?? {});
}
/**
* gets a Story from an ID
* @returns {Promise<Story>} a Story class for the story
*/
getStory(id: string): Story {
return new Story(id, this.session);
}
search(opts: QuerySearchParams) {
return new Search(opts, this.session);
}
tagSearch(opts: TagSearchParams) {
return new TagSearch(opts, this.session);
}
}