Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
josancamon19 committed Nov 11, 2024
2 parents d49d58e + ade2c01 commit 20fc6a8
Show file tree
Hide file tree
Showing 45 changed files with 3,360 additions and 1,181 deletions.
10 changes: 9 additions & 1 deletion app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ android {
storePassword keystoreProperties['storePassword']
}
}
debug {
if (keystorePropertiesFile.exists()) {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
storePassword keystoreProperties['storePassword']
}
}
}

buildTypes {
Expand All @@ -119,7 +127,7 @@ android {
}
}

ndkVersion System.getenv()["NDK_VERSION"] ?: "27.0.12077973"
ndkVersion System.getenv()["NDK_VERSION"] ?: "27.0.12077973"
}

flutter {
Expand Down
132 changes: 126 additions & 6 deletions app/lib/backend/http/api/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import 'package:path/path.dart';

Future<List<App>> retrieveApps() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v3/plugins',
url: '${Env.apiBaseUrl}v1/apps',
headers: {},
body: '',
method: 'GET',
Expand All @@ -37,7 +37,7 @@ Future<List<App>> retrieveApps() async {

Future<bool> enableAppServer(String appId) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/plugins/enable?plugin_id=$appId',
url: '${Env.apiBaseUrl}v1/apps/enable?app_id=$appId',
headers: {},
method: 'POST',
body: '',
Expand All @@ -49,7 +49,7 @@ Future<bool> enableAppServer(String appId) async {

Future<bool> disableAppServer(String appId) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/plugins/disable?plugin_id=$appId',
url: '${Env.apiBaseUrl}v1/apps/disable?app_id=$appId',
headers: {},
method: 'POST',
body: '',
Expand All @@ -61,7 +61,7 @@ Future<bool> disableAppServer(String appId) async {

Future<void> reviewApp(String appId, double score, {String review = ''}) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/plugins/review?plugin_id=$appId',
url: '${Env.apiBaseUrl}v1/apps/review?app_id=$appId',
headers: {'Content-Type': 'application/json'},
method: 'POST',
body: jsonEncode({'score': score, review: review}),
Expand Down Expand Up @@ -141,11 +141,11 @@ Future<double> getAppMoneyMade(String pluginId) async {
Future<bool> submitAppServer(File file, Map<String, dynamic> appData) async {
var request = http.MultipartRequest(
'POST',
Uri.parse('${Env.apiBaseUrl}v3/plugins'),
Uri.parse('${Env.apiBaseUrl}v1/apps'),
);
request.files.add(await http.MultipartFile.fromPath('file', file.path, filename: basename(file.path)));
request.headers.addAll({'Authorization': await getAuthHeader()});
request.fields.addAll({'plugin_data': jsonEncode(appData)});
request.fields.addAll({'app_data': jsonEncode(appData)});
print(jsonEncode(appData));
try {
var streamedResponse = await request.send();
Expand All @@ -164,6 +164,34 @@ Future<bool> submitAppServer(File file, Map<String, dynamic> appData) async {
}
}

Future<bool> updateAppServer(File? file, Map<String, dynamic> appData) async {
var request = http.MultipartRequest(
'PATCH',
Uri.parse('${Env.apiBaseUrl}v1/apps/${appData['id']}'),
);
if (file != null) {
request.files.add(await http.MultipartFile.fromPath('file', file.path, filename: basename(file.path)));
}
request.headers.addAll({'Authorization': await getAuthHeader()});
request.fields.addAll({'app_data': jsonEncode(appData)});
print(jsonEncode(appData));
try {
var streamedResponse = await request.send();
var response = await http.Response.fromStream(streamedResponse);

if (response.statusCode == 200) {
debugPrint('updateAppServer Response body: ${jsonDecode(response.body)}');
return true;
} else {
debugPrint('Failed to update app. Status code: ${response.statusCode}');
return false;
}
} catch (e) {
debugPrint('An error occurred updateAppServer: $e');
return false;
}
}

Future<List<Category>> getAppCategories() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/plugin-categories',
Expand All @@ -183,6 +211,25 @@ Future<List<Category>> getAppCategories() async {
}
}

Future<List<AppCapability>> getAppCapabilitiesServer() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/app-capabilities',
headers: {},
body: '',
method: 'GET',
);
try {
if (response == null || response.statusCode != 200) return [];
log('getAppCapabilities: ${response.body}');
var res = jsonDecode(response.body);
return AppCapability.fromJsonList(res);
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return [];
}
}

Future<List<TriggerEvent>> getTriggerEventsServer() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/plugin-triggers',
Expand All @@ -201,3 +248,76 @@ Future<List<TriggerEvent>> getTriggerEventsServer() async {
return [];
}
}

Future<List<NotificationScope>> getNotificationScopesServer() async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/apps/proactive-notification-scopes',
headers: {},
body: '',
method: 'GET',
);
try {
if (response == null || response.statusCode != 200) return [];
log('getNotificationScopes: ${response.body}');
var res = jsonDecode(response.body);
return NotificationScope.fromJsonList(res);
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return [];
}
}

Future changeAppVisibilityServer(String appId, bool makePublic) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/apps/$appId/change-visibility?private=${!makePublic}',
headers: {},
body: '',
method: 'PATCH',
);
try {
if (response == null || response.statusCode != 200) return false;
log('changeAppVisibilityServer: ${response.body}');
return true;
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return false;
}
}

Future deleteAppServer(String appId) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/apps/$appId',
headers: {},
body: '',
method: 'DELETE',
);
try {
if (response == null || response.statusCode != 200) return false;
log('deleteAppServer: ${response.body}');
return true;
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return false;
}
}

Future<Map<String, dynamic>?> getAppDetailsServer(String appId) async {
var response = await makeApiCall(
url: '${Env.apiBaseUrl}v1/apps/$appId',
headers: {},
body: '',
method: 'GET',
);
try {
if (response == null || response.statusCode != 200) return null;
log('getAppDetailsServer: ${response.body}');
return jsonDecode(response.body);
} catch (e, stackTrace) {
debugPrint(e.toString());
CrashReporting.reportHandledCrash(e, stackTrace);
return null;
}
}
Loading

0 comments on commit 20fc6a8

Please sign in to comment.