getDatabase method
Get database from the server.
Throws DaapImproperlyConfiguredException in case of calling without
supplied sessionId
before connect call.
Implementation
Future<DaapObject> getDatabase(int databaseId,
{int? sessionId,
List<String> metaCodes = databaseQueryDefaultMetaCodes}) async {
var url = _baseUrl;
if (sessionId != null) {
url = url.replace(
path: Interpolator(databaseUrlPath)(
{"databaseId": databaseId.toString()}),
queryParameters: {
"type": "music",
"session-id": sessionId.toString(),
"meta": getRequestMeta(metaCodes),
});
} else {
if (sessionInfo != null) {
return await getDatabase(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));
}