getBundle method
Future<BundleResponse?>
getBundle({
- required Credentials credentials,
- required BundleRequest request,
Implementation
Future<BundleResponse?> getBundle({
required Credentials credentials,
required BundleRequest request,
}) async {
try {
final otaResponse = await _otaClient.getBundle(
credentials: credentials,
request: request,
);
if (!otaResponse.isSuccess) {
throw otaResponse.httpCode == 404
? BundleNotFoundException()
: InternalException.fromOtaErrorResponse(param: otaResponse.error!);
}
final otaResult = otaResponse.result!;
if (otaResult.isEmpty) {
return null;
}
final downloaderResponse = await _downloaderClient.download(
resourceUrl: otaResult.url,
);
if (!downloaderResponse.isSuccess) {
throw InternalException.unexpected(
param: 'Unexpected bundle downloader error',
);
}
return BundleResponse(
bundle: downloaderResponse.result!,
version: otaResult.version,
);
} on ApiException catch (e) {
throw InternalException.fromApiException(param: e);
}
}