Skip to content

Commit

Permalink
Use enum types in API. Fixes #51
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed May 15, 2022
1 parent 7203e3d commit a8f4298
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 50 deletions.
11 changes: 3 additions & 8 deletions src/interfaces/api/comment.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ListingType, SortType } from "../others";
import { CommentReportView, CommentView } from "../views";

export interface CreateComment {
Expand Down Expand Up @@ -77,14 +78,8 @@ export interface CreateCommentLike {
* To get posts for a federated community by name, use `name@instance.tld` .
*/
export interface GetComments {
/**
* The [[ListingType]].
*/
type_?: string;
/**
* The [[SortType]].
*/
sort?: string;
type_?: ListingType;
sort?: SortType;
page?: number;
limit?: number;
community_id?: number;
Expand Down
12 changes: 3 additions & 9 deletions src/interfaces/api/community.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ListingType, SortType } from "../others";
import { Site } from "../source";
import {
CommunityModeratorView,
Expand Down Expand Up @@ -39,15 +40,8 @@ export interface CommunityResponse {
}

export interface ListCommunities {
/**
* The [[ListingType]].
*/
type_?: string;

/**
* The [[SortType]].
*/
sort?: string;
type_?: ListingType;
sort?: SortType;
page?: number;
limit?: number;
auth?: string;
Expand Down
13 changes: 4 additions & 9 deletions src/interfaces/api/person.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SortType } from "../others";
import {
CommentView,
CommunityModeratorView,
Expand Down Expand Up @@ -127,7 +128,7 @@ export interface GetPersonDetails {
* To get details for a federated user, use `person@instance.tld`.
*/
username?: string;
sort?: string;
sort?: SortType;
page?: number;
limit?: number;
community_id?: number;
Expand Down Expand Up @@ -186,21 +187,15 @@ export interface BanPersonResponse {
}

export interface GetReplies {
/**
* The [[SortType]].
*/
sort?: string;
sort?: SortType;
page?: number;
limit?: number;
unread_only?: boolean;
auth: string;
}

export interface GetPersonMentions {
/**
* The [[SortType]].
*/
sort?: string;
sort?: SortType;
page?: number;
limit?: number;
unread_only?: boolean;
Expand Down
14 changes: 3 additions & 11 deletions src/interfaces/api/post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SiteMetadata } from "..";
import { ListingType, SiteMetadata, SortType } from "../others";
import {
CommentView,
CommunityModeratorView,
Expand Down Expand Up @@ -35,16 +35,8 @@ export interface GetPostResponse {
}

export interface GetPosts {
/**
* The [[ListingType]].
*
* Post listing types are `All, Subscribed, Community`
*/
type_?: string;
/**
* The [[SortType]].
*/
sort?: string;
type_?: ListingType;
sort?: SortType;
page?: number;
limit?: number;
community_id?: number;
Expand Down
17 changes: 4 additions & 13 deletions src/interfaces/api/site.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ListingType, SearchType, SortType } from "../others";
import {
CommentView,
CommunityBlockView,
Expand Down Expand Up @@ -30,22 +31,12 @@ export interface Search {
* The search query string.
*/
q: string;

/**
* The [[SearchType]].
*/
type_?: string;
type_?: SearchType;
community_id?: number;
community_name?: string;
creator_id?: number;
/**
* The [[SortType]].
*/
sort?: string;
/**
* The [[ListingType]].
*/
listing_type?: string;
sort?: SortType;
listing_type?: ListingType;
page?: number;
limit?: number;
auth?: string;
Expand Down

0 comments on commit a8f4298

Please sign in to comment.