setBetaBuildLocalization method

  1. @override
Future<void> setBetaBuildLocalization({
  1. required String buildId,
  2. required String locale,
  3. required String whatsNew,
})
override

Creates or updates localized TestFlight "What to Test" text.

Implementation

@override
Future<void> setBetaBuildLocalization({
  required String buildId,
  required String locale,
  required String whatsNew,
}) async {
  final localizations = await _collection(
    '/v1/builds/$buildId/betaBuildLocalizations?limit=200',
  );
  final existing = localizations
      .map(_genericResource)
      .where(
        (item) => item.attributes['locale'] == locale,
      )
      .firstOrNull;
  if (existing != null) {
    await _request(
      'PATCH',
      '/v1/betaBuildLocalizations/${existing.id}',
      body: <String, Object?>{
        'data': <String, Object?>{
          'type': 'betaBuildLocalizations',
          'id': existing.id,
          'attributes': <String, Object?>{'whatsNew': whatsNew},
        },
      },
    );
  } else {
    await _request(
      'POST',
      '/v1/betaBuildLocalizations',
      body: <String, Object?>{
        'data': <String, Object?>{
          'type': 'betaBuildLocalizations',
          'attributes': <String, Object?>{
            'locale': locale,
            'whatsNew': whatsNew,
          },
          'relationships': <String, Object?>{
            'build': <String, Object?>{
              'data': <String, Object?>{'type': 'builds', 'id': buildId},
            },
          },
        },
      },
    );
  }
}