Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/app_store_connect.dart
Original file line number Diff line number Diff line change
@@ -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;
18 changes: 6 additions & 12 deletions lib/src/app_store_connect.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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<List<AppStoreVersion>> getAppVersions() async {
List<AppStoreVersion> res = List.empty(growable: true);

return res;
}
}
40 changes: 40 additions & 0 deletions lib/src/app_store_versions.dart
Original file line number Diff line number Diff line change
@@ -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<List<Build>> 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<Build> _convertResponseToListOfBuilds(http.Response response) {
dynamic jsonResponse = jsonDecode(response.body);
List<dynamic> allProfiles = jsonResponse['data'] as List<dynamic>;

var profiles = allProfiles
.map((dynamic e) => Build.fromJson(e as Map<String, dynamic>))
.toList();

return profiles;
}
}
1 change: 1 addition & 0 deletions lib/src/models/app_store_version.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class AppStoreVersion {}
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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