Skip to content

Commit

Permalink
feat: get collections
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed May 4, 2023
1 parent d99e944 commit 86bd5c2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/bgmc/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import type { BGMSearch, BGMSearchParams, BGMSubject, Query } from 'bgm-types';
import type {
BGMCollection,
BGMCollectionParams,
BGMSearch,
BGMSearchParams,
BGMSubject,
Query
} from 'bgm-types';

export class BgmClient {
static baseURL = 'https://api.bgm.tv';
Expand Down Expand Up @@ -41,6 +48,10 @@ export class BgmClient {
return this.request<BGMSearch.Search>(`/search/subject/${keywords}`, query);
}

public getCollections(username: string, query?: Query<BGMCollectionParams.Information>) {
return this.request<BGMCollection.Information>(`/v0/users/${username}/collections`, query);
}

public async request<T>(pathname: string, query: Record<string, any> = {}): Promise<T> {
const url = new URL(pathname, BgmClient.baseURL);
for (const [key, value] of Object.entries(query)) {
Expand Down

0 comments on commit 86bd5c2

Please sign in to comment.