-
-
Notifications
You must be signed in to change notification settings - Fork 239
/
AccountInfo.ts
31 lines (22 loc) · 959 Bytes
/
AccountInfo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { Parser } from '../index.js';
import { InnertubeError } from '../../utils/Utils.js';
import AccountSectionList from '../classes/AccountSectionList.js';
import type { ApiResponse } from '../../core/index.js';
import type { IParsedResponse } from '../types/index.js';
import type AccountItemSection from '../classes/AccountItemSection.js';
export default class AccountInfo {
readonly #page: IParsedResponse;
contents: AccountItemSection | null;
constructor(response: ApiResponse) {
this.#page = Parser.parseResponse(response.data);
if (!this.#page.contents)
throw new InnertubeError('Page contents not found');
const account_section_list = this.#page.contents.array().as(AccountSectionList).first();
if (!account_section_list)
throw new InnertubeError('Account section list not found');
this.contents = account_section_list.contents.first();
}
get page(): IParsedResponse {
return this.#page;
}
}