diff --git a/lib/app_store_connect.dart b/lib/app_store_connect.dart index fa96616..7829ee3 100644 --- a/lib/app_store_connect.dart +++ b/lib/app_store_connect.dart @@ -1,2 +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; diff --git a/lib/src/app_store_connect.dart b/lib/src/app_store_connect.dart index e452b5f..c1186d9 100644 --- a/lib/src/app_store_connect.dart +++ b/lib/src/app_store_connect.dart @@ -1,5 +1,4 @@ -import 'dart:io'; - +import 'package:app_store_connect_apis/src/models/app_store_version.dart'; import 'package:app_store_connect_apis/src/provisioning.dart'; import 'builds.dart'; @@ -9,7 +8,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; @@ -19,8 +17,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,12 +37,9 @@ class AppStoreConnect { return _builds.getAllBuilds(); } - void loadKeyFileContent() { - try { - _keyFileContent = File(_keyFilePath).readAsStringSync(); - } catch (e) { - throw FileSystemException( - 'Could not load the Apple App Store Connect key file', _keyFilePath); - } + 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 {} diff --git a/pubspec.yaml b/pubspec.yaml index aa7b2bf..1a5636c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -9,10 +9,12 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: - http: ^0.13.4 + flutter: + sdk: flutter + 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