Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

any plans to migrate to ts or provide types #1

Open
sk337 opened this issue Apr 19, 2024 · 2 comments
Open

any plans to migrate to ts or provide types #1

sk337 opened this issue Apr 19, 2024 · 2 comments

Comments

@sk337
Copy link

sk337 commented Apr 19, 2024

if you are willing to I could add types for you

@sk337 sk337 changed the title any plans to migrate to ts or provide types of at least jsdoc comments any plans to migrate to ts or provide types Apr 19, 2024
@Gimenz
Copy link
Owner

Gimenz commented Apr 20, 2024

yeaa, it's good idea, but i'm sorry i too busy at RL, any time at holiday i'll convert it to ts. also youu can add types, it make more easier to read

@sk337
Copy link
Author

sk337 commented Apr 21, 2024

here are the types I made so you can implement them into the program

interface User {
  name: string;
  avatar: string;
  fullName: string;
}

interface Profile {
  username:string;
  avatar:string;
  isPrivate:boolean;
  backgroundUrl:string;
  followerRequest:string;
  followingRequest:string;
  isBlockedbyCurrentUser:boolean;
  name:string;
  description:string;
  genderCode:string;
  language:number;
  createDate:string;
  location:string;
  verified:boolean;
  ambassador:boolean;
  facebook:string;
  twitter:string;
  website:string;
  votesReceved:number;
  numStoriesPublished:number;
  numFollowing:number;
  numFollowers:number;
  numLists:number;
  verified_email:number;
  is_staff:boolean;
  highlight_color:string;
  programs:{ [key:string]:boolean };
  externalId:string;
  showSocialNetwork:boolean;
}

interface Language {
  id: number;
  name: string;
}

interface Part {
  id: number;
  title: string;
  modifyDate: string;
  length: number;
  videoId: string;
  photoUrl: string;
  commentCount: number;
  voteCount: number;
  readCount: number;
  dedication: { [key: string]: string };
  text_url: {
    text: string;
  }
}

interface ViewPart {
  id: number;
  title: string;
  url: string;
  rating: number;
  modifyDate: string;
  photoUrl: string;
  commentCount: number;
  voteCount: number;
  readCount: number;
}

interface Error {
  error_code: number;
  error_typr: string;
  message: string;
  fields: string[];
}

export interface Details {
  id: string;
  title: string;
  length: number;
  createDate: string;
  modifyDate: string;
  voteCount: number;
  readCount: number;
  commentCount: number;
  language: Language;
  user: User;
  description: string;
  cover: string;
  completed: boolean;
  categories: number[];
  tags: string[];
  rating: number;
  copyright: number;
  url: string;
  numParts: number;
  lastPublishedPart: {
    createDate: string;
  };
  parts: Part[];
}

interface Story {
  text: string;
  text_hash: string;
}

declare module "wattpad.js" {
  export default class Wattpad {
    constructor();
    static Stories: {
      detail(id: string | number): Promise<Details | Error>;
      read(id: string | number): Promise<Story | Error>;
    };
    static User: {
      lookup(username: string): Promise<Profile | Error>;
    };
    // Add other methods as needed
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants