generate static method

String generate(
  1. QueryModel? query, {
  2. List<String> fields = const [],
})

Implementation

static String generate(QueryModel? query, {List<String> fields = const []}) {
  if (query == null) {
    return '';
  }

  final apiFilter = query.filters != null
      ? QueryFilter.getApiFilters(query.columns, query.filters)
      : null;

  final apiFields = DhisUrlGenerator.getApiFields(query.columns);

  return '${query.resourceName}.json${apiFilter != null ? '?$apiFilter&${query.junctionOperator != null ? 'rootJunction=${query.junctionOperator}&' : ''}' : '?'}fields=${(fields.isNotEmpty ? fields : apiFields).join(',')}&paging=false'
      .replaceAll('AND', '&')
      .replaceAll(' ', '');
}