import 'package:social_app/core/api/i_api_client.dart'; class AppVersionResponse { final bool hasUpdate; final String latestVersion; final int latestBuild; final String minRequiredVersion; final String updateType; final String? downloadUrl; final String? releaseNotes; AppVersionResponse({ required this.hasUpdate, required this.latestVersion, required this.latestBuild, required this.minRequiredVersion, required this.updateType, this.downloadUrl, this.releaseNotes, }); factory AppVersionResponse.fromJson(Map json) { return AppVersionResponse( hasUpdate: json['has_update'] as bool, latestVersion: json['latest_version'] as String, latestBuild: json['latest_build'] as int, minRequiredVersion: json['min_required_version'] as String, updateType: json['update_type'] as String, downloadUrl: json['download_url'] as String?, releaseNotes: json['release_notes'] as String?, ); } } class SettingsApi { final IApiClient _client; static const _prefix = '/api/v1/app'; SettingsApi(this._client); Future checkUpdates({ required int currentBuild, String? currentVersion, String platform = 'android', }) async { final params = { 'platform': platform, 'current_build': currentBuild.toString(), }; if (currentVersion != null) { params['current_version'] = currentVersion; } final queryString = params.entries .map((e) => '${e.key}=${e.value}') .join('&'); final response = await _client.get('$_prefix/check-updates?$queryString'); return AppVersionResponse.fromJson(response.data); } }