added batch file upload logic
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:qpay/screens/groups/models/group_batch_model.dart';
|
||||
|
||||
part 'create_group_from_file_response.g.dart';
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class FileUploadError {
|
||||
final int lineNumber;
|
||||
final String account;
|
||||
final String name;
|
||||
final String message;
|
||||
|
||||
const FileUploadError({
|
||||
required this.lineNumber,
|
||||
required this.account,
|
||||
required this.name,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
factory FileUploadError.fromJson(Map<String, dynamic> json) =>
|
||||
_$FileUploadErrorFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$FileUploadErrorToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable(explicitToJson: true)
|
||||
class CreateGroupFromFileResponse {
|
||||
final GroupBatch? batch;
|
||||
final int totalRows;
|
||||
final int successCount;
|
||||
final int errorCount;
|
||||
final List<FileUploadError> errors;
|
||||
|
||||
const CreateGroupFromFileResponse({
|
||||
this.batch,
|
||||
required this.totalRows,
|
||||
required this.successCount,
|
||||
required this.errorCount,
|
||||
required this.errors,
|
||||
});
|
||||
|
||||
factory CreateGroupFromFileResponse.fromJson(Map<String, dynamic> json) =>
|
||||
_$CreateGroupFromFileResponseFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CreateGroupFromFileResponseToJson(this);
|
||||
|
||||
bool get isSuccess => errors.isEmpty;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'create_group_from_file_response.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
FileUploadError _$FileUploadErrorFromJson(Map<String, dynamic> json) =>
|
||||
FileUploadError(
|
||||
lineNumber: (json['lineNumber'] as num).toInt(),
|
||||
account: json['account'] as String,
|
||||
name: json['name'] as String,
|
||||
message: json['message'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$FileUploadErrorToJson(FileUploadError instance) =>
|
||||
<String, dynamic>{
|
||||
'lineNumber': instance.lineNumber,
|
||||
'account': instance.account,
|
||||
'name': instance.name,
|
||||
'message': instance.message,
|
||||
};
|
||||
|
||||
CreateGroupFromFileResponse _$CreateGroupFromFileResponseFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => CreateGroupFromFileResponse(
|
||||
batch: json['batch'] == null
|
||||
? null
|
||||
: GroupBatch.fromJson(json['batch'] as Map<String, dynamic>),
|
||||
totalRows: (json['totalRows'] as num).toInt(),
|
||||
successCount: (json['successCount'] as num).toInt(),
|
||||
errorCount: (json['errorCount'] as num).toInt(),
|
||||
errors: (json['errors'] as List<dynamic>)
|
||||
.map((e) => FileUploadError.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CreateGroupFromFileResponseToJson(
|
||||
CreateGroupFromFileResponse instance,
|
||||
) => <String, dynamic>{
|
||||
'batch': instance.batch?.toJson(),
|
||||
'totalRows': instance.totalRows,
|
||||
'successCount': instance.successCount,
|
||||
'errorCount': instance.errorCount,
|
||||
'errors': instance.errors.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
Reference in New Issue
Block a user