getStatus static method
Returns each platform of project projectId that has a connected
store, in display order, with its most recent build. The builds are
only fetched when a store is connected.
Throws FailureException if the publishing setup or the builds cannot be fetched.
Implementation
static Future<List<AppStatusRow>> getStatus(
Client cloudApiClient, {
required String projectId,
}) async {
final AppPublishingSetup setup;
final List<AppBuildSummary> latestBuilds;
try {
setup = await cloudApiClient.appPublishing.getSetup(
cloudCapsuleId: projectId,
);
final hasConnectedStore =
setup.ios.store != null || setup.android.store != null;
latestBuilds = hasConnectedStore
? await cloudApiClient.appBuilds.getLatestBuilds(
cloudCapsuleId: projectId,
)
: const [];
} on AppPublishingDisabledException catch (e) {
throw FailureException(error: e.message);
} on NotFoundException catch (e) {
throw FailureException(error: e.message);
} on Exception catch (e, stackTrace) {
throw FailureException.nested(
e,
stackTrace,
'Failed to fetch the app status.',
);
}
final connectedPlatforms = [
if (setup.ios.store != null)
(platform: AppPlatform.ios, store: AppStore.appStore),
if (setup.android.store != null)
(platform: AppPlatform.android, store: AppStore.googlePlay),
];
return [
for (final (:platform, :store) in connectedPlatforms)
AppStatusRow(
platform: platform,
store: store,
latestBuild: latestBuilds
.where((build) => build.platform == platform)
.firstOrNull,
),
];
}