diff --git a/CHANGELOG.md b/CHANGELOG.md index 894ce671..cf08ad71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 3.7.3 +- Refactor `CaclInput`. + ## 3.7.2 - Remove unused properties `mapLayerId` and `poisIds` from `MapLayerInput` diff --git a/lib/src/ats/ats.freezed.dart b/lib/src/ats/ats.freezed.dart index 4266cb97..a16630c3 100644 --- a/lib/src/ats/ats.freezed.dart +++ b/lib/src/ats/ats.freezed.dart @@ -18722,10 +18722,7 @@ return $default(_that);case _: final _that = this; switch (_that) { case _CaclInput(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that);} } /// A variant of `map` that fallback to returning `null`. /// @@ -18784,10 +18781,7 @@ return $default(_that.id,_that.assetId,_that.transportAssetId,_that.transportUse @optionalTypeArgs TResult when(TResult Function( String? id, String? assetId, String? transportAssetId, String? transportUserId, String? caclNumber, String? category, String? product, String? clientAssetId, String? tankNumber, String? transport, CaclEquipmentInput? equipments, MeasurementsInput? measurements, ResultsInput? results, CaclMeasurement? measurer01, CaclMeasurement? measurer02, VolumeMovedInput? volumeMoved, String? observations, @TimestampOrNullConverter() DateTime? startedAt, @TimestampOrNullConverter() DateTime? finishedAt, String? operationId, @TimestampOrNullConverter() DateTime? localDateStart, @TimestampOrNullConverter() DateTime? localDateEnd) $default,) {final _that = this; switch (_that) { case _CaclInput(): -return $default(_that.id,_that.assetId,_that.transportAssetId,_that.transportUserId,_that.caclNumber,_that.category,_that.product,_that.clientAssetId,_that.tankNumber,_that.transport,_that.equipments,_that.measurements,_that.results,_that.measurer01,_that.measurer02,_that.volumeMoved,_that.observations,_that.startedAt,_that.finishedAt,_that.operationId,_that.localDateStart,_that.localDateEnd);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that.id,_that.assetId,_that.transportAssetId,_that.transportUserId,_that.caclNumber,_that.category,_that.product,_that.clientAssetId,_that.tankNumber,_that.transport,_that.equipments,_that.measurements,_that.results,_that.measurer01,_that.measurer02,_that.volumeMoved,_that.observations,_that.startedAt,_that.finishedAt,_that.operationId,_that.localDateStart,_that.localDateEnd);} } /// A variant of `when` that fallback to returning `null` /// @@ -18815,8 +18809,8 @@ return $default(_that.id,_that.assetId,_that.transportAssetId,_that.transportUse /// @nodoc @JsonSerializable() -class _CaclInput implements CaclInput { - _CaclInput({this.id, this.assetId, this.transportAssetId, this.transportUserId, this.caclNumber, this.category, this.product, this.clientAssetId, this.tankNumber, this.transport, this.equipments, this.measurements, this.results, this.measurer01, this.measurer02, this.volumeMoved, this.observations, @TimestampOrNullConverter() this.startedAt, @TimestampOrNullConverter() this.finishedAt, this.operationId, @TimestampOrNullConverter() this.localDateStart, @TimestampOrNullConverter() this.localDateEnd}); +class _CaclInput extends CaclInput { + _CaclInput({this.id, this.assetId, this.transportAssetId, this.transportUserId, this.caclNumber, this.category, this.product, this.clientAssetId, this.tankNumber, this.transport, this.equipments, this.measurements, this.results, this.measurer01, this.measurer02, this.volumeMoved, this.observations, @TimestampOrNullConverter() this.startedAt, @TimestampOrNullConverter() this.finishedAt, this.operationId, @TimestampOrNullConverter() this.localDateStart, @TimestampOrNullConverter() this.localDateEnd}): super._(); factory _CaclInput.fromJson(Map json) => _$CaclInputFromJson(json); /// The [id] parameter is the id of the cacl input. @@ -19244,8 +19238,8 @@ return $default(_that.measuringTape,_that.densimeter,_that.thermometer);case _: /// @nodoc @JsonSerializable() -class _CaclEquipmentInput implements CaclEquipmentInput { - _CaclEquipmentInput({this.measuringTape, this.densimeter, this.thermometer}); +class _CaclEquipmentInput extends CaclEquipmentInput { + _CaclEquipmentInput({this.measuringTape, this.densimeter, this.thermometer}): super._(); factory _CaclEquipmentInput.fromJson(Map json) => _$CaclEquipmentInputFromJson(json); /// The [measuringTape] parameter is the measuringTape of the cacl equipment input. @@ -19562,10 +19556,7 @@ return $default(_that);case _: final _that = this; switch (_that) { case _MeasurementsInput(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that);} } /// A variant of `map` that fallback to returning `null`. /// @@ -19624,10 +19615,7 @@ return $default(_that.referenceHeight,_that.productLevelHeight,_that.correctedLe @optionalTypeArgs TResult when(TResult Function( MeasurementInput? referenceHeight, MeasurementInput? productLevelHeight, MeasurementInput? correctedLevelHeight, MeasurementInput? waterHeight, MeasurementInput? ambientLineVolume, MeasurementInput? ambientDensity, MeasurementInput? ambientTemperature, MeasurementInput? averageTankTemperature) $default,) {final _that = this; switch (_that) { case _MeasurementsInput(): -return $default(_that.referenceHeight,_that.productLevelHeight,_that.correctedLevelHeight,_that.waterHeight,_that.ambientLineVolume,_that.ambientDensity,_that.ambientTemperature,_that.averageTankTemperature);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that.referenceHeight,_that.productLevelHeight,_that.correctedLevelHeight,_that.waterHeight,_that.ambientLineVolume,_that.ambientDensity,_that.ambientTemperature,_that.averageTankTemperature);} } /// A variant of `when` that fallback to returning `null` /// @@ -19655,8 +19643,8 @@ return $default(_that.referenceHeight,_that.productLevelHeight,_that.correctedLe /// @nodoc @JsonSerializable() -class _MeasurementsInput implements MeasurementsInput { - _MeasurementsInput({this.referenceHeight, this.productLevelHeight, this.correctedLevelHeight, this.waterHeight, this.ambientLineVolume, this.ambientDensity, this.ambientTemperature, this.averageTankTemperature}); +class _MeasurementsInput extends MeasurementsInput { + _MeasurementsInput({this.referenceHeight, this.productLevelHeight, this.correctedLevelHeight, this.waterHeight, this.ambientLineVolume, this.ambientDensity, this.ambientTemperature, this.averageTankTemperature}): super._(); factory _MeasurementsInput.fromJson(Map json) => _$MeasurementsInputFromJson(json); /// The [referenceHeight] parameter is the referenceHeight of the measurements input. @@ -20048,10 +20036,7 @@ return $default(_that);case _: final _that = this; switch (_that) { case _ResultsInput(): -return $default(_that);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that);} } /// A variant of `map` that fallback to returning `null`. /// @@ -20110,10 +20095,7 @@ return $default(_that.environmentalTankVolume,_that.waterVolume,_that.densityAt2 @optionalTypeArgs TResult when(TResult Function( MeasurementInput? environmentalTankVolume, MeasurementInput? waterVolume, MeasurementInput? densityAt20, MeasurementInput? volumeCorrectionFactor, MeasurementInput? alcoholicContent, MeasurementInput? environmentalVolume, MeasurementInput? volumeAt20, MeasurementInput? kilogramsAt20) $default,) {final _that = this; switch (_that) { case _ResultsInput(): -return $default(_that.environmentalTankVolume,_that.waterVolume,_that.densityAt20,_that.volumeCorrectionFactor,_that.alcoholicContent,_that.environmentalVolume,_that.volumeAt20,_that.kilogramsAt20);case _: - throw StateError('Unexpected subclass'); - -} +return $default(_that.environmentalTankVolume,_that.waterVolume,_that.densityAt20,_that.volumeCorrectionFactor,_that.alcoholicContent,_that.environmentalVolume,_that.volumeAt20,_that.kilogramsAt20);} } /// A variant of `when` that fallback to returning `null` /// @@ -20141,8 +20123,8 @@ return $default(_that.environmentalTankVolume,_that.waterVolume,_that.densityAt2 /// @nodoc @JsonSerializable() -class _ResultsInput implements ResultsInput { - _ResultsInput({this.environmentalTankVolume, this.waterVolume, this.densityAt20, this.volumeCorrectionFactor, this.alcoholicContent, this.environmentalVolume, this.volumeAt20, this.kilogramsAt20}); +class _ResultsInput extends ResultsInput { + _ResultsInput({this.environmentalTankVolume, this.waterVolume, this.densityAt20, this.volumeCorrectionFactor, this.alcoholicContent, this.environmentalVolume, this.volumeAt20, this.kilogramsAt20}): super._(); factory _ResultsInput.fromJson(Map json) => _$ResultsInputFromJson(json); /// The [environmentalTankVolume] parameter is the environmentalTankVolume of the results input. diff --git a/lib/src/ats/src/cacl/input/cacl_equipment_input.dart b/lib/src/ats/src/cacl/input/cacl_equipment_input.dart index ab65d1bd..50c6a9b8 100644 --- a/lib/src/ats/src/cacl/input/cacl_equipment_input.dart +++ b/lib/src/ats/src/cacl/input/cacl_equipment_input.dart @@ -3,6 +3,12 @@ part of '../../../ats.dart'; /// A model class representing a cacl equipment input. @unfreezed abstract class CaclEquipmentInput with _$CaclEquipmentInput { + CaclEquipmentInput._() { + measuringTape ??= EquipmentMeasurementInput(); + densimeter ??= EquipmentMeasurementInput(); + thermometer ??= EquipmentMeasurementInput(); + } + /// Creates a new [CaclEquipmentInput] instance. factory CaclEquipmentInput({ /// The [measuringTape] parameter is the measuringTape of the cacl equipment input. @@ -18,6 +24,5 @@ abstract class CaclEquipmentInput with _$CaclEquipmentInput { /// Creates a new [CaclEquipmentInput] instance from a JSON map. /// /// The [json] parameter is the JSON map to create the instance from. - factory CaclEquipmentInput.fromJson(Map json) => - _$CaclEquipmentInputFromJson(json); + factory CaclEquipmentInput.fromJson(Map json) => _$CaclEquipmentInputFromJson(json); } diff --git a/lib/src/ats/src/cacl/input/cacl_input.dart b/lib/src/ats/src/cacl/input/cacl_input.dart index 4d3b2f8a..656501fb 100644 --- a/lib/src/ats/src/cacl/input/cacl_input.dart +++ b/lib/src/ats/src/cacl/input/cacl_input.dart @@ -2,8 +2,17 @@ part of '../../../ats.dart'; /// A model class representing a cacl input. @unfreezed -abstract class CaclInput with _$CaclInput { - /// Creates a new [CaclInput] instance. +sealed class CaclInput with _$CaclInput { + CaclInput._() { + // Inicialización de valores no constantes + measurements ??= MeasurementsInput(); + results ??= ResultsInput(); + volumeMoved ??= VolumeMovedInput(); + measurer01 ??= CaclMeasurement(); + measurer02 ??= CaclMeasurement(); + equipments ??= CaclEquipmentInput(); + } + factory CaclInput({ /// The [id] parameter is the id of the cacl input. String? id, diff --git a/lib/src/ats/src/cacl/input/measurements_input.dart b/lib/src/ats/src/cacl/input/measurements_input.dart index 94944fed..4609b2ad 100644 --- a/lib/src/ats/src/cacl/input/measurements_input.dart +++ b/lib/src/ats/src/cacl/input/measurements_input.dart @@ -2,7 +2,18 @@ part of '../../../ats.dart'; /// A model class representing a measurements input. @unfreezed -abstract class MeasurementsInput with _$MeasurementsInput { +sealed class MeasurementsInput with _$MeasurementsInput { + MeasurementsInput._() { + referenceHeight ??= MeasurementInput(); + productLevelHeight ??= MeasurementInput(); + correctedLevelHeight ??= MeasurementInput(); + waterHeight ??= MeasurementInput(); + ambientLineVolume ??= MeasurementInput(); + ambientDensity ??= MeasurementInput(); + ambientTemperature ??= MeasurementInput(); + averageTankTemperature ??= MeasurementInput(); + } + /// Creates a new [MeasurementsInput] instance. factory MeasurementsInput({ /// The [referenceHeight] parameter is the referenceHeight of the measurements input. @@ -33,6 +44,5 @@ abstract class MeasurementsInput with _$MeasurementsInput { /// Creates a new [MeasurementsInput] instance from a JSON map. /// /// The [json] parameter is the JSON map to create the instance from. - factory MeasurementsInput.fromJson(Map json) => - _$MeasurementsInputFromJson(json); + factory MeasurementsInput.fromJson(Map json) => _$MeasurementsInputFromJson(json); } diff --git a/lib/src/ats/src/cacl/input/results_input.dart b/lib/src/ats/src/cacl/input/results_input.dart index 0838151f..58aa15fa 100644 --- a/lib/src/ats/src/cacl/input/results_input.dart +++ b/lib/src/ats/src/cacl/input/results_input.dart @@ -2,7 +2,18 @@ part of '../../../ats.dart'; /// A model class representing a results input. @unfreezed -abstract class ResultsInput with _$ResultsInput { +sealed class ResultsInput with _$ResultsInput { + ResultsInput._() { + environmentalTankVolume ??= MeasurementInput(); + waterVolume ??= MeasurementInput(); + densityAt20 ??= MeasurementInput(); + volumeCorrectionFactor ??= MeasurementInput(); + alcoholicContent ??= MeasurementInput(); + environmentalVolume ??= MeasurementInput(); + volumeAt20 ??= MeasurementInput(); + kilogramsAt20 ??= MeasurementInput(); + } + /// Creates a new [ResultsInput] instance. factory ResultsInput({ /// The [environmentalTankVolume] parameter is the environmentalTankVolume of the results input. diff --git a/pubspec.yaml b/pubspec.yaml index 736191a7..8410d270 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ description: Layrz API models for Dart/Flutter. This package contains the models used by the Layrz API. name: layrz_models -version: "3.7.2" +version: "3.7.3" repository: https://github.com/goldenm-software/layrz_models environment: