create static method

Future<TestCase> create(
  1. int sectionId, {
  2. Map<String, dynamic>? customValues,
  3. String? estimate,
  4. int? milestoneId,
  5. int? priorityId,
  6. String? refs,
  7. required String title,
  8. int? templateId,
  9. int? typeId,
})

Implementation

static Future<TestCase> create(
  int sectionId, {
  Map<String, dynamic>? customValues,
  String? estimate,
  int? milestoneId,
  int? priorityId,
  String? refs,
  required String title,
  int? templateId,
  int? typeId,
}) async {
  final parametersMap = {
    if (estimate != null) 'estimate': estimate,
    if (milestoneId != null) 'milestone_id': milestoneId,
    if (priorityId != null) 'priority_id': priorityId,
    if (refs != null) 'refs': refs,
    if (templateId != null) 'template_id': templateId,
    'title': title,
    if (typeId != null) 'type_id': typeId,
  };

  customValues?.forEach((key, value) {
    parametersMap.putIfAbsent(key, () => value);
  });

  final response = await FlutterTestRail.instance.client.request(
    '/add_case/$sectionId',
    RequestMethod.post,
    params: parametersMap,
  );

  return TestCase.fromJson(response!);
}