APIRequest constructor

APIRequest(
  1. APIRequestMethod method,
  2. String path, {
  3. String? protocol,
  4. Map<String, dynamic>? parameters,
  5. Map<String, dynamic>? headers,
  6. dynamic payload,
  7. Object? payloadMimeType,
  8. String? payloadFileExtension,
  9. String? sessionID,
  10. bool newSession = false,
  11. APICredential? credential,
  12. String? scheme,
  13. APIRequesterSource? requesterSource,
  14. String? requesterAddress,
  15. bool keepAlive = false,
  16. DateTime? time,
  17. Duration? parsingDuration,
  18. Uri? requestedUri,
  19. Object? originalRequest,
  20. Map<String, APIMetric>? metrics,
})

Implementation

APIRequest(this.method, this.path,
    {this.protocol,
    Map<String, dynamic>? parameters,
    Map<String, dynamic>? headers,
    this.payload,
    Object? payloadMimeType,
    this.payloadFileExtension,
    this.sessionID,
    this.newSession = false,
    this.credential,
    String? scheme,
    APIRequesterSource? requesterSource,
    String? requesterAddress,
    this.keepAlive = false,
    DateTime? time,
    this.parsingDuration,
    Uri? requestedUri,
    this.originalRequest,
    super.metrics})
    : parameters = parameters ?? <String, dynamic>{},
      _payloadMimeType = APIPayload.resolveMimeType(payloadMimeType),
      headers = headers ?? <String, dynamic>{},
      _pathParts = _buildPathParts(path),
      scheme = scheme?.trim(),
      originalCredential = credential,
      requesterSource = _resolveRestSource(requesterAddress),
      _requesterAddress = requesterAddress,
      requestedUri = requestedUri ??
          Uri(
              host: requesterSource == APIRequesterSource.local
                  ? 'localhost'
                  : null,
              path: path,
              queryParameters: parameters?.map((key, value) => MapEntry(
                  key,
                  value is List
                      ? value.map((e) => '$e').toList()
                      : '$value'))),
      time = time ?? DateTime.now();