-
Notifications
You must be signed in to change notification settings - Fork 37
/
basic.js
76 lines (65 loc) · 1.6 KB
/
basic.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Basic examples
* Test a lot of handlers that don't require user login.
*
*/
'use strict'
import Client from '../src/Client';
import TrackHandler from '../src/handlers/TrackHandler';
import PlaylistHandler from '../src/handlers/PlaylistHandler';
import ArtistHandler from '../src/handlers/ArtistHandler';
let client = Client.instance;
client.settings = {
clientId: 'CLIENT_ID',
secretId: 'SECRET_ID'
};
/*
* TrackHandler Examples
*
*/
var track = new TrackHandler();
/*
* #1 example
* Get tracks with the name 'R U mine?', should return a Collection of tracks.
*/
track.search('R U mine?', {limit: 5}).then((trackCollection) => {
console.log(trackCollection);
});
/*
* #2 example
* Get tracks by single Id, should return a Track entity with his helpers.
*/
track.get('2UzMpPKPhbcC8RbsmuURAZ').then((TrackEntity) => {
console.log(TrackEntity);
});
/*
* #3 example
* Get tracks by a list of Ids, should return a Collection.
*/
track.get(['4kTd0TND65MUY4BlcmJ2cM', '7iqTu4OPL3KYs4FMdtLZsy']).then((trackCollection) => {
console.log(trackCollection);
});
/*
* PlaylistHandler Examples
*
*/
var playlist = new PlaylistHandler();
/*
* #4 example
* Get playlists with the name 'Previon De Fiesta', should return a Collection of playlists.
*/
playlist.search('Previon De Fiesta').then((playlistCollection) => {
console.log(playlistCollection);
});
/*
* PlaylistHandler Examples
*
*/
var artist = new ArtistHandler();
/*
* #4 example
* Get artist with the name 'Muse', should return a Collection of artists.
*/
artist.search('Muse').then((artistCollection) => {
console.log(artistCollection);
});