forked from KKBOX/OpenAPI-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMoodStationFetcher.js
More file actions
60 lines (55 loc) · 1.53 KB
/
Copy pathMoodStationFetcher.js
File metadata and controls
60 lines (55 loc) · 1.53 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { MOOD_STATIONS as ENDPOINT } from '../Endpoint';
import Fetcher from './Fetcher';
/**
* Get mood stations.
* @see https://docs-en.kkbox.codes/v1.1/reference#mood-stations
*/
export default class MoodStationFetcher extends Fetcher {
/**
* @ignore
*/
constructor(http, territory = 'TW') {
super(http, territory);
/**
* @ignore
*/
this.moodStationID = undefined;
}
/**
* Fetch all mood stations.
*
* @return {Promise}
* @example api.moodStationFetcher.fetchAllMoodStations();
* @see https://docs-en.kkbox.codes/v1.1/reference#moodstations
*/
fetchAllMoodStations() {
return this.http.get(ENDPOINT, {
territory: this.territory
});
}
/**
* Init the mood station fetcher.
*
* @param {string} moodStationID - The ID of a mood station.
* @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory of a mood station.
* @return {MoodStation}
* @see https://docs-en.kkbox.codes/v1.1/reference#moodstations-station_id
*/
setMoodStationID(moodStationID, territory = 'TW') {
this.moodStationID = moodStationID;
this.territory = territory;
return this;
}
/**
* Fetch the mood station's metadata.
*
* @return {Promise}
* @example api.moodStationFetcher.setMoodStationID('StGZp2ToWq92diPHS7').fetchMetadata();
* @see https://docs-en.kkbox.codes/v1.1/reference#moodstations-station_id
*/
fetchMetadata() {
return this.http.get(ENDPOINT + '/' + this.moodStationID, {
territory: this.territory
});
}
}