open static method

Future<AppStoreReads> open({
  1. required String bundleId,
  2. required AscPlatform platform,
})

Resolves bundleId and holds the session open.

Throws StateError when no credentials are configured, and AscApiException when Apple has no app with that exact bundle id.

Implementation

static Future<AppStoreReads> open({
  required String bundleId,
  required AscPlatform platform,
}) async {
  final credentials = AscCredentials.fromEnvironment();
  if (credentials == null) {
    throw StateError(
      'no App Store Connect credentials. APPLE_API_KEY_ID, '
      'APPLE_API_ISSUER_ID and APPLE_API_PRIVATE_KEY_PATH are not set in '
      'this process. Run it through `cux_ship secrets exec`, which writes '
      'the key file and sets all three, or export them yourself.',
    );
  }
  final client = AscClient(credentials);
  // **dryRun is not a mode here, it is the guarantee.** Every write in this
  // package goes through a [Writer], so a session whose writer refuses
  // cannot write however it is later extended.
  final store = AppStore(
    client,
    Writer(client, dryRun: true),
    platform: platform,
  );
  try {
    final app = await store.resolveApp(bundleId);
    return AppStoreReads._(client, store, app, platform);
  } on Object {
    client.close();
    rethrow;
  }
}