UNPKG

@kkboxorg/kkbox-javascript-developer-sdk

Version:

KKBOX Open API developer SDK for JavaScript. Use it to easily access KKBOX open API to get various metadata about KKBOX's tracks, albums, artists, playlists and stations.

1,578 lines 135 kB
[ { "__docId__": 0, "kind": "file", "name": "src/Endpoint.js", "content": "const API_DOMAIN = (() => {\n return process.env.NODE_ENV === 'staging' ? 'https://api.kkbox-staging.com/v1.1/' : 'https://api.kkbox.com/v1.1/'\n})()\n/**\n * @ignore\n */\nexport const SEARCH = API_DOMAIN + 'search/'\n\n/**\n * @ignore\n */\nexport const TRACKS = API_DOMAIN + 'tracks/'\n\n/**\n * @ignore\n */\nexport const ARTISTS = API_DOMAIN + 'artists/'\n\n/**\n * @ignore\n */\nexport const ALBUMS = API_DOMAIN + 'albums/'\n\n/**\n * @ignore\n */\nexport const SHARED_PLAYLISTS = API_DOMAIN + 'shared-playlists/'\n\n/**\n * @ignore\n */\nexport const MOOD_STATIONS = API_DOMAIN + 'mood-stations/'\n\n/**\n * @ignore\n */\nexport const FEATURED_PLAYLISTS = API_DOMAIN + 'featured-playlists/'\n\n/**\n * @ignore\n */\nexport const FEATURED_PLAYLISTS_CATEGORIES = API_DOMAIN + 'featured-playlist-categories/'\n\n/**\n * @ignore\n */\nexport const GENRE_STATIONS = API_DOMAIN + 'genre-stations/'\n\n/**\n * @ignore\n */\nexport const SEARCH_TYPES = {\n ARTIST: 'artist',\n ALBUM: 'album',\n TRACK: 'track',\n PLAY_LIST: 'playlist'\n}\n\nconst OAuth_DOMAIN = 'https://account.kkbox.com/oauth2/'\n\n/**\n * @ignore\n */\nexport const Token = OAuth_DOMAIN + 'token/'\n\n/**\n * @ignore\n */\nexport const TokenInfo = OAuth_DOMAIN + 'tokeninfo/'\n\n/**\n * @ignore\n */\nexport const Authorization = OAuth_DOMAIN + 'authorize/'", "static": true, "longname": "src/Endpoint.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 1, "kind": "variable", "name": "API_DOMAIN", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~API_DOMAIN", "access": null, "export": false, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": null, "description": null, "lineNumber": 1, "undocument": true, "unknown": [ { "tagName": "@_undocument", "tagValue": "" } ], "type": { "types": [ "*" ] } }, { "__docId__": 2, "kind": "variable", "name": "SEARCH", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~SEARCH", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{SEARCH}", "description": "", "lineNumber": 7, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 3, "kind": "variable", "name": "TRACKS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~TRACKS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{TRACKS}", "description": "", "lineNumber": 12, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 4, "kind": "variable", "name": "ARTISTS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~ARTISTS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{ARTISTS}", "description": "", "lineNumber": 17, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 5, "kind": "variable", "name": "ALBUMS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~ALBUMS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{ALBUMS}", "description": "", "lineNumber": 22, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 6, "kind": "variable", "name": "SHARED_PLAYLISTS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~SHARED_PLAYLISTS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{SHARED_PLAYLISTS}", "description": "", "lineNumber": 27, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 7, "kind": "variable", "name": "MOOD_STATIONS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~MOOD_STATIONS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{MOOD_STATIONS}", "description": "", "lineNumber": 32, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 8, "kind": "variable", "name": "FEATURED_PLAYLISTS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~FEATURED_PLAYLISTS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{FEATURED_PLAYLISTS}", "description": "", "lineNumber": 37, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 9, "kind": "variable", "name": "FEATURED_PLAYLISTS_CATEGORIES", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~FEATURED_PLAYLISTS_CATEGORIES", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{FEATURED_PLAYLISTS_CATEGORIES}", "description": "", "lineNumber": 42, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 10, "kind": "variable", "name": "GENRE_STATIONS", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~GENRE_STATIONS", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{GENRE_STATIONS}", "description": "", "lineNumber": 47, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 11, "kind": "variable", "name": "SEARCH_TYPES", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~SEARCH_TYPES", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{SEARCH_TYPES}", "description": "", "lineNumber": 52, "ignore": true, "type": { "types": [ "{\"ARTIST\": string, \"ALBUM\": string, \"TRACK\": string, \"PLAY_LIST\": string}" ] } }, { "__docId__": 12, "kind": "variable", "name": "OAuth_DOMAIN", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~OAuth_DOMAIN", "access": null, "export": false, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": null, "description": null, "lineNumber": 59, "undocument": true, "unknown": [ { "tagName": "@_undocument", "tagValue": "" } ], "type": { "types": [ "string" ] } }, { "__docId__": 13, "kind": "variable", "name": "Token", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~Token", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{Token}", "description": "", "lineNumber": 64, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 14, "kind": "variable", "name": "TokenInfo", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~TokenInfo", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{TokenInfo}", "description": "", "lineNumber": 69, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 15, "kind": "variable", "name": "Authorization", "memberof": "src/Endpoint.js", "static": true, "longname": "src/Endpoint.js~Authorization", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/Endpoint.js", "importStyle": "{Authorization}", "description": "", "lineNumber": 74, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 16, "kind": "file", "name": "src/SDK.js", "content": "export {default as Auth} from './auth/Auth'\nexport {default as Api} from './api/Api'", "static": true, "longname": "src/SDK.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 17, "kind": "file", "name": "src/api/AlbumFetcher.js", "content": "import {ALBUMS as ENDPOINT} from '../Endpoint'\nimport Fetcher from './Fetcher'\n\n/**\n * Fetch metadata and tracks of a album.\n * @see https://docs.kkbox.codes/docs/albums\n */\nexport default class AlbumFetcher extends Fetcher { \n /**\n * @ignore\n */\n constructor(http, territory = 'TW') {\n super(http, territory)\n\n /**\n * @ignore\n */\n this.album_id = undefined\n }\n\n /**\n * Set the album fetcher.\n *\n * @param {string} album_id - The ID of an album.\n * @return {AlbumFetcher}\n * @see https://docs.kkbox.codes/docs/albums\n */\n setAlbumID(album_id) {\n this.album_id = album_id \n return this\n }\n\n /**\n * Fetcy metadata of the album you create.\n *\n * @return {Promise}\n * @example api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchMetadata()\n */\n fetchMetadata() {\n return this.http.get(ENDPOINT + this.album_id, {territory: this.territory})\n }\n\n /**\n * Get KKBOX web widget uri of the album.\n * @example https://widget.kkbox.com/v1/?id=4qtXcj31wYJTRZbb23&type=album\n * @return {string}\n */\n getWidgetUri(){\n return `https://widget.kkbox.com/v1/?id=${this.album_id}&type=album`\n }\n\n /**\n * Get tracks in an album. Result will be return with pagination.\n *\n * @param {number} [limit] - The size for one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks()\n * @see https://docs.kkbox.codes/docs/albums-tracks\n */\n fetchTracks(limit = undefined, offset = undefined) {\n return this.http.get(ENDPOINT + this.album_id + '/tracks', {\n territory: this.territory,\n limit: limit,\n offset: offset\n })\n }\n}", "static": true, "longname": "src/api/AlbumFetcher.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 18, "kind": "class", "name": "AlbumFetcher", "memberof": "src/api/AlbumFetcher.js", "static": true, "longname": "src/api/AlbumFetcher.js~AlbumFetcher", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/AlbumFetcher.js", "importStyle": "AlbumFetcher", "description": "Fetch metadata and tracks of a album.", "see": [ "https://docs.kkbox.codes/docs/albums" ], "lineNumber": 8, "interface": false, "extends": [ "src/api/Fetcher.js~Fetcher" ] }, { "__docId__": 19, "kind": "constructor", "name": "constructor", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#constructor", "access": null, "description": "", "lineNumber": 12, "ignore": true, "params": [ { "name": "http", "types": [ "*" ] }, { "name": "territory", "optional": true, "types": [ "string" ], "defaultRaw": "TW", "defaultValue": "TW" } ] }, { "__docId__": 20, "kind": "member", "name": "album_id", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#album_id", "access": null, "description": "", "lineNumber": 18, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 21, "kind": "method", "name": "setAlbumID", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#setAlbumID", "access": null, "description": "Set the album fetcher.", "see": [ "https://docs.kkbox.codes/docs/albums" ], "lineNumber": 28, "params": [ { "nullable": null, "types": [ "string" ], "spread": false, "optional": false, "name": "album_id", "description": "The ID of an album." } ], "return": { "nullable": null, "types": [ "AlbumFetcher" ], "spread": false, "description": "" } }, { "__docId__": 22, "kind": "member", "name": "album_id", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#album_id", "access": null, "description": null, "lineNumber": 29, "undocument": true, "unknown": [ { "tagName": "@_undocument", "tagValue": "" } ], "type": { "types": [ "*" ] } }, { "__docId__": 23, "kind": "method", "name": "fetchMetadata", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#fetchMetadata", "access": null, "description": "Fetcy metadata of the album you create.", "examples": [ "api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchMetadata()" ], "lineNumber": 39, "params": [], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 24, "kind": "method", "name": "getWidgetUri", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#getWidgetUri", "access": null, "description": "Get KKBOX web widget uri of the album.", "examples": [ "https://widget.kkbox.com/v1/?id=4qtXcj31wYJTRZbb23&type=album" ], "lineNumber": 48, "params": [], "return": { "nullable": null, "types": [ "string" ], "spread": false, "description": "" } }, { "__docId__": 25, "kind": "method", "name": "fetchTracks", "memberof": "src/api/AlbumFetcher.js~AlbumFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/AlbumFetcher.js~AlbumFetcher#fetchTracks", "access": null, "description": "Get tracks in an album. Result will be return with pagination.", "examples": [ "api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks()" ], "see": [ "https://docs.kkbox.codes/docs/albums-tracks" ], "lineNumber": 61, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "limit", "description": "The size for one page." }, { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "offset", "description": "The offset index for first element." } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 26, "kind": "file", "name": "src/api/Api.js", "content": "import HttpClient from './HttpClient'\nimport SearchFetcher from './SearchFetcher'\nimport TrackFetcher from './TrackFetcher'\nimport AlbumFetcher from './AlbumFetcher'\nimport ArtistFetcher from './ArtistFetcher'\nimport FeaturedPlaylistFetcher from './FeaturedPlaylistFetcher'\nimport FeaturedPlaylistCategoryFetcher from './FeaturedPlaylistCategoryFetcher'\nimport GenreStationFetcher from './GenreStationFetcher'\nimport MoodStationFetcher from './MoodStationFetcher'\n\n/**\n * Fetch KKBOX resources.\n */\nexport default class Api {\n /**\n * Need access token to initialize.\n *\n * @param {string} token - Get via Auth.\n * @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory for the fetcher.\n * @example new Api(token)\n * @example new Api(token, 'TW')\n */\n constructor(token, territory = 'TW') {\n const http = new HttpClient(token)\n\n /**\n * @type {SearchFetcher}\n */\n this.searchFetcher = new SearchFetcher(http, territory)\n\n /**\n * @type {TrackFetcher}\n */\n this.trackFetcher = new TrackFetcher(http, territory)\n\n /**\n * @type {AlbumFetcher}\n */\n this.albumFetcher = new AlbumFetcher(http, territory)\n\n /**\n * @type {ArtistFetcher}\n */\n this.artistFetcher = new ArtistFetcher(http, territory)\n\n /**\n * @type {FeaturedPlaylistFetcher}\n */\n this.featuredPlaylistFetcher = new FeaturedPlaylistFetcher(http, territory)\n\n /**\n * @type {FeaturedPlaylistCategoryFetcher}\n */\n this.featuredPlaylistCategoryFetcher = new FeaturedPlaylistCategoryFetcher(http, territory)\n\n /**\n * @type {GenreStationFetcher}\n */\n this.genreStationFetcher = new GenreStationFetcher(http, territory)\n\n /**\n * @type {MoodStationFetcher}\n */\n this.moodStationFetcher = new MoodStationFetcher(http, territory)\n }\n}", "static": true, "longname": "src/api/Api.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 27, "kind": "class", "name": "Api", "memberof": "src/api/Api.js", "static": true, "longname": "src/api/Api.js~Api", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/Api.js", "importStyle": "Api", "description": "Fetch KKBOX resources.", "lineNumber": 14, "interface": false }, { "__docId__": 28, "kind": "constructor", "name": "constructor", "memberof": "src/api/Api.js~Api", "generator": false, "async": false, "static": false, "longname": "src/api/Api.js~Api#constructor", "access": null, "description": "Need access token to initialize.", "examples": [ "new Api(token)", "new Api(token, 'TW')" ], "lineNumber": 23, "params": [ { "nullable": null, "types": [ "string" ], "spread": false, "optional": false, "name": "token", "description": "Get via Auth." }, { "nullable": null, "types": [ "string" ], "spread": false, "optional": true, "defaultValue": " 'TW'", "defaultRaw": " 'TW'", "name": "territory", "description": "['TW', 'HK', 'SG', 'MY', 'JP'] The territory for the fetcher." } ] }, { "__docId__": 29, "kind": "member", "name": "searchFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#searchFetcher", "access": null, "description": "", "lineNumber": 29, "type": { "nullable": null, "types": [ "SearchFetcher" ], "spread": false, "description": null } }, { "__docId__": 30, "kind": "member", "name": "trackFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#trackFetcher", "access": null, "description": "", "lineNumber": 34, "type": { "nullable": null, "types": [ "TrackFetcher" ], "spread": false, "description": null } }, { "__docId__": 31, "kind": "member", "name": "albumFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#albumFetcher", "access": null, "description": "", "lineNumber": 39, "type": { "nullable": null, "types": [ "AlbumFetcher" ], "spread": false, "description": null } }, { "__docId__": 32, "kind": "member", "name": "artistFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#artistFetcher", "access": null, "description": "", "lineNumber": 44, "type": { "nullable": null, "types": [ "ArtistFetcher" ], "spread": false, "description": null } }, { "__docId__": 33, "kind": "member", "name": "featuredPlaylistFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#featuredPlaylistFetcher", "access": null, "description": "", "lineNumber": 49, "type": { "nullable": null, "types": [ "FeaturedPlaylistFetcher" ], "spread": false, "description": null } }, { "__docId__": 34, "kind": "member", "name": "featuredPlaylistCategoryFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#featuredPlaylistCategoryFetcher", "access": null, "description": "", "lineNumber": 54, "type": { "nullable": null, "types": [ "FeaturedPlaylistCategoryFetcher" ], "spread": false, "description": null } }, { "__docId__": 35, "kind": "member", "name": "genreStationFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#genreStationFetcher", "access": null, "description": "", "lineNumber": 59, "type": { "nullable": null, "types": [ "GenreStationFetcher" ], "spread": false, "description": null } }, { "__docId__": 36, "kind": "member", "name": "moodStationFetcher", "memberof": "src/api/Api.js~Api", "static": false, "longname": "src/api/Api.js~Api#moodStationFetcher", "access": null, "description": "", "lineNumber": 64, "type": { "nullable": null, "types": [ "MoodStationFetcher" ], "spread": false, "description": null } }, { "__docId__": 37, "kind": "file", "name": "src/api/ArtistFetcher.js", "content": "import {ARTISTS as ENDPOINT} from '../Endpoint'\nimport Fetcher from './Fetcher'\n\n/**\n * Get artist metadata.\n * @see https://docs.kkbox.codes/docs/artists\n */\nexport default class ArtistFetcher extends Fetcher {\n /**\n * @ignore\n */\n constructor(http, territory = 'TW') {\n super(http, territory)\n\n /**\n * @ignore\n */\n this.artist_id = undefined\n }\n\n /**\n * Init the artist object.\n *\n * @param {string} artist_id - The ID of an artist.\n * @return {Artist}\n * @see https://docs.kkbox.codes/docs/artists\n */\n setArtistID(artist_id) {\n this.artist_id = artist_id\n return this\n }\n\n /**\n * Fetch metadata of the artist you find.\n *\n * @return {Promise}\n * @example api.Artist.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchMetadata()\n */\n fetchMetadata() {\n return this.http.get(ENDPOINT + this.artist_id, {territory: this.territory})\n }\n\n /**\n * Fetch albums belong to an artist.\n *\n * @param {number} [limit] - The size for one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchAlbums()\n * @see https://docs.kkbox.codes/docs/artists-albums\n */\n fetchAlbums(limit = undefined, offset = undefined) {\n return this.http.get(ENDPOINT + this.artist_id + '/albums', {\n territory: this.territory,\n limit: limit,\n offset: offset\n })\n }\n\n /**\n * Fetch top tracks belong to an artist.\n *\n * @param {number} [limit] - The size for one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.Artist.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchTopTracks()\n * @see https://docs.kkbox.codes/docs/artists-top-tracks\n */\n fetchTopTracks(limit = undefined, offset = undefined) {\n return this.http.get(ENDPOINT + this.artist_id + '/top-tracks', {\n territory: this.territory,\n limit: limit,\n offset: offset\n })\n }\n}", "static": true, "longname": "src/api/ArtistFetcher.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 38, "kind": "class", "name": "ArtistFetcher", "memberof": "src/api/ArtistFetcher.js", "static": true, "longname": "src/api/ArtistFetcher.js~ArtistFetcher", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/ArtistFetcher.js", "importStyle": "ArtistFetcher", "description": "Get artist metadata.", "see": [ "https://docs.kkbox.codes/docs/artists" ], "lineNumber": 8, "interface": false, "extends": [ "src/api/Fetcher.js~Fetcher" ] }, { "__docId__": 39, "kind": "constructor", "name": "constructor", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#constructor", "access": null, "description": "", "lineNumber": 12, "ignore": true, "params": [ { "name": "http", "types": [ "*" ] }, { "name": "territory", "optional": true, "types": [ "string" ], "defaultRaw": "TW", "defaultValue": "TW" } ] }, { "__docId__": 40, "kind": "member", "name": "artist_id", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#artist_id", "access": null, "description": "", "lineNumber": 18, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 41, "kind": "method", "name": "setArtistID", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#setArtistID", "access": null, "description": "Init the artist object.", "see": [ "https://docs.kkbox.codes/docs/artists" ], "lineNumber": 28, "params": [ { "nullable": null, "types": [ "string" ], "spread": false, "optional": false, "name": "artist_id", "description": "The ID of an artist." } ], "return": { "nullable": null, "types": [ "Artist" ], "spread": false, "description": "" } }, { "__docId__": 42, "kind": "member", "name": "artist_id", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#artist_id", "access": null, "description": null, "lineNumber": 29, "undocument": true, "unknown": [ { "tagName": "@_undocument", "tagValue": "" } ], "type": { "types": [ "*" ] } }, { "__docId__": 43, "kind": "method", "name": "fetchMetadata", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#fetchMetadata", "access": null, "description": "Fetch metadata of the artist you find.", "examples": [ "api.Artist.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchMetadata()" ], "lineNumber": 39, "params": [], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 44, "kind": "method", "name": "fetchAlbums", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#fetchAlbums", "access": null, "description": "Fetch albums belong to an artist.", "examples": [ "api.artistFetcher.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchAlbums()" ], "see": [ "https://docs.kkbox.codes/docs/artists-albums" ], "lineNumber": 52, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "limit", "description": "The size for one page." }, { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "offset", "description": "The offset index for first element." } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 45, "kind": "method", "name": "fetchTopTracks", "memberof": "src/api/ArtistFetcher.js~ArtistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/ArtistFetcher.js~ArtistFetcher#fetchTopTracks", "access": null, "description": "Fetch top tracks belong to an artist.", "examples": [ "api.Artist.setArtistID('Cnv_K6i5Ft4y41SxLy').fetchTopTracks()" ], "see": [ "https://docs.kkbox.codes/docs/artists-top-tracks" ], "lineNumber": 69, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "limit", "description": "The size for one page." }, { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "offset", "description": "The offset index for first element." } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 46, "kind": "file", "name": "src/api/FeaturedPlaylistCategoryFetcher.js", "content": "import {FEATURED_PLAYLISTS_CATEGORIES as ENDPOINT} from '../Endpoint'\nimport Fetcher from './Fetcher'\n\n/**\n * List featured playlist categories.\n * @see https://docs.kkbox.codes/docs/featured-playlist-categories\n */\nexport default class FeaturedPlaylistCategoryFetcher extends Fetcher {\n /**\n * @ignore\n */\n constructor(http, territory = 'TW') {\n super(http, territory)\n\n /**\n * @ignore\n */\n this.category_id = undefined\n }\n\n /**\n * Fetch all featured playlist categories.\n *\n * @return {Promise}\n * @example api.FeaturedPlaylistCategory.fetchAllFeaturedPlaylistCategories()\n * @see https://docs.kkbox.codes/docs/featured-playlist-categories\n */\n fetchAllFeaturedPlaylistCategories() {\n return this.http.get(ENDPOINT, {territory: this.territory})\n }\n\n /**\n * Init the featured playlist category fetcher.\n *\n * @param {string} category_id - The category ID.\n * @return {FeaturedPlaylistCategory}\n * @see https://docs.kkbox.codes/docs/feature-playlist-category\n */\n setCategoryID(category_id) {\n this.category_id = category_id \n return this\n }\n\n /**\n * Fetch metadata of the category you init.\n *\n * @return {Promise}\n * @example api.FeaturedPlaylistCategory.setCategoryID('LXUR688EBKRRZydAWb').fetchMetadata()\n */\n fetchMetadata() {\n return this.http.get(ENDPOINT + this.category_id, {territory: this.territory})\n }\n\n /**\n * Fetch featured playlists of the category with the category fetcher you init. Result will be paged.\n *\n * @param {number} [limit] - The size of one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.FeaturedPlaylistCategory.setCategoryID('LXUR688EBKRRZydAWb').fetchPlaylists()\n * @see https://docs.kkbox.codes/docs/featured-playlist-categoriescategoriesplaylists\n */\n fetchPlaylists(limit = undefined, offset = undefined) {\n return this.http.get(ENDPOINT + this.category_id + '/playlists', {\n territory: this.territory,\n limit: limit,\n offset: offset\n })\n }\n}", "static": true, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 47, "kind": "class", "name": "FeaturedPlaylistCategoryFetcher", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js", "static": true, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/FeaturedPlaylistCategoryFetcher.js", "importStyle": "FeaturedPlaylistCategoryFetcher", "description": "List featured playlist categories.", "see": [ "https://docs.kkbox.codes/docs/featured-playlist-categories" ], "lineNumber": 8, "interface": false, "extends": [ "src/api/Fetcher.js~Fetcher" ] }, { "__docId__": 48, "kind": "constructor", "name": "constructor", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#constructor", "access": null, "description": "", "lineNumber": 12, "ignore": true, "params": [ { "name": "http", "types": [ "*" ] }, { "name": "territory", "optional": true, "types": [ "string" ], "defaultRaw": "TW", "defaultValue": "TW" } ] }, { "__docId__": 49, "kind": "member", "name": "category_id", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#category_id", "access": null, "description": "", "lineNumber": 18, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 50, "kind": "method", "name": "fetchAllFeaturedPlaylistCategories", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#fetchAllFeaturedPlaylistCategories", "access": null, "description": "Fetch all featured playlist categories.", "examples": [ "api.FeaturedPlaylistCategory.fetchAllFeaturedPlaylistCategories()" ], "see": [ "https://docs.kkbox.codes/docs/featured-playlist-categories" ], "lineNumber": 28, "params": [], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 51, "kind": "method", "name": "setCategoryID", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#setCategoryID", "access": null, "description": "Init the featured playlist category fetcher.", "see": [ "https://docs.kkbox.codes/docs/feature-playlist-category" ], "lineNumber": 39, "params": [ { "nullable": null, "types": [ "string" ], "spread": false, "optional": false, "name": "category_id", "description": "The category ID." } ], "return": { "nullable": null, "types": [ "FeaturedPlaylistCategory" ], "spread": false, "description": "" } }, { "__docId__": 52, "kind": "member", "name": "category_id", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#category_id", "access": null, "description": null, "lineNumber": 40, "undocument": true, "unknown": [ { "tagName": "@_undocument", "tagValue": "" } ], "type": { "types": [ "*" ] } }, { "__docId__": 53, "kind": "method", "name": "fetchMetadata", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#fetchMetadata", "access": null, "description": "Fetch metadata of the category you init.", "examples": [ "api.FeaturedPlaylistCategory.setCategoryID('LXUR688EBKRRZydAWb').fetchMetadata()" ], "lineNumber": 50, "params": [], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 54, "kind": "method", "name": "fetchPlaylists", "memberof": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistCategoryFetcher.js~FeaturedPlaylistCategoryFetcher#fetchPlaylists", "access": null, "description": "Fetch featured playlists of the category with the category fetcher you init. Result will be paged.", "examples": [ "api.FeaturedPlaylistCategory.setCategoryID('LXUR688EBKRRZydAWb').fetchPlaylists()" ], "see": [ "https://docs.kkbox.codes/docs/featured-playlist-categoriescategoriesplaylists" ], "lineNumber": 63, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "limit", "description": "The size of one page." }, { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "offset", "description": "The offset index for first element." } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 55, "kind": "file", "name": "src/api/FeaturedPlaylistFetcher.js", "content": "import {FEATURED_PLAYLISTS as ENDPOINT} from '../Endpoint'\nimport Fetcher from './Fetcher'\n\n/**\n * List all featured playlists.\n * @see https://docs.kkbox.codes/docs/featured-playlists\n */\nexport default class FeaturedPlaylistFetcher extends Fetcher {\n /**\n * @ignore\n */\n constructor(http, territory = 'TW') {\n super(http, territory)\n }\n\n /**\n * Fetch all featured playlists. Result will be paged.\n *\n * @param {number} [limit] - The size for one page.\n * @param {number} [offset] - The offset index for first element.\n * @return {Promise}\n * @example api.FeaturedPlaylist.fetchAllFeaturedPlaylists()\n */\n fetchAllFeaturedPlaylists(limit = undefined, offset = undefined) {\n return this.http.get(ENDPOINT, {\n limit: limit, \n offset: offset, \n territory: this.territory\n })\n }\n}", "static": true, "longname": "src/api/FeaturedPlaylistFetcher.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 56, "kind": "class", "name": "FeaturedPlaylistFetcher", "memberof": "src/api/FeaturedPlaylistFetcher.js", "static": true, "longname": "src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/FeaturedPlaylistFetcher.js", "importStyle": "FeaturedPlaylistFetcher", "description": "List all featured playlists.", "see": [ "https://docs.kkbox.codes/docs/featured-playlists" ], "lineNumber": 8, "interface": false, "extends": [ "src/api/Fetcher.js~Fetcher" ] }, { "__docId__": 57, "kind": "constructor", "name": "constructor", "memberof": "src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher#constructor", "access": null, "description": "", "lineNumber": 12, "ignore": true, "params": [ { "name": "http", "types": [ "*" ] }, { "name": "territory", "optional": true, "types": [ "string" ], "defaultRaw": "TW", "defaultValue": "TW" } ] }, { "__docId__": 58, "kind": "method", "name": "fetchAllFeaturedPlaylists", "memberof": "src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher", "generator": false, "async": false, "static": false, "longname": "src/api/FeaturedPlaylistFetcher.js~FeaturedPlaylistFetcher#fetchAllFeaturedPlaylists", "access": null, "description": "Fetch all featured playlists. Result will be paged.", "examples": [ "api.FeaturedPlaylist.fetchAllFeaturedPlaylists()" ], "lineNumber": 24, "params": [ { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "limit", "description": "The size for one page." }, { "nullable": null, "types": [ "number" ], "spread": false, "optional": true, "name": "offset", "description": "The offset index for first element." } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 59, "kind": "file", "name": "src/api/Fetcher.js", "content": "/**\n * Base api fetcher.\n */\nexport default class Fetcher {\n /** \n * @param {Http} http \n * @param {string} [territory = 'TW'] - ['TW', 'HK', 'SG', 'MY', 'JP'] The territory for the fetcher.\n */\n constructor(http, territory = 'TW') {\n /**\n * @ignore\n */\n this.http = http\n\n /**\n * @ignore\n */\n this.territory = territory\n }\n\n /**\n * Fetches next page of various paged API.\n * @param {fulfillment} fulfillment - The fulfillment get from Promose's onFulfillment function \n * @return {Promise}\n * @example \n * api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks().then(response => {\n * api.albumFetcher.fetchNextPage(response))\n * })\n */\n fetchNextPage(fulfillment) {\n var nextUri = fulfillment.data.paging.next\n if (nextUri != null && nextUri !== undefined) {\n return this.http.get(nextUri)\n }\n else {\n return new Promise((resolve, reject) => {\n reject('Cannot fetch next page')\n }) \n }\n }\n\n /**\n * Is next page available for various paged API.\n * @param {fulfillment} fulfillment - The fulfillment get from Promose's onFulfillment function \n * @return {Boolean}\n * @example\n * api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks().then(response => {\n * if (api.albumFetcher.hasNextPage(response)) {\n * // more data available\n * }\n * })\n */\n hasNextPage(fulfillment) {\n var nextUri = fulfillment.data.paging.next\n if (nextUri != null && nextUri !== undefined) {\n return true\n }\n else {\n return false\n }\n }\n}", "static": true, "longname": "src/api/Fetcher.js", "access": null, "description": null, "lineNumber": 1 }, { "__docId__": 60, "kind": "class", "name": "Fetcher", "memberof": "src/api/Fetcher.js", "static": true, "longname": "src/api/Fetcher.js~Fetcher", "access": null, "export": true, "importPath": "kkbox-javascript-developer-sdk/src/api/Fetcher.js", "importStyle": "Fetcher", "description": "Base api fetcher.", "lineNumber": 4, "interface": false }, { "__docId__": 61, "kind": "constructor", "name": "constructor", "memberof": "src/api/Fetcher.js~Fetcher", "generator": false, "async": false, "static": false, "longname": "src/api/Fetcher.js~Fetcher#constructor", "access": null, "description": " ", "lineNumber": 9, "params": [ { "nullable": null, "types": [ "Http" ], "spread": false, "optional": false, "name": "http", "description": "" }, { "nullable": null, "types": [ "string" ], "spread": false, "optional": true, "defaultValue": " 'TW'", "defaultRaw": " 'TW'", "name": "territory", "description": "['TW', 'HK', 'SG', 'MY', 'JP'] The territory for the fetcher." } ] }, { "__docId__": 62, "kind": "member", "name": "http", "memberof": "src/api/Fetcher.js~Fetcher", "static": false, "longname": "src/api/Fetcher.js~Fetcher#http", "access": null, "description": "", "lineNumber": 13, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 63, "kind": "member", "name": "territory", "memberof": "src/api/Fetcher.js~Fetcher", "static": false, "longname": "src/api/Fetcher.js~Fetcher#territory", "access": null, "description": "", "lineNumber": 18, "ignore": true, "type": { "types": [ "*" ] } }, { "__docId__": 64, "kind": "method", "name": "fetchNextPage", "memberof": "src/api/Fetcher.js~Fetcher", "generator": false, "async": false, "static": false, "longname": "src/api/Fetcher.js~Fetcher#fetchNextPage", "access": null, "description": "Fetches next page of various paged API.", "examples": [ "api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks().then(response => {\n api.albumFetcher.fetchNextPage(response))\n})" ], "lineNumber": 30, "params": [ { "nullable": null, "types": [ "fulfillment" ], "spread": false, "optional": false, "name": "fulfillment", "description": "The fulfillment get from Promose's onFulfillment function" } ], "return": { "nullable": null, "types": [ "Promise" ], "spread": false, "description": "" } }, { "__docId__": 65, "kind": "method", "name": "hasNextPage", "memberof": "src/api/Fetcher.js~Fetcher", "generator": false, "async": false, "static": false, "longname": "src/api/Fetcher.js~Fetcher#hasNextPage", "access": null, "description": "Is next page available for various paged API.", "examples": [ "api.albumFetcher.setAlbumID('KmRKnW5qmUrTnGRuxF').fetchTracks().then(response => {\n if (api.albumFetcher.hasNextPage(response)) {\n // more data available\n }\n})" ], "lineNumber": 53, "params": [ { "nullable": null, "types": [ "fulfillment" ], "spread": false, "optional": false, "name": "fulfillment", "description": "The fulfillment get from Promose's onFulfillment function" } ], "return": { "nullable": null, "types": [ "Boolean" ], "spread": false, "description": "" } }, { "__docId__": 66, "kind": "file", "name": "src/api/GenreStationFetcher.js", "content": "im