submitCommunication static method

Future<void> submitCommunication({
  1. required String message,
  2. required String type,
  3. String? email,
  4. List<File>? files,
})

Implementation

static Future<void> submitCommunication({
  required String message,
  required String type,
  String? email,
  List<File>? files,
}) async {
  type = type.toLowerCase();
  if (!_allowedTypes.contains(type)) {
    throw Exception(
      "Invalid communication type: $type. Allowed types are: ${_allowedTypes.join(', ')}",
    );
  }

  if (_apiKey == null) {
    throw Exception("Feedbacknest is not initialized. Call init() first.");
  }

  await _apiClient?.postWithMultipart(
    endpoint: "/user/submit/communication",
    apiKey: _apiKey!,
    fields: {
      "user_id": _userIdentifier ?? "Unknown",
      "app_version": _appVersion,
      "platform": _deviceInfo?.deviceOS ?? "Unknown",
      "device_model": _deviceInfo?.deviceName ?? "Unknown",
      "device_os_version": _deviceInfo?.deviceOSVersion ?? "Unknown",
      "message": message,
      "contact_email": email ?? "",
      "type": type,
    },
    files: files,
  );
}