-
Notifications
You must be signed in to change notification settings - Fork 2
/
Category.ts
39 lines (31 loc) · 915 Bytes
/
Category.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
32
33
34
35
36
37
38
39
import { Image } from './Misc.js';
import BaseStructure from './BaseStructure.js';
import type Client from '../client/Client.js';
import type { CategoryObject, ImageObject } from 'spotify-api-types';
export default class Category extends BaseStructure {
/**
* A link to the Web API endpoint returning full details of the category
*/
href: string;
/**
* The category icons, in various sizes
*/
icons: Array<Image>;
/**
* The name of the category
*/
name: string;
constructor(client: Client, data: CategoryObject) {
super(client, data.id);
this.href = data.href;
this.icons = this._patchImages(data.icons);
this.name = data.name;
}
private _patchImages(data: Array<ImageObject>): Array<Image> {
const imagesArray: Array<Image> = [];
data.forEach(imageObject => {
imagesArray.push(new Image(imageObject));
});
return imagesArray;
}
}