request<T> method

Future<APIResponse<T>> request<T>(
  1. String target,
  2. RequestType type, {
  3. Map<String, dynamic>? data,
  4. List<MultipartFile> files = const [],
  5. dynamic onFilesUpload(
    1. int bytes,
    2. int totalBytes
    )?,
  6. bool? log,
  7. Map<String, String> headers = const {},
  8. bool appendHeader = true,
  9. String errorsField = 'errors',
  10. Map<String, String> decodeErrors(
    1. Map errors
    )?,
  11. Encoding? encoding,
})

Implementation

Future<APIResponse<T>> request<T>(
  String target,
  RequestType type, {
  Map<String, dynamic>? data,
  List<http.MultipartFile> files = const [],
  Function(int bytes, int totalBytes)? onFilesUpload,
  bool? log,
  Map<String, String> headers = const {},
  bool appendHeader = true,
  String errorsField = 'errors',
  Map<String, String> Function(Map errors)? decodeErrors,
  Encoding? encoding,
}) {
  final url = '$apiUrl/$target';

  return APIRequest<T>(
    url,
    type: type,
    data: data,
    files: files,
    onFilesUpload: onFilesUpload,
    log: log ?? this.log,
    headers: appendHeader
        ? {...(getHeaders?.call(url) ?? {}), ...headers}
        : headers,
    errorsField: errorsField,
    encoding: encoding,
  ).send();
}