fromJson method

  1. @override
URepoApplyWritesWrites fromJson(
  1. Map<String, dynamic> json
)

Implementation

@override
URepoApplyWritesWrites fromJson(Map<String, dynamic> json) {
  try {
    if (Create.validate(json)) {
      return URepoApplyWritesWrites.create(
        data: const CreateConverter().fromJson(json),
      );
    }
    if (Update.validate(json)) {
      return URepoApplyWritesWrites.update(
        data: const UpdateConverter().fromJson(json),
      );
    }
    if (Delete.validate(json)) {
      return URepoApplyWritesWrites.delete(
        data: const DeleteConverter().fromJson(json),
      );
    }

    return URepoApplyWritesWrites.unknown(data: json);
  } catch (_) {
    return URepoApplyWritesWrites.unknown(data: json);
  }
}