From ad1bc943533e6b91f5e98cfe80e7b2ef4d6affa9 Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Fri, 14 Feb 2025 09:20:42 +0100 Subject: [PATCH 1/6] Update dependencies - pubspec.yaml: Update http to ^1.1.2 and dartdoc to ^8.2.3 --- pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index aa7b2bf..901e069 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,10 +9,10 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: - http: ^0.13.4 + http: ^1.1.2 jose: ^0.3.2 dev_dependencies: lints: ^1.0.1 test: ^1.19.3 - dartdoc: ^4.1.0 + dartdoc: ^8.2.3 From f15427102494a73baca9d875876c176082a5df3f Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Wed, 19 Feb 2025 10:30:08 +0100 Subject: [PATCH 2/6] - app_store_connect.dart: Add export for Build model --- lib/app_store_connect.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/app_store_connect.dart b/lib/app_store_connect.dart index fa96616..599dfc4 100644 --- a/lib/app_store_connect.dart +++ b/lib/app_store_connect.dart @@ -1,2 +1,3 @@ export 'src/app_store_connect.dart' show AppStoreConnect; +export 'src/models/build.dart' show Build; export 'src/models/profile.dart' show Profile; From 9deb1cc76169c46e78e5c7f06f99c08eee40a187 Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Wed, 19 Feb 2025 10:48:56 +0100 Subject: [PATCH 3/6] 345: Update key file loading method and add flutter dependency - app_store_connect.dart: Change loadKeyFileContent to use async and loadString from rootBundle - pubspec.yaml: Add flutter dependency --- lib/src/app_store_connect.dart | 5 +++-- pubspec.yaml | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/src/app_store_connect.dart b/lib/src/app_store_connect.dart index e452b5f..eb82c83 100644 --- a/lib/src/app_store_connect.dart +++ b/lib/src/app_store_connect.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:app_store_connect_apis/src/provisioning.dart'; +import 'package:flutter/services.dart'; import 'builds.dart'; import 'models/build.dart'; @@ -40,9 +41,9 @@ class AppStoreConnect { return _builds.getAllBuilds(); } - void loadKeyFileContent() { + Future loadKeyFileContent() async { try { - _keyFileContent = File(_keyFilePath).readAsStringSync(); + _keyFileContent = await rootBundle.loadString(_keyFilePath); } catch (e) { throw FileSystemException( 'Could not load the Apple App Store Connect key file', _keyFilePath); diff --git a/pubspec.yaml b/pubspec.yaml index 901e069..1a5636c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,6 +9,8 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: + flutter: + sdk: flutter http: ^1.1.2 jose: ^0.3.2 From dbc26934fc86c1f4a27571dc86eeab3718811435 Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Wed, 19 Feb 2025 13:05:50 +0100 Subject: [PATCH 4/6] Update AppStoreConnect initialization - app_store_connect.dart: Remove unused imports and modify constructor to accept key file content directly --- lib/src/app_store_connect.dart | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/lib/src/app_store_connect.dart b/lib/src/app_store_connect.dart index eb82c83..7413bcd 100644 --- a/lib/src/app_store_connect.dart +++ b/lib/src/app_store_connect.dart @@ -1,7 +1,4 @@ -import 'dart:io'; - import 'package:app_store_connect_apis/src/provisioning.dart'; -import 'package:flutter/services.dart'; import 'builds.dart'; import 'models/build.dart'; @@ -10,7 +7,6 @@ import 'models/profile.dart'; class AppStoreConnect { final String _issuer; final String _keyId; - final String _keyFilePath; late final String _keyFileContent; late final Provisioning _provisioning; late final Builds _builds; @@ -20,8 +16,7 @@ class AppStoreConnect { /// [_keyId] Your private key ID from App Store Connect /// /// [_keyFilePath] Path to the private key file from App Store Connect - AppStoreConnect(this._issuer, this._keyId, this._keyFilePath) { - loadKeyFileContent(); + AppStoreConnect(this._issuer, this._keyId, this._keyFileContent) { _provisioning = Provisioning(_issuer, _keyId, _keyFileContent); _builds = Builds(_issuer, _keyId, _keyFileContent); } @@ -40,13 +35,4 @@ class AppStoreConnect { Future> getAllBuilds() async { return _builds.getAllBuilds(); } - - Future loadKeyFileContent() async { - try { - _keyFileContent = await rootBundle.loadString(_keyFilePath); - } catch (e) { - throw FileSystemException( - 'Could not load the Apple App Store Connect key file', _keyFilePath); - } - } } From 132706db04d1a7cee8d3fdf01c2a010d7ab9b7a9 Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Wed, 19 Feb 2025 13:21:30 +0100 Subject: [PATCH 5/6] Add HttpClient export to app_store_connect - app_store_connect.dart: Add export for HttpClient --- lib/app_store_connect.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/app_store_connect.dart b/lib/app_store_connect.dart index 599dfc4..7829ee3 100644 --- a/lib/app_store_connect.dart +++ b/lib/app_store_connect.dart @@ -1,3 +1,4 @@ export 'src/app_store_connect.dart' show AppStoreConnect; +export 'src/http_client.dart'; export 'src/models/build.dart' show Build; export 'src/models/profile.dart' show Profile; From f2168016062be90cb96989d6f4a6dd37929e57ba Mon Sep 17 00:00:00 2001 From: Jonas Ohlendorf Date: Wed, 19 Feb 2025 13:41:36 +0100 Subject: [PATCH 6/6] Implement App Store Version Management - app_store_version.dart: Introduce AppStoreVersion class - app_store_versions.dart: Add AppStoreVersions class for handling App Store versions - app_store_connect.dart: Add getAppVersions method to AppStoreConnect class to manage App Store versions --- lib/src/app_store_connect.dart | 7 +++++ lib/src/app_store_versions.dart | 40 +++++++++++++++++++++++++++ lib/src/models/app_store_version.dart | 1 + 3 files changed, 48 insertions(+) create mode 100644 lib/src/app_store_versions.dart create mode 100644 lib/src/models/app_store_version.dart diff --git a/lib/src/app_store_connect.dart b/lib/src/app_store_connect.dart index 7413bcd..c1186d9 100644 --- a/lib/src/app_store_connect.dart +++ b/lib/src/app_store_connect.dart @@ -1,3 +1,4 @@ +import 'package:app_store_connect_apis/src/models/app_store_version.dart'; import 'package:app_store_connect_apis/src/provisioning.dart'; import 'builds.dart'; @@ -35,4 +36,10 @@ class AppStoreConnect { Future> getAllBuilds() async { return _builds.getAllBuilds(); } + + Future> getAppVersions() async { + List res = List.empty(growable: true); + + return res; + } } diff --git a/lib/src/app_store_versions.dart b/lib/src/app_store_versions.dart new file mode 100644 index 0000000..87fa3ed --- /dev/null +++ b/lib/src/app_store_versions.dart @@ -0,0 +1,40 @@ +import 'dart:convert'; + +import 'package:http/http.dart' as http; + +import 'http_client.dart'; +import 'jwt.dart'; +import 'models/build.dart'; + +class AppStoreVersions { + final String _issuer; + final String _keyId; + final String _keyFileContent; + + AppStoreVersions(this._issuer, this._keyId, this._keyFileContent); + + /// Gets a list of all versions + Future> getAllVersions() async { + var jwt = createJWT(_issuer, _keyFileContent, _keyId); + + var response = await get( + 'https://api.appstoreconnect.apple.com/v1/6471971574/appStoreVersions', + jwt); + + print('Response: $response Data: ${jsonDecode(response.body)}'); + var builds = _convertResponseToListOfBuilds(response); + + return builds; + } + + List _convertResponseToListOfBuilds(http.Response response) { + dynamic jsonResponse = jsonDecode(response.body); + List allProfiles = jsonResponse['data'] as List; + + var profiles = allProfiles + .map((dynamic e) => Build.fromJson(e as Map)) + .toList(); + + return profiles; + } +} diff --git a/lib/src/models/app_store_version.dart b/lib/src/models/app_store_version.dart new file mode 100644 index 0000000..7e2f2f3 --- /dev/null +++ b/lib/src/models/app_store_version.dart @@ -0,0 +1 @@ +class AppStoreVersion {}