createProperty method

  1. @override
AsserestHttpProperty createProperty(
  1. Uri url,
  2. Duration timeout,
  3. bool accessible,
  4. int? tryCount,
  5. UnmodifiableMapView<String, dynamic> additionalProperty,
)

Define the construction of AsserestProperty with given url, timeout, accessible and tryCount with additionalProperty for those non-standard properties found in Map.

Implementation

@override
AsserestHttpProperty createProperty(
    Uri url,
    Duration timeout,
    bool accessible,
    int? tryCount,
    UnmodifiableMapView<String, dynamic> additionalProperty) {
  final HttpRequestMethod method = HttpRequestMethod.values
      .singleWhere((e) => e.name == additionalProperty["method"]);
  final Map<String, String>? headers = additionalProperty["header"];
  final Object? body = additionalProperty["body"];

  return AsserestHttpProperty(
      url,
      accessible,
      timeout,
      tryCount,
      method,
      UnmodifiableMapView({
        "User-Agent":
            "Asserest $_uaVersion (${platform_iden.runtimePlatformInString})"
      }..addAll(headers ?? <String, String>{})),
      body);
}