postVerificationResults method

Future<void> postVerificationResults(
  1. String projectId,
  2. Map<String, dynamic> verificationReport
)

Post verification results to the API for onboarding

Implementation

Future<void> postVerificationResults(
  String projectId,
  Map<String, dynamic> verificationReport,
) async {
  final url = Uri.parse('$baseUrl/projects/$projectId/onboarding/cli-verification');
  final headers = await _authHeaders();

  final response = await _postWithRetry(
    url,
    headers,
    jsonEncode(verificationReport),
  );

  if (response.statusCode == 401) {
    throw Exception(
      'Authentication failed. Please run "ulink login" to re-authenticate.',
    );
  } else if (response.statusCode == 403) {
    throw Exception(
      'Access forbidden. You may not have permission to update this project.',
    );
  } else if (response.statusCode == 404) {
    throw Exception('Project not found. Please check the project ID.');
  } else if (response.statusCode != 200 && response.statusCode != 201) {
    throw Exception(
      'Failed to upload verification results: ${response.statusCode}',
    );
  }
}