// Query parameter constants
const String _limitParam = 'limit';
const String _offsetParam = 'offset';
const String _archivedParam = 'archived';

void _addIfNotNull(Map<String, String> params, String key, dynamic value) {
  if (value != null) {
    params[key] = value.toString();
  }
}

Uri paramsToUri({
  required String path,
  int? limit,
  int? offset,
  bool? fetchArchived,
  Map<String, String>? params,
}) {
  Map<String, String> queryParams = params ?? {};
  _addIfNotNull(queryParams, _limitParam, limit);
  _addIfNotNull(queryParams, _offsetParam, offset);
  _addIfNotNull(queryParams, _archivedParam, fetchArchived);
  
  // Build URL with query parameters using Uri class
  return Uri(
    path: path,
    queryParameters: queryParams.isEmpty ? null : queryParams,
  );
}


String paramsToUriString({
  required String path,
  Map<String, String> queryParams = const {},
  int? limit,
  int? offset,
  bool? fetchArchived,
}) => paramsToUri(path: path, limit: limit, offset: offset, fetchArchived: fetchArchived).toString();
