getPlaylists method

Future<DaapObject> getPlaylists(
  1. int databaseId, {
  2. int? sessionId,
  3. List<String> metaCodes = playlistsQueryDefaultMetaCodes,
})

Get database playlists from the server.

Throws DaapImproperlyConfiguredException in case of calling without supplied sessionId before connect call.

Implementation

Future<DaapObject> getPlaylists(int databaseId,
    {int? sessionId,
    List<String> metaCodes = playlistsQueryDefaultMetaCodes}) async {
  var url = _baseUrl;
  if (sessionId != null) {
    url = url.replace(
        path: Interpolator(playlistsUrlPath)(
            {"databaseId": databaseId.toString()}),
        queryParameters: {
          "session-id": sessionId.toString(),
          "meta": getRequestMeta(metaCodes),
        });
  } else {
    if (sessionInfo != null) {
      return await getPlaylists(databaseId,
          sessionId: sessionInfo!.getAtom(dmapCodeDmapSessionId),
          metaCodes: metaCodes);
    } else {
      throw DaapImproperlyConfiguredException(
          // ignore: lines_longer_than_80_chars
          "Can't get 'sessionId' from 'sessionInfo'. First, try to connect to the server.");
    }
  }
  return DaapObject(await request(url));
}