From e2d321a921dfb5ed892bfb1975ab13ef98558dd0 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:23:00 -0500 Subject: [PATCH 01/25] Update c2logbook.dart --- lib/c2logbook.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/c2logbook.dart b/lib/c2logbook.dart index 935d3fd..211de86 100644 --- a/lib/c2logbook.dart +++ b/lib/c2logbook.dart @@ -7,5 +7,6 @@ export 'src/c2logbook_base.dart'; export 'src/types/c2_user.dart'; export 'src/types/c2_results.dart'; export 'src/types/c2_webhook_result.dart'; +export 'src/types/c2_types.dart'; // TODO: Export any libraries intended for clients of this package. From 2f8c3b57389464201d0bdfa248db1d2ae460e562 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:23:56 -0400 Subject: [PATCH 02/25] We need these --- lib/src/types/index.freezed.dart | 1985 ++++++++++++++++++++++++++++++ lib/src/types/index.g.dart | 217 ++++ 2 files changed, 2202 insertions(+) create mode 100644 lib/src/types/index.freezed.dart create mode 100644 lib/src/types/index.g.dart diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart new file mode 100644 index 0000000..0c26bc6 --- /dev/null +++ b/lib/src/types/index.freezed.dart @@ -0,0 +1,1985 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'index.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +C2FullResults _$C2FullResultsFromJson(Map json) { + return _C2FullResults.fromJson(json); +} + +/// @nodoc +mixin _$C2FullResults { + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "user_id") + int get userId => throw _privateConstructorUsedError; + @JsonKey(name: "date") + @TimestampConverter() + DateTime get endDate => throw _privateConstructorUsedError; + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + DateTime? get dateUtc => throw _privateConstructorUsedError; + String? get timezone => throw _privateConstructorUsedError; + int get distance => throw _privateConstructorUsedError; + C2ResultType get type => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get time => throw _privateConstructorUsedError; + @JsonKey(name: "workout_type") + C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; + String get source => throw _privateConstructorUsedError; + @JsonKey(name: "weight_class") + C2WeightClass get weightClass => throw _privateConstructorUsedError; + @JsonKey(name: "stroke_rate") + int? get strokeRate => throw _privateConstructorUsedError; + bool get verified => throw _privateConstructorUsedError; + bool get ranked => throw _privateConstructorUsedError; + String? get comments => throw _privateConstructorUsedError; + C2PrivacyLevel get privacy => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2FullResultsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2FullResultsCopyWith<$Res> { + factory $C2FullResultsCopyWith( + C2FullResults value, $Res Function(C2FullResults) then) = + _$C2FullResultsCopyWithImpl<$Res, C2FullResults>; + @useResult + $Res call( + {int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "date") @TimestampConverter() DateTime endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + String? timezone, + int distance, + C2ResultType type, + @DecimalIntConverter.tenths() double time, + @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + String source, + @JsonKey(name: "weight_class") C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") int? strokeRate, + bool verified, + bool ranked, + String? comments, + C2PrivacyLevel privacy}); +} + +/// @nodoc +class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> + implements $C2FullResultsCopyWith<$Res> { + _$C2FullResultsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? endDate = null, + Object? dateUtc = freezed, + Object? timezone = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, + Object? strokeRate = freezed, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2FullResultsImplCopyWith<$Res> + implements $C2FullResultsCopyWith<$Res> { + factory _$$C2FullResultsImplCopyWith( + _$C2FullResultsImpl value, $Res Function(_$C2FullResultsImpl) then) = + __$$C2FullResultsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "date") @TimestampConverter() DateTime endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + String? timezone, + int distance, + C2ResultType type, + @DecimalIntConverter.tenths() double time, + @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + String source, + @JsonKey(name: "weight_class") C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") int? strokeRate, + bool verified, + bool ranked, + String? comments, + C2PrivacyLevel privacy}); +} + +/// @nodoc +class __$$C2FullResultsImplCopyWithImpl<$Res> + extends _$C2FullResultsCopyWithImpl<$Res, _$C2FullResultsImpl> + implements _$$C2FullResultsImplCopyWith<$Res> { + __$$C2FullResultsImplCopyWithImpl( + _$C2FullResultsImpl _value, $Res Function(_$C2FullResultsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? endDate = null, + Object? dateUtc = freezed, + Object? timezone = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, + Object? strokeRate = freezed, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + }) { + return _then(_$C2FullResultsImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2FullResultsImpl extends _C2FullResults { + _$C2FullResultsImpl( + {this.id = 0, + @JsonKey(name: "user_id") this.userId = 0, + @JsonKey(name: "date") @TimestampConverter() required this.endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() this.dateUtc, + this.timezone, + this.distance = 0, + this.type = C2ResultType.rower, + @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: "workout_type") + this.workoutType = C2APIWorkoutType.JustRow, + this.source = "c2logbook dart", + @JsonKey(name: "weight_class") + this.weightClass = C2WeightClass.heavyweight, + @JsonKey(name: "stroke_rate") this.strokeRate, + this.verified = false, + this.ranked = false, + this.comments, + this.privacy = C2PrivacyLevel.private}) + : super._(); + + factory _$C2FullResultsImpl.fromJson(Map json) => + _$$C2FullResultsImplFromJson(json); + + @override + @JsonKey() + final int id; + @override + @JsonKey(name: "user_id") + final int userId; + @override + @JsonKey(name: "date") + @TimestampConverter() + final DateTime endDate; + @override + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + final DateTime? dateUtc; + @override + final String? timezone; + @override + @JsonKey() + final int distance; + @override + @JsonKey() + final C2ResultType type; + @override + @DecimalIntConverter.tenths() + final double time; + @override + @JsonKey(name: "workout_type") + final C2APIWorkoutType workoutType; + @override + @JsonKey() + final String source; + @override + @JsonKey(name: "weight_class") + final C2WeightClass weightClass; + @override + @JsonKey(name: "stroke_rate") + final int? strokeRate; + @override + @JsonKey() + final bool verified; + @override + @JsonKey() + final bool ranked; + @override + final String? comments; + @override + @JsonKey() + final C2PrivacyLevel privacy; + + @override + String toString() { + return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2FullResultsImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.endDate, endDate) || other.endDate == endDate) && + (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && + (identical(other.timezone, timezone) || + other.timezone == timezone) && + (identical(other.distance, distance) || + other.distance == distance) && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time) && + (identical(other.workoutType, workoutType) || + other.workoutType == workoutType) && + (identical(other.source, source) || other.source == source) && + (identical(other.weightClass, weightClass) || + other.weightClass == weightClass) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && + (identical(other.verified, verified) || + other.verified == verified) && + (identical(other.ranked, ranked) || other.ranked == ranked) && + (identical(other.comments, comments) || + other.comments == comments) && + (identical(other.privacy, privacy) || other.privacy == privacy)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + id, + userId, + endDate, + dateUtc, + timezone, + distance, + type, + time, + workoutType, + source, + weightClass, + strokeRate, + verified, + ranked, + comments, + privacy); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => + __$$C2FullResultsImplCopyWithImpl<_$C2FullResultsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2FullResultsImplToJson( + this, + ); + } +} + +abstract class _C2FullResults extends C2FullResults { + factory _C2FullResults( + {final int id, + @JsonKey(name: "user_id") final int userId, + @JsonKey(name: "date") + @TimestampConverter() + required final DateTime endDate, + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + final DateTime? dateUtc, + final String? timezone, + final int distance, + final C2ResultType type, + @DecimalIntConverter.tenths() required final double time, + @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, + final String source, + @JsonKey(name: "weight_class") final C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") final int? strokeRate, + final bool verified, + final bool ranked, + final String? comments, + final C2PrivacyLevel privacy}) = _$C2FullResultsImpl; + _C2FullResults._() : super._(); + + factory _C2FullResults.fromJson(Map json) = + _$C2FullResultsImpl.fromJson; + + @override + int get id; + @override + @JsonKey(name: "user_id") + int get userId; + @override + @JsonKey(name: "date") + @TimestampConverter() + DateTime get endDate; + @override + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + DateTime? get dateUtc; + @override + String? get timezone; + @override + int get distance; + @override + C2ResultType get type; + @override + @DecimalIntConverter.tenths() + double get time; + @override + @JsonKey(name: "workout_type") + C2APIWorkoutType get workoutType; + @override + String get source; + @override + @JsonKey(name: "weight_class") + C2WeightClass get weightClass; + @override + @JsonKey(name: "stroke_rate") + int? get strokeRate; + @override + bool get verified; + @override + bool get ranked; + @override + String? get comments; + @override + C2PrivacyLevel get privacy; + @override + @JsonKey(ignore: true) + _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2HeartRate _$C2HeartRateFromJson(Map json) { + return _C2HeartRate.fromJson(json); +} + +/// @nodoc +mixin _$C2HeartRate { + @JsonKey(name: "min") + int get min => throw _privateConstructorUsedError; + @JsonKey(name: "average") + int get average => throw _privateConstructorUsedError; + @JsonKey(name: "max") + int get max => throw _privateConstructorUsedError; + @JsonKey(name: "ending") + int get ending => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2HeartRateCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2HeartRateCopyWith<$Res> { + factory $C2HeartRateCopyWith( + C2HeartRate value, $Res Function(C2HeartRate) then) = + _$C2HeartRateCopyWithImpl<$Res, C2HeartRate>; + @useResult + $Res call( + {@JsonKey(name: "min") int min, + @JsonKey(name: "average") int average, + @JsonKey(name: "max") int max, + @JsonKey(name: "ending") int ending}); +} + +/// @nodoc +class _$C2HeartRateCopyWithImpl<$Res, $Val extends C2HeartRate> + implements $C2HeartRateCopyWith<$Res> { + _$C2HeartRateCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? min = null, + Object? average = null, + Object? max = null, + Object? ending = null, + }) { + return _then(_value.copyWith( + min: null == min + ? _value.min + : min // ignore: cast_nullable_to_non_nullable + as int, + average: null == average + ? _value.average + : average // ignore: cast_nullable_to_non_nullable + as int, + max: null == max + ? _value.max + : max // ignore: cast_nullable_to_non_nullable + as int, + ending: null == ending + ? _value.ending + : ending // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2HeartRateImplCopyWith<$Res> + implements $C2HeartRateCopyWith<$Res> { + factory _$$C2HeartRateImplCopyWith( + _$C2HeartRateImpl value, $Res Function(_$C2HeartRateImpl) then) = + __$$C2HeartRateImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "min") int min, + @JsonKey(name: "average") int average, + @JsonKey(name: "max") int max, + @JsonKey(name: "ending") int ending}); +} + +/// @nodoc +class __$$C2HeartRateImplCopyWithImpl<$Res> + extends _$C2HeartRateCopyWithImpl<$Res, _$C2HeartRateImpl> + implements _$$C2HeartRateImplCopyWith<$Res> { + __$$C2HeartRateImplCopyWithImpl( + _$C2HeartRateImpl _value, $Res Function(_$C2HeartRateImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? min = null, + Object? average = null, + Object? max = null, + Object? ending = null, + }) { + return _then(_$C2HeartRateImpl( + min: null == min + ? _value.min + : min // ignore: cast_nullable_to_non_nullable + as int, + average: null == average + ? _value.average + : average // ignore: cast_nullable_to_non_nullable + as int, + max: null == max + ? _value.max + : max // ignore: cast_nullable_to_non_nullable + as int, + ending: null == ending + ? _value.ending + : ending // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2HeartRateImpl extends _C2HeartRate { + _$C2HeartRateImpl( + {@JsonKey(name: "min") this.min = 0, + @JsonKey(name: "average") this.average = 0, + @JsonKey(name: "max") this.max = 0, + @JsonKey(name: "ending") this.ending = 0}) + : super._(); + + factory _$C2HeartRateImpl.fromJson(Map json) => + _$$C2HeartRateImplFromJson(json); + + @override + @JsonKey(name: "min") + final int min; + @override + @JsonKey(name: "average") + final int average; + @override + @JsonKey(name: "max") + final int max; + @override + @JsonKey(name: "ending") + final int ending; + + @override + String toString() { + return 'C2HeartRate(min: $min, average: $average, max: $max, ending: $ending)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2HeartRateImpl && + (identical(other.min, min) || other.min == min) && + (identical(other.average, average) || other.average == average) && + (identical(other.max, max) || other.max == max) && + (identical(other.ending, ending) || other.ending == ending)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, min, average, max, ending); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2HeartRateImplCopyWith<_$C2HeartRateImpl> get copyWith => + __$$C2HeartRateImplCopyWithImpl<_$C2HeartRateImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2HeartRateImplToJson( + this, + ); + } +} + +abstract class _C2HeartRate extends C2HeartRate { + factory _C2HeartRate( + {@JsonKey(name: "min") final int min, + @JsonKey(name: "average") final int average, + @JsonKey(name: "max") final int max, + @JsonKey(name: "ending") final int ending}) = _$C2HeartRateImpl; + _C2HeartRate._() : super._(); + + factory _C2HeartRate.fromJson(Map json) = + _$C2HeartRateImpl.fromJson; + + @override + @JsonKey(name: "min") + int get min; + @override + @JsonKey(name: "average") + int get average; + @override + @JsonKey(name: "max") + int get max; + @override + @JsonKey(name: "ending") + int get ending; + @override + @JsonKey(ignore: true) + _$$C2HeartRateImplCopyWith<_$C2HeartRateImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2Intervals _$C2IntervalsFromJson(Map json) { + return _C2Intervals.fromJson(json); +} + +/// @nodoc +mixin _$C2Intervals { + @JsonKey(name: "type") + String get type => throw _privateConstructorUsedError; + @JsonKey(name: "time") + int get time => throw _privateConstructorUsedError; + @JsonKey(name: "calories_total") + int get calories => throw _privateConstructorUsedError; + @JsonKey(name: "stroke_rate") + int get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: "machine") + String get machine => throw _privateConstructorUsedError; + @JsonKey(name: "rest_distance") + int get restDistance => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2IntervalsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2IntervalsCopyWith<$Res> { + factory $C2IntervalsCopyWith( + C2Intervals value, $Res Function(C2Intervals) then) = + _$C2IntervalsCopyWithImpl<$Res, C2Intervals>; + @useResult + $Res call( + {@JsonKey(name: "type") String type, + @JsonKey(name: "time") int time, + @JsonKey(name: "calories_total") int calories, + @JsonKey(name: "stroke_rate") int strokeRate, + @JsonKey(name: "machine") String machine, + @JsonKey(name: "rest_distance") int restDistance}); +} + +/// @nodoc +class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> + implements $C2IntervalsCopyWith<$Res> { + _$C2IntervalsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? time = null, + Object? calories = null, + Object? strokeRate = null, + Object? machine = null, + Object? restDistance = null, + }) { + return _then(_value.copyWith( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as int, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as int, + strokeRate: null == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int, + machine: null == machine + ? _value.machine + : machine // ignore: cast_nullable_to_non_nullable + as String, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2IntervalsImplCopyWith<$Res> + implements $C2IntervalsCopyWith<$Res> { + factory _$$C2IntervalsImplCopyWith( + _$C2IntervalsImpl value, $Res Function(_$C2IntervalsImpl) then) = + __$$C2IntervalsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: "type") String type, + @JsonKey(name: "time") int time, + @JsonKey(name: "calories_total") int calories, + @JsonKey(name: "stroke_rate") int strokeRate, + @JsonKey(name: "machine") String machine, + @JsonKey(name: "rest_distance") int restDistance}); +} + +/// @nodoc +class __$$C2IntervalsImplCopyWithImpl<$Res> + extends _$C2IntervalsCopyWithImpl<$Res, _$C2IntervalsImpl> + implements _$$C2IntervalsImplCopyWith<$Res> { + __$$C2IntervalsImplCopyWithImpl( + _$C2IntervalsImpl _value, $Res Function(_$C2IntervalsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? time = null, + Object? calories = null, + Object? strokeRate = null, + Object? machine = null, + Object? restDistance = null, + }) { + return _then(_$C2IntervalsImpl( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as int, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as int, + strokeRate: null == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int, + machine: null == machine + ? _value.machine + : machine // ignore: cast_nullable_to_non_nullable + as String, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2IntervalsImpl extends _C2Intervals { + _$C2IntervalsImpl( + {@JsonKey(name: "type") this.type = "time", + @JsonKey(name: "time") this.time = 0, + @JsonKey(name: "calories_total") this.calories = 0, + @JsonKey(name: "stroke_rate") this.strokeRate = 0, + @JsonKey(name: "machine") this.machine = "rower", + @JsonKey(name: "rest_distance") this.restDistance = "0"}) + : super._(); + + factory _$C2IntervalsImpl.fromJson(Map json) => + _$$C2IntervalsImplFromJson(json); + + @override + @JsonKey(name: "type") + final String type; + @override + @JsonKey(name: "time") + final int time; + @override + @JsonKey(name: "calories_total") + final int calories; + @override + @JsonKey(name: "stroke_rate") + final int strokeRate; + @override + @JsonKey(name: "machine") + final String machine; + @override + @JsonKey(name: "rest_distance") + final int restDistance; + + @override + String toString() { + return 'C2Intervals(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2IntervalsImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time) && + (identical(other.calories, calories) || + other.calories == calories) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && + (identical(other.machine, machine) || other.machine == machine) && + (identical(other.restDistance, restDistance) || + other.restDistance == restDistance)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, type, time, calories, strokeRate, machine, restDistance); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2IntervalsImplCopyWith<_$C2IntervalsImpl> get copyWith => + __$$C2IntervalsImplCopyWithImpl<_$C2IntervalsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2IntervalsImplToJson( + this, + ); + } +} + +abstract class _C2Intervals extends C2Intervals { + factory _C2Intervals( + {@JsonKey(name: "type") final String type, + @JsonKey(name: "time") final int time, + @JsonKey(name: "calories_total") final int calories, + @JsonKey(name: "stroke_rate") final int strokeRate, + @JsonKey(name: "machine") final String machine, + @JsonKey(name: "rest_distance") final int restDistance}) = + _$C2IntervalsImpl; + _C2Intervals._() : super._(); + + factory _C2Intervals.fromJson(Map json) = + _$C2IntervalsImpl.fromJson; + + @override + @JsonKey(name: "type") + String get type; + @override + @JsonKey(name: "time") + int get time; + @override + @JsonKey(name: "calories_total") + int get calories; + @override + @JsonKey(name: "stroke_rate") + int get strokeRate; + @override + @JsonKey(name: "machine") + String get machine; + @override + @JsonKey(name: "rest_distance") + int get restDistance; + @override + @JsonKey(ignore: true) + _$$C2IntervalsImplCopyWith<_$C2IntervalsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2Results _$C2ResultsFromJson(Map json) { + return _C2Results.fromJson(json); +} + +/// @nodoc +mixin _$C2Results { + int get id => throw _privateConstructorUsedError; + @JsonKey(name: "user_id") + int get userId => throw _privateConstructorUsedError; + @JsonKey(name: "date") + @TimestampConverter() + DateTime get endDate => throw _privateConstructorUsedError; + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + DateTime? get dateUtc => throw _privateConstructorUsedError; + String? get timezone => throw _privateConstructorUsedError; + int get distance => throw _privateConstructorUsedError; + C2ResultType get type => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get time => throw _privateConstructorUsedError; + @JsonKey(name: "workout_type") + C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; + String get source => throw _privateConstructorUsedError; + @JsonKey(name: "weight_class") + C2WeightClass get weightClass => throw _privateConstructorUsedError; + @JsonKey(name: "stroke_rate") + int? get strokeRate => throw _privateConstructorUsedError; + bool get verified => throw _privateConstructorUsedError; + bool get ranked => throw _privateConstructorUsedError; + String? get comments => throw _privateConstructorUsedError; + C2PrivacyLevel get privacy => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2ResultsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2ResultsCopyWith<$Res> { + factory $C2ResultsCopyWith(C2Results value, $Res Function(C2Results) then) = + _$C2ResultsCopyWithImpl<$Res, C2Results>; + @useResult + $Res call( + {int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "date") @TimestampConverter() DateTime endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + String? timezone, + int distance, + C2ResultType type, + @DecimalIntConverter.tenths() double time, + @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + String source, + @JsonKey(name: "weight_class") C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") int? strokeRate, + bool verified, + bool ranked, + String? comments, + C2PrivacyLevel privacy}); +} + +/// @nodoc +class _$C2ResultsCopyWithImpl<$Res, $Val extends C2Results> + implements $C2ResultsCopyWith<$Res> { + _$C2ResultsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? endDate = null, + Object? dateUtc = freezed, + Object? timezone = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, + Object? strokeRate = freezed, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2ResultsImplCopyWith<$Res> + implements $C2ResultsCopyWith<$Res> { + factory _$$C2ResultsImplCopyWith( + _$C2ResultsImpl value, $Res Function(_$C2ResultsImpl) then) = + __$$C2ResultsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, + @JsonKey(name: "user_id") int userId, + @JsonKey(name: "date") @TimestampConverter() DateTime endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + String? timezone, + int distance, + C2ResultType type, + @DecimalIntConverter.tenths() double time, + @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + String source, + @JsonKey(name: "weight_class") C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") int? strokeRate, + bool verified, + bool ranked, + String? comments, + C2PrivacyLevel privacy}); +} + +/// @nodoc +class __$$C2ResultsImplCopyWithImpl<$Res> + extends _$C2ResultsCopyWithImpl<$Res, _$C2ResultsImpl> + implements _$$C2ResultsImplCopyWith<$Res> { + __$$C2ResultsImplCopyWithImpl( + _$C2ResultsImpl _value, $Res Function(_$C2ResultsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userId = null, + Object? endDate = null, + Object? dateUtc = freezed, + Object? timezone = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, + Object? strokeRate = freezed, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + }) { + return _then(_$C2ResultsImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + endDate: null == endDate + ? _value.endDate + : endDate // ignore: cast_nullable_to_non_nullable + as DateTime, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2ResultsImpl extends _C2Results { + _$C2ResultsImpl( + {this.id = 0, + @JsonKey(name: "user_id") this.userId = 0, + @JsonKey(name: "date") @TimestampConverter() required this.endDate, + @JsonKey(name: "date_utc") @TimestampOrNullConverter() this.dateUtc, + this.timezone, + this.distance = 0, + this.type = C2ResultType.rower, + @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: "workout_type") + this.workoutType = C2APIWorkoutType.JustRow, + this.source = "c2logbook dart", + @JsonKey(name: "weight_class") + this.weightClass = C2WeightClass.heavyweight, + @JsonKey(name: "stroke_rate") this.strokeRate, + this.verified = false, + this.ranked = false, + this.comments, + this.privacy = C2PrivacyLevel.private}) + : super._(); + + factory _$C2ResultsImpl.fromJson(Map json) => + _$$C2ResultsImplFromJson(json); + + @override + @JsonKey() + final int id; + @override + @JsonKey(name: "user_id") + final int userId; + @override + @JsonKey(name: "date") + @TimestampConverter() + final DateTime endDate; + @override + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + final DateTime? dateUtc; + @override + final String? timezone; + @override + @JsonKey() + final int distance; + @override + @JsonKey() + final C2ResultType type; + @override + @DecimalIntConverter.tenths() + final double time; + @override + @JsonKey(name: "workout_type") + final C2APIWorkoutType workoutType; + @override + @JsonKey() + final String source; + @override + @JsonKey(name: "weight_class") + final C2WeightClass weightClass; + @override + @JsonKey(name: "stroke_rate") + final int? strokeRate; + @override + @JsonKey() + final bool verified; + @override + @JsonKey() + final bool ranked; + @override + final String? comments; + @override + @JsonKey() + final C2PrivacyLevel privacy; + + @override + String toString() { + return 'C2Results(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2ResultsImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.endDate, endDate) || other.endDate == endDate) && + (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && + (identical(other.timezone, timezone) || + other.timezone == timezone) && + (identical(other.distance, distance) || + other.distance == distance) && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time) && + (identical(other.workoutType, workoutType) || + other.workoutType == workoutType) && + (identical(other.source, source) || other.source == source) && + (identical(other.weightClass, weightClass) || + other.weightClass == weightClass) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && + (identical(other.verified, verified) || + other.verified == verified) && + (identical(other.ranked, ranked) || other.ranked == ranked) && + (identical(other.comments, comments) || + other.comments == comments) && + (identical(other.privacy, privacy) || other.privacy == privacy)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + id, + userId, + endDate, + dateUtc, + timezone, + distance, + type, + time, + workoutType, + source, + weightClass, + strokeRate, + verified, + ranked, + comments, + privacy); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2ResultsImplCopyWith<_$C2ResultsImpl> get copyWith => + __$$C2ResultsImplCopyWithImpl<_$C2ResultsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2ResultsImplToJson( + this, + ); + } +} + +abstract class _C2Results extends C2Results { + factory _C2Results( + {final int id, + @JsonKey(name: "user_id") final int userId, + @JsonKey(name: "date") + @TimestampConverter() + required final DateTime endDate, + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + final DateTime? dateUtc, + final String? timezone, + final int distance, + final C2ResultType type, + @DecimalIntConverter.tenths() required final double time, + @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, + final String source, + @JsonKey(name: "weight_class") final C2WeightClass weightClass, + @JsonKey(name: "stroke_rate") final int? strokeRate, + final bool verified, + final bool ranked, + final String? comments, + final C2PrivacyLevel privacy}) = _$C2ResultsImpl; + _C2Results._() : super._(); + + factory _C2Results.fromJson(Map json) = + _$C2ResultsImpl.fromJson; + + @override + int get id; + @override + @JsonKey(name: "user_id") + int get userId; + @override + @JsonKey(name: "date") + @TimestampConverter() + DateTime get endDate; + @override + @JsonKey(name: "date_utc") + @TimestampOrNullConverter() + DateTime? get dateUtc; + @override + String? get timezone; + @override + int get distance; + @override + C2ResultType get type; + @override + @DecimalIntConverter.tenths() + double get time; + @override + @JsonKey(name: "workout_type") + C2APIWorkoutType get workoutType; + @override + String get source; + @override + @JsonKey(name: "weight_class") + C2WeightClass get weightClass; + @override + @JsonKey(name: "stroke_rate") + int? get strokeRate; + @override + bool get verified; + @override + bool get ranked; + @override + String? get comments; + @override + C2PrivacyLevel get privacy; + @override + @JsonKey(ignore: true) + _$$C2ResultsImplCopyWith<_$C2ResultsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2User _$C2UserFromJson(Map json) { + return _C2User.fromJson(json); +} + +/// @nodoc +mixin _$C2User { + int get id => throw _privateConstructorUsedError; + String get username => throw _privateConstructorUsedError; + @JsonKey(name: 'first_name') + String get firstName => throw _privateConstructorUsedError; + @JsonKey(name: 'last_name') + String get lastName => throw _privateConstructorUsedError; + String get gender => throw _privateConstructorUsedError; + @JsonKey(name: 'dob') + String get birthday => throw _privateConstructorUsedError; + String get email => throw _privateConstructorUsedError; + String get country => throw _privateConstructorUsedError; + @JsonKey(name: 'profile_image') + String? get profileImage => throw _privateConstructorUsedError; + @JsonKey(name: 'age_restricted') + bool get ageRestricted => throw _privateConstructorUsedError; + @JsonKey(name: 'email_permission') + bool get emailPermission => throw _privateConstructorUsedError; + @JsonKey(name: 'max_heart_rate') + int? get maxHeartRate => throw _privateConstructorUsedError; + int? get weight => throw _privateConstructorUsedError; + List get roles => throw _privateConstructorUsedError; + @JsonKey(name: 'logbook_privacy') + C2PrivacyLevel get logbookPrivacy => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2UserCopyWith get copyWith => throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2UserCopyWith<$Res> { + factory $C2UserCopyWith(C2User value, $Res Function(C2User) then) = + _$C2UserCopyWithImpl<$Res, C2User>; + @useResult + $Res call( + {int id, + String username, + @JsonKey(name: 'first_name') String firstName, + @JsonKey(name: 'last_name') String lastName, + String gender, + @JsonKey(name: 'dob') String birthday, + String email, + String country, + @JsonKey(name: 'profile_image') String? profileImage, + @JsonKey(name: 'age_restricted') bool ageRestricted, + @JsonKey(name: 'email_permission') bool emailPermission, + @JsonKey(name: 'max_heart_rate') int? maxHeartRate, + int? weight, + List roles, + @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); +} + +/// @nodoc +class _$C2UserCopyWithImpl<$Res, $Val extends C2User> + implements $C2UserCopyWith<$Res> { + _$C2UserCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? username = null, + Object? firstName = null, + Object? lastName = null, + Object? gender = null, + Object? birthday = null, + Object? email = null, + Object? country = null, + Object? profileImage = freezed, + Object? ageRestricted = null, + Object? emailPermission = null, + Object? maxHeartRate = freezed, + Object? weight = freezed, + Object? roles = null, + Object? logbookPrivacy = null, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + username: null == username + ? _value.username + : username // ignore: cast_nullable_to_non_nullable + as String, + firstName: null == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String, + lastName: null == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String, + gender: null == gender + ? _value.gender + : gender // ignore: cast_nullable_to_non_nullable + as String, + birthday: null == birthday + ? _value.birthday + : birthday // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + profileImage: freezed == profileImage + ? _value.profileImage + : profileImage // ignore: cast_nullable_to_non_nullable + as String?, + ageRestricted: null == ageRestricted + ? _value.ageRestricted + : ageRestricted // ignore: cast_nullable_to_non_nullable + as bool, + emailPermission: null == emailPermission + ? _value.emailPermission + : emailPermission // ignore: cast_nullable_to_non_nullable + as bool, + maxHeartRate: freezed == maxHeartRate + ? _value.maxHeartRate + : maxHeartRate // ignore: cast_nullable_to_non_nullable + as int?, + weight: freezed == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as int?, + roles: null == roles + ? _value.roles + : roles // ignore: cast_nullable_to_non_nullable + as List, + logbookPrivacy: null == logbookPrivacy + ? _value.logbookPrivacy + : logbookPrivacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2UserImplCopyWith<$Res> implements $C2UserCopyWith<$Res> { + factory _$$C2UserImplCopyWith( + _$C2UserImpl value, $Res Function(_$C2UserImpl) then) = + __$$C2UserImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {int id, + String username, + @JsonKey(name: 'first_name') String firstName, + @JsonKey(name: 'last_name') String lastName, + String gender, + @JsonKey(name: 'dob') String birthday, + String email, + String country, + @JsonKey(name: 'profile_image') String? profileImage, + @JsonKey(name: 'age_restricted') bool ageRestricted, + @JsonKey(name: 'email_permission') bool emailPermission, + @JsonKey(name: 'max_heart_rate') int? maxHeartRate, + int? weight, + List roles, + @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); +} + +/// @nodoc +class __$$C2UserImplCopyWithImpl<$Res> + extends _$C2UserCopyWithImpl<$Res, _$C2UserImpl> + implements _$$C2UserImplCopyWith<$Res> { + __$$C2UserImplCopyWithImpl( + _$C2UserImpl _value, $Res Function(_$C2UserImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? username = null, + Object? firstName = null, + Object? lastName = null, + Object? gender = null, + Object? birthday = null, + Object? email = null, + Object? country = null, + Object? profileImage = freezed, + Object? ageRestricted = null, + Object? emailPermission = null, + Object? maxHeartRate = freezed, + Object? weight = freezed, + Object? roles = null, + Object? logbookPrivacy = null, + }) { + return _then(_$C2UserImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as int, + username: null == username + ? _value.username + : username // ignore: cast_nullable_to_non_nullable + as String, + firstName: null == firstName + ? _value.firstName + : firstName // ignore: cast_nullable_to_non_nullable + as String, + lastName: null == lastName + ? _value.lastName + : lastName // ignore: cast_nullable_to_non_nullable + as String, + gender: null == gender + ? _value.gender + : gender // ignore: cast_nullable_to_non_nullable + as String, + birthday: null == birthday + ? _value.birthday + : birthday // ignore: cast_nullable_to_non_nullable + as String, + email: null == email + ? _value.email + : email // ignore: cast_nullable_to_non_nullable + as String, + country: null == country + ? _value.country + : country // ignore: cast_nullable_to_non_nullable + as String, + profileImage: freezed == profileImage + ? _value.profileImage + : profileImage // ignore: cast_nullable_to_non_nullable + as String?, + ageRestricted: null == ageRestricted + ? _value.ageRestricted + : ageRestricted // ignore: cast_nullable_to_non_nullable + as bool, + emailPermission: null == emailPermission + ? _value.emailPermission + : emailPermission // ignore: cast_nullable_to_non_nullable + as bool, + maxHeartRate: freezed == maxHeartRate + ? _value.maxHeartRate + : maxHeartRate // ignore: cast_nullable_to_non_nullable + as int?, + weight: freezed == weight + ? _value.weight + : weight // ignore: cast_nullable_to_non_nullable + as int?, + roles: null == roles + ? _value._roles + : roles // ignore: cast_nullable_to_non_nullable + as List, + logbookPrivacy: null == logbookPrivacy + ? _value.logbookPrivacy + : logbookPrivacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2UserImpl implements _C2User { + const _$C2UserImpl( + {this.id = 0, + this.username = '', + @JsonKey(name: 'first_name') this.firstName = '', + @JsonKey(name: 'last_name') this.lastName = '', + this.gender = 'F', + @JsonKey(name: 'dob') this.birthday = '1970-01-01', + this.email = '', + this.country = '', + @JsonKey(name: 'profile_image') this.profileImage, + @JsonKey(name: 'age_restricted') this.ageRestricted = false, + @JsonKey(name: 'email_permission') this.emailPermission = false, + @JsonKey(name: 'max_heart_rate') this.maxHeartRate, + this.weight, + final List roles = const [], + @JsonKey(name: 'logbook_privacy') + this.logbookPrivacy = C2PrivacyLevel.private}) + : _roles = roles; + + factory _$C2UserImpl.fromJson(Map json) => + _$$C2UserImplFromJson(json); + + @override + @JsonKey() + final int id; + @override + @JsonKey() + final String username; + @override + @JsonKey(name: 'first_name') + final String firstName; + @override + @JsonKey(name: 'last_name') + final String lastName; + @override + @JsonKey() + final String gender; + @override + @JsonKey(name: 'dob') + final String birthday; + @override + @JsonKey() + final String email; + @override + @JsonKey() + final String country; + @override + @JsonKey(name: 'profile_image') + final String? profileImage; + @override + @JsonKey(name: 'age_restricted') + final bool ageRestricted; + @override + @JsonKey(name: 'email_permission') + final bool emailPermission; + @override + @JsonKey(name: 'max_heart_rate') + final int? maxHeartRate; + @override + final int? weight; + final List _roles; + @override + @JsonKey() + List get roles { + if (_roles is EqualUnmodifiableListView) return _roles; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_roles); + } + + @override + @JsonKey(name: 'logbook_privacy') + final C2PrivacyLevel logbookPrivacy; + + @override + String toString() { + return 'C2User(id: $id, username: $username, firstName: $firstName, lastName: $lastName, gender: $gender, birthday: $birthday, email: $email, country: $country, profileImage: $profileImage, ageRestricted: $ageRestricted, emailPermission: $emailPermission, maxHeartRate: $maxHeartRate, weight: $weight, roles: $roles, logbookPrivacy: $logbookPrivacy)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2UserImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.username, username) || + other.username == username) && + (identical(other.firstName, firstName) || + other.firstName == firstName) && + (identical(other.lastName, lastName) || + other.lastName == lastName) && + (identical(other.gender, gender) || other.gender == gender) && + (identical(other.birthday, birthday) || + other.birthday == birthday) && + (identical(other.email, email) || other.email == email) && + (identical(other.country, country) || other.country == country) && + (identical(other.profileImage, profileImage) || + other.profileImage == profileImage) && + (identical(other.ageRestricted, ageRestricted) || + other.ageRestricted == ageRestricted) && + (identical(other.emailPermission, emailPermission) || + other.emailPermission == emailPermission) && + (identical(other.maxHeartRate, maxHeartRate) || + other.maxHeartRate == maxHeartRate) && + (identical(other.weight, weight) || other.weight == weight) && + const DeepCollectionEquality().equals(other._roles, _roles) && + (identical(other.logbookPrivacy, logbookPrivacy) || + other.logbookPrivacy == logbookPrivacy)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + id, + username, + firstName, + lastName, + gender, + birthday, + email, + country, + profileImage, + ageRestricted, + emailPermission, + maxHeartRate, + weight, + const DeepCollectionEquality().hash(_roles), + logbookPrivacy); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2UserImplCopyWith<_$C2UserImpl> get copyWith => + __$$C2UserImplCopyWithImpl<_$C2UserImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2UserImplToJson( + this, + ); + } +} + +abstract class _C2User implements C2User { + const factory _C2User( + {final int id, + final String username, + @JsonKey(name: 'first_name') final String firstName, + @JsonKey(name: 'last_name') final String lastName, + final String gender, + @JsonKey(name: 'dob') final String birthday, + final String email, + final String country, + @JsonKey(name: 'profile_image') final String? profileImage, + @JsonKey(name: 'age_restricted') final bool ageRestricted, + @JsonKey(name: 'email_permission') final bool emailPermission, + @JsonKey(name: 'max_heart_rate') final int? maxHeartRate, + final int? weight, + final List roles, + @JsonKey(name: 'logbook_privacy') + final C2PrivacyLevel logbookPrivacy}) = _$C2UserImpl; + + factory _C2User.fromJson(Map json) = _$C2UserImpl.fromJson; + + @override + int get id; + @override + String get username; + @override + @JsonKey(name: 'first_name') + String get firstName; + @override + @JsonKey(name: 'last_name') + String get lastName; + @override + String get gender; + @override + @JsonKey(name: 'dob') + String get birthday; + @override + String get email; + @override + String get country; + @override + @JsonKey(name: 'profile_image') + String? get profileImage; + @override + @JsonKey(name: 'age_restricted') + bool get ageRestricted; + @override + @JsonKey(name: 'email_permission') + bool get emailPermission; + @override + @JsonKey(name: 'max_heart_rate') + int? get maxHeartRate; + @override + int? get weight; + @override + List get roles; + @override + @JsonKey(name: 'logbook_privacy') + C2PrivacyLevel get logbookPrivacy; + @override + @JsonKey(ignore: true) + _$$C2UserImplCopyWith<_$C2UserImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart new file mode 100644 index 0000000..3c1850c --- /dev/null +++ b/lib/src/types/index.g.dart @@ -0,0 +1,217 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'index.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => + _$C2FullResultsImpl( + id: json['id'] as int? ?? 0, + userId: json['user_id'] as int? ?? 0, + endDate: const TimestampConverter().fromJson(json['date'] as String), + dateUtc: const TimestampOrNullConverter() + .fromJson(json['date_utc'] as String?), + timezone: json['timezone'] as String?, + distance: json['distance'] as int? ?? 0, + type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? + C2ResultType.rower, + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + workoutType: $enumDecodeNullable( + _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? + C2APIWorkoutType.JustRow, + source: json['source'] as String? ?? "c2logbook dart", + weightClass: + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? + C2WeightClass.heavyweight, + strokeRate: json['stroke_rate'] as int?, + verified: json['verified'] as bool? ?? false, + ranked: json['ranked'] as bool? ?? false, + comments: json['comments'] as String?, + privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? + C2PrivacyLevel.private, + ); + +Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'date': const TimestampConverter().toJson(instance.endDate), + 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'timezone': instance.timezone, + 'distance': instance.distance, + 'type': _$C2ResultTypeEnumMap[instance.type]!, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'source': instance.source, + 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, + 'stroke_rate': instance.strokeRate, + 'verified': instance.verified, + 'ranked': instance.ranked, + 'comments': instance.comments, + 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, + }; + +const _$C2ResultTypeEnumMap = { + C2ResultType.rower: 'rower', + C2ResultType.skierg: 'skierg', + C2ResultType.bike: 'bike', + C2ResultType.dynamic: 'dynamic', + C2ResultType.slides: 'slides', + C2ResultType.paddle: 'paddle', + C2ResultType.water: 'water', + C2ResultType.snow: 'snow', + C2ResultType.rollerski: 'rollerski', + C2ResultType.multierg: 'multierg', +}; + +const _$C2APIWorkoutTypeEnumMap = { + C2APIWorkoutType.unknown: 'unknown', + C2APIWorkoutType.JustRow: 'JustRow', + C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', + C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', + C2APIWorkoutType.FixedCalorie: 'FixedCalorie', + C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', + C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', + C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', + C2APIWorkoutType.VariableInterval: 'VariableInterval', + C2APIWorkoutType.VariableIntervalUndefinedRest: + 'VariableIntervalUndefinedRest', +}; + +const _$C2WeightClassEnumMap = { + C2WeightClass.lightweight: 'L', + C2WeightClass.heavyweight: 'H', +}; + +const _$C2PrivacyLevelEnumMap = { + C2PrivacyLevel.private: 'private', + C2PrivacyLevel.partners: 'partners', + C2PrivacyLevel.logged_in: 'logged_in', + C2PrivacyLevel.everyone: 'everyone', +}; + +_$C2HeartRateImpl _$$C2HeartRateImplFromJson(Map json) => + _$C2HeartRateImpl( + min: json['min'] as int? ?? 0, + average: json['average'] as int? ?? 0, + max: json['max'] as int? ?? 0, + ending: json['ending'] as int? ?? 0, + ); + +Map _$$C2HeartRateImplToJson(_$C2HeartRateImpl instance) => + { + 'min': instance.min, + 'average': instance.average, + 'max': instance.max, + 'ending': instance.ending, + }; + +_$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => + _$C2IntervalsImpl( + type: json['type'] as String? ?? "time", + time: json['time'] as int? ?? 0, + calories: json['calories_total'] as int? ?? 0, + strokeRate: json['stroke_rate'] as int? ?? 0, + machine: json['machine'] as String? ?? "rower", + restDistance: json['rest_distance'] as int? ?? "0", + ); + +Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => + { + 'type': instance.type, + 'time': instance.time, + 'calories_total': instance.calories, + 'stroke_rate': instance.strokeRate, + 'machine': instance.machine, + 'rest_distance': instance.restDistance, + }; + +_$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => + _$C2ResultsImpl( + id: json['id'] as int? ?? 0, + userId: json['user_id'] as int? ?? 0, + endDate: const TimestampConverter().fromJson(json['date'] as String), + dateUtc: const TimestampOrNullConverter() + .fromJson(json['date_utc'] as String?), + timezone: json['timezone'] as String?, + distance: json['distance'] as int? ?? 0, + type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? + C2ResultType.rower, + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + workoutType: $enumDecodeNullable( + _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? + C2APIWorkoutType.JustRow, + source: json['source'] as String? ?? "c2logbook dart", + weightClass: + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? + C2WeightClass.heavyweight, + strokeRate: json['stroke_rate'] as int?, + verified: json['verified'] as bool? ?? false, + ranked: json['ranked'] as bool? ?? false, + comments: json['comments'] as String?, + privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? + C2PrivacyLevel.private, + ); + +Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => + { + 'id': instance.id, + 'user_id': instance.userId, + 'date': const TimestampConverter().toJson(instance.endDate), + 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'timezone': instance.timezone, + 'distance': instance.distance, + 'type': _$C2ResultTypeEnumMap[instance.type]!, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'source': instance.source, + 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, + 'stroke_rate': instance.strokeRate, + 'verified': instance.verified, + 'ranked': instance.ranked, + 'comments': instance.comments, + 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, + }; + +_$C2UserImpl _$$C2UserImplFromJson(Map json) => _$C2UserImpl( + id: json['id'] as int? ?? 0, + username: json['username'] as String? ?? '', + firstName: json['first_name'] as String? ?? '', + lastName: json['last_name'] as String? ?? '', + gender: json['gender'] as String? ?? 'F', + birthday: json['dob'] as String? ?? '1970-01-01', + email: json['email'] as String? ?? '', + country: json['country'] as String? ?? '', + profileImage: json['profile_image'] as String?, + ageRestricted: json['age_restricted'] as bool? ?? false, + emailPermission: json['email_permission'] as bool? ?? false, + maxHeartRate: json['max_heart_rate'] as int?, + weight: json['weight'] as int?, + roles: + (json['roles'] as List?)?.map((e) => e as String).toList() ?? + const [], + logbookPrivacy: $enumDecodeNullable( + _$C2PrivacyLevelEnumMap, json['logbook_privacy']) ?? + C2PrivacyLevel.private, + ); + +Map _$$C2UserImplToJson(_$C2UserImpl instance) => + { + 'id': instance.id, + 'username': instance.username, + 'first_name': instance.firstName, + 'last_name': instance.lastName, + 'gender': instance.gender, + 'dob': instance.birthday, + 'email': instance.email, + 'country': instance.country, + 'profile_image': instance.profileImage, + 'age_restricted': instance.ageRestricted, + 'email_permission': instance.emailPermission, + 'max_heart_rate': instance.maxHeartRate, + 'weight': instance.weight, + 'roles': instance.roles, + 'logbook_privacy': _$C2PrivacyLevelEnumMap[instance.logbookPrivacy]!, + }; From 76303b65535a6f9b821e11398711cadaa6c8167a Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Mon, 11 Mar 2024 12:38:15 -0400 Subject: [PATCH 03/25] Biiiiig refactor --- build.yaml | 14 + example/pubspec.lock | 48 +- lib/c2logbook.dart | 5 - lib/src/c2logbook_base.dart | 1 + lib/src/types/c2_full_results.dart | 42 ++ lib/src/types/c2_heart_rate.dart | 19 + lib/src/types/c2_intervals.dart | 22 + lib/src/types/c2_results.dart | 16 +- lib/src/types/c2_results.freezed.dart | 520 ----------------- lib/src/types/c2_results.g.dart | 93 --- lib/src/types/c2_splits.dart | 22 + lib/src/types/c2_type_extensions.dart | 2 +- lib/src/types/c2_types.dart | 2 +- lib/src/types/c2_user.dart | 21 +- lib/src/types/c2_user.freezed.dart | 495 ---------------- lib/src/types/c2_user.g.dart | 55 -- lib/src/types/c2_webhook_result.dart | 2 +- lib/src/types/index.dart | 14 + lib/src/types/index.freezed.dart | 801 ++++++++++++++++++-------- lib/src/types/index.g.dart | 134 +++-- test/c2logbook_test.dart | 1 + 21 files changed, 844 insertions(+), 1485 deletions(-) create mode 100644 build.yaml create mode 100644 lib/src/types/c2_full_results.dart create mode 100644 lib/src/types/c2_heart_rate.dart create mode 100644 lib/src/types/c2_intervals.dart delete mode 100644 lib/src/types/c2_results.freezed.dart delete mode 100644 lib/src/types/c2_results.g.dart create mode 100644 lib/src/types/c2_splits.dart delete mode 100644 lib/src/types/c2_user.freezed.dart delete mode 100644 lib/src/types/c2_user.g.dart create mode 100644 lib/src/types/index.dart diff --git a/build.yaml b/build.yaml new file mode 100644 index 0000000..6129904 --- /dev/null +++ b/build.yaml @@ -0,0 +1,14 @@ +targets: + $default: + builders: + json_serializable: + generate_for: + - "**/types/**.dart" + options: + explicit_to_json: true + freezed: + generate_for: + - "**/types/**.dart" + options: + maybe_when: false + maybe_map: false \ No newline at end of file diff --git a/example/pubspec.lock b/example/pubspec.lock index fe1f010..9fecb96 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -122,6 +122,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -134,26 +158,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" nested: dependency: transitive description: @@ -174,10 +198,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" provider: dependency: "direct main" description: @@ -255,6 +279,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + url: "https://pub.dev" + source: hosted + version: "13.0.0" web: dependency: transitive description: diff --git a/lib/c2logbook.dart b/lib/c2logbook.dart index 61ca7a6..c952af3 100644 --- a/lib/c2logbook.dart +++ b/lib/c2logbook.dart @@ -4,10 +4,5 @@ library; export 'src/c2logbook_base.dart'; -export 'src/types/c2_user.dart'; -export 'src/types/c2_types.dart'; -export 'src/types/c2_results.dart'; -export 'src/types/c2_webhook_result.dart'; -export 'src/types/c2_types.dart'; // TODO: Export any libraries intended for clients of this package. diff --git a/lib/src/c2logbook_base.dart b/lib/src/c2logbook_base.dart index 4c5eac9..ddacf4d 100644 --- a/lib/src/c2logbook_base.dart +++ b/lib/src/c2logbook_base.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'types/index.dart'; import 'package:oauth2/oauth2.dart' as oauth2; import 'package:http/http.dart' as http; diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart new file mode 100644 index 0000000..7cee125 --- /dev/null +++ b/lib/src/types/c2_full_results.dart @@ -0,0 +1,42 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2FullResults with _$C2FullResults { + //TODO: figure out how to get this into JSON as time_formatted + String get timeFormatted => Duration( + seconds: this.time.toInt(), + milliseconds: + (this.time.remainder(1) * Duration.millisecondsPerSecond).toInt()) + .toString(); + + C2FullResults._(); + + factory C2FullResults({ + @Default(0) int id, + @Default(0) int userId, + @TimestampConverter() required DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, + String? timezone, + @Default(0) int distance, + @Default(C2ResultType.rower) C2ResultType type, + @DecimalIntConverter.tenths() required double time, + @Default(C2APIWorkoutType.JustRow) + C2APIWorkoutType workoutType, + @Default("c2logbook dart") String source, + @Default(C2WeightClass.heavyweight) + C2WeightClass weightClass, + int? strokeRate, + @Default(false) bool verified, + @Default(false) bool ranked, + String? comments, + @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + @Default([]) List intervals, + @Default([]) List splits, + @Default(null) C2HeartRate heartRate, + }) = _C2FullResults; + + factory C2FullResults.fromJson(Map json) => + _$C2FullResultsFromJson(Map.from(json)); +} diff --git a/lib/src/types/c2_heart_rate.dart b/lib/src/types/c2_heart_rate.dart new file mode 100644 index 0000000..f7bbae9 --- /dev/null +++ b/lib/src/types/c2_heart_rate.dart @@ -0,0 +1,19 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2HeartRate with _$C2HeartRate { + + C2HeartRate._(); + + factory C2HeartRate({ + @Default(0) int min, + @Default(0) int average, + @Default(0) int max, + @Default(0) int ending, + }) = _C2HeartRate; + + factory C2HeartRate.fromJson(Map json) => + _$C2HeartRateFromJson(Map.from(json)); +} diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart new file mode 100644 index 0000000..8a11c79 --- /dev/null +++ b/lib/src/types/c2_intervals.dart @@ -0,0 +1,22 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Intervals with _$C2Intervals { + + C2Intervals._(); + + factory C2Intervals({ + @Default("time") String type, + @Default(0) int time, + @Default(0) int calories, + @Default(0) int strokeRate, + @Default("rower") String machine, + @Default("0") int restDistance, + @Default(null) C2HeartRate heartRate, + }) = _C2Intervals; + + factory C2Intervals.fromJson(Map json) => + _$C2IntervalsFromJson(Map.from(json)); +} diff --git a/lib/src/types/c2_results.dart b/lib/src/types/c2_results.dart index 1f4119f..bcefdec 100644 --- a/lib/src/types/c2_results.dart +++ b/lib/src/types/c2_results.dart @@ -1,12 +1,6 @@ // ignore_for_file: invalid_annotation_target -import 'c2_types.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -import '../utils.dart'; - -part 'c2_results.freezed.dart'; -part 'c2_results.g.dart'; +part of 'index.dart'; @freezed class C2Results with _$C2Results { @@ -21,9 +15,9 @@ class C2Results with _$C2Results { factory C2Results({ @Default(0) int id, - @JsonKey(name: "user_id") @Default(0) int userId, - @JsonKey(name: "date") @TimestampConverter() required DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + @Default(0) int userId, + @TimestampConverter() required DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, @Default(0) int distance, @Default(C2ResultType.rower) C2ResultType type, @@ -35,7 +29,7 @@ class C2Results with _$C2Results { @JsonKey(name: "weight_class") @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, + int? strokeRate, @Default(false) bool verified, @Default(false) bool ranked, String? comments, diff --git a/lib/src/types/c2_results.freezed.dart b/lib/src/types/c2_results.freezed.dart deleted file mode 100644 index 0deb7f0..0000000 --- a/lib/src/types/c2_results.freezed.dart +++ /dev/null @@ -1,520 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'c2_results.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -C2Results _$C2ResultsFromJson(Map json) { - return _C2Results.fromJson(json); -} - -/// @nodoc -mixin _$C2Results { - int get id => throw _privateConstructorUsedError; - @JsonKey(name: "user_id") - int get userId => throw _privateConstructorUsedError; - @JsonKey(name: "date") - @TimestampConverter() - DateTime get endDate => throw _privateConstructorUsedError; - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - DateTime? get dateUtc => throw _privateConstructorUsedError; - String? get timezone => throw _privateConstructorUsedError; - int get distance => throw _privateConstructorUsedError; - C2ResultType get type => throw _privateConstructorUsedError; - @DecimalIntConverter.tenths() - double get time => throw _privateConstructorUsedError; - @JsonKey(name: "workout_type") - C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; - String get source => throw _privateConstructorUsedError; - @JsonKey(name: "weight_class") - C2WeightClass get weightClass => throw _privateConstructorUsedError; - @JsonKey(name: "stroke_rate") - int? get strokeRate => throw _privateConstructorUsedError; - bool get verified => throw _privateConstructorUsedError; - bool get ranked => throw _privateConstructorUsedError; - String? get comments => throw _privateConstructorUsedError; - C2PrivacyLevel get privacy => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $C2ResultsCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $C2ResultsCopyWith<$Res> { - factory $C2ResultsCopyWith(C2Results value, $Res Function(C2Results) then) = - _$C2ResultsCopyWithImpl<$Res, C2Results>; - @useResult - $Res call( - {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, - String? timezone, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, - String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy}); -} - -/// @nodoc -class _$C2ResultsCopyWithImpl<$Res, $Val extends C2Results> - implements $C2ResultsCopyWith<$Res> { - _$C2ResultsCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? userId = null, - Object? endDate = null, - Object? dateUtc = freezed, - Object? timezone = freezed, - Object? distance = null, - Object? type = null, - Object? time = null, - Object? workoutType = null, - Object? source = null, - Object? weightClass = null, - Object? strokeRate = freezed, - Object? verified = null, - Object? ranked = null, - Object? comments = freezed, - Object? privacy = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - userId: null == userId - ? _value.userId - : userId // ignore: cast_nullable_to_non_nullable - as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable - as DateTime, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, - timezone: freezed == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String?, - distance: null == distance - ? _value.distance - : distance // ignore: cast_nullable_to_non_nullable - as int, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as C2ResultType, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as double, - workoutType: null == workoutType - ? _value.workoutType - : workoutType // ignore: cast_nullable_to_non_nullable - as C2APIWorkoutType, - source: null == source - ? _value.source - : source // ignore: cast_nullable_to_non_nullable - as String, - weightClass: null == weightClass - ? _value.weightClass - : weightClass // ignore: cast_nullable_to_non_nullable - as C2WeightClass, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, - verified: null == verified - ? _value.verified - : verified // ignore: cast_nullable_to_non_nullable - as bool, - ranked: null == ranked - ? _value.ranked - : ranked // ignore: cast_nullable_to_non_nullable - as bool, - comments: freezed == comments - ? _value.comments - : comments // ignore: cast_nullable_to_non_nullable - as String?, - privacy: null == privacy - ? _value.privacy - : privacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$C2ResultsImplCopyWith<$Res> - implements $C2ResultsCopyWith<$Res> { - factory _$$C2ResultsImplCopyWith( - _$C2ResultsImpl value, $Res Function(_$C2ResultsImpl) then) = - __$$C2ResultsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, - String? timezone, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, - String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy}); -} - -/// @nodoc -class __$$C2ResultsImplCopyWithImpl<$Res> - extends _$C2ResultsCopyWithImpl<$Res, _$C2ResultsImpl> - implements _$$C2ResultsImplCopyWith<$Res> { - __$$C2ResultsImplCopyWithImpl( - _$C2ResultsImpl _value, $Res Function(_$C2ResultsImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? userId = null, - Object? endDate = null, - Object? dateUtc = freezed, - Object? timezone = freezed, - Object? distance = null, - Object? type = null, - Object? time = null, - Object? workoutType = null, - Object? source = null, - Object? weightClass = null, - Object? strokeRate = freezed, - Object? verified = null, - Object? ranked = null, - Object? comments = freezed, - Object? privacy = null, - }) { - return _then(_$C2ResultsImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - userId: null == userId - ? _value.userId - : userId // ignore: cast_nullable_to_non_nullable - as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable - as DateTime, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, - timezone: freezed == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String?, - distance: null == distance - ? _value.distance - : distance // ignore: cast_nullable_to_non_nullable - as int, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as C2ResultType, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as double, - workoutType: null == workoutType - ? _value.workoutType - : workoutType // ignore: cast_nullable_to_non_nullable - as C2APIWorkoutType, - source: null == source - ? _value.source - : source // ignore: cast_nullable_to_non_nullable - as String, - weightClass: null == weightClass - ? _value.weightClass - : weightClass // ignore: cast_nullable_to_non_nullable - as C2WeightClass, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, - verified: null == verified - ? _value.verified - : verified // ignore: cast_nullable_to_non_nullable - as bool, - ranked: null == ranked - ? _value.ranked - : ranked // ignore: cast_nullable_to_non_nullable - as bool, - comments: freezed == comments - ? _value.comments - : comments // ignore: cast_nullable_to_non_nullable - as String?, - privacy: null == privacy - ? _value.privacy - : privacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$C2ResultsImpl extends _C2Results { - _$C2ResultsImpl( - {this.id = 0, - @JsonKey(name: "user_id") this.userId = 0, - @JsonKey(name: "date") @TimestampConverter() required this.endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() this.dateUtc, - this.timezone, - this.distance = 0, - this.type = C2ResultType.rower, - @DecimalIntConverter.tenths() required this.time, - @JsonKey(name: "workout_type") - this.workoutType = C2APIWorkoutType.JustRow, - this.source = "c2logbook dart", - @JsonKey(name: "weight_class") - this.weightClass = C2WeightClass.heavyweight, - @JsonKey(name: "stroke_rate") this.strokeRate, - this.verified = false, - this.ranked = false, - this.comments, - this.privacy = C2PrivacyLevel.private}) - : super._(); - - factory _$C2ResultsImpl.fromJson(Map json) => - _$$C2ResultsImplFromJson(json); - - @override - @JsonKey() - final int id; - @override - @JsonKey(name: "user_id") - final int userId; - @override - @JsonKey(name: "date") - @TimestampConverter() - final DateTime endDate; - @override - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - final DateTime? dateUtc; - @override - final String? timezone; - @override - @JsonKey() - final int distance; - @override - @JsonKey() - final C2ResultType type; - @override - @DecimalIntConverter.tenths() - final double time; - @override - @JsonKey(name: "workout_type") - final C2APIWorkoutType workoutType; - @override - @JsonKey() - final String source; - @override - @JsonKey(name: "weight_class") - final C2WeightClass weightClass; - @override - @JsonKey(name: "stroke_rate") - final int? strokeRate; - @override - @JsonKey() - final bool verified; - @override - @JsonKey() - final bool ranked; - @override - final String? comments; - @override - @JsonKey() - final C2PrivacyLevel privacy; - - @override - String toString() { - return 'C2Results(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$C2ResultsImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.userId, userId) || other.userId == userId) && - (identical(other.endDate, endDate) || other.endDate == endDate) && - (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && - (identical(other.timezone, timezone) || - other.timezone == timezone) && - (identical(other.distance, distance) || - other.distance == distance) && - (identical(other.type, type) || other.type == type) && - (identical(other.time, time) || other.time == time) && - (identical(other.workoutType, workoutType) || - other.workoutType == workoutType) && - (identical(other.source, source) || other.source == source) && - (identical(other.weightClass, weightClass) || - other.weightClass == weightClass) && - (identical(other.strokeRate, strokeRate) || - other.strokeRate == strokeRate) && - (identical(other.verified, verified) || - other.verified == verified) && - (identical(other.ranked, ranked) || other.ranked == ranked) && - (identical(other.comments, comments) || - other.comments == comments) && - (identical(other.privacy, privacy) || other.privacy == privacy)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash( - runtimeType, - id, - userId, - endDate, - dateUtc, - timezone, - distance, - type, - time, - workoutType, - source, - weightClass, - strokeRate, - verified, - ranked, - comments, - privacy); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$C2ResultsImplCopyWith<_$C2ResultsImpl> get copyWith => - __$$C2ResultsImplCopyWithImpl<_$C2ResultsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$C2ResultsImplToJson( - this, - ); - } -} - -abstract class _C2Results extends C2Results { - factory _C2Results( - {final int id, - @JsonKey(name: "user_id") final int userId, - @JsonKey(name: "date") - @TimestampConverter() - required final DateTime endDate, - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - final DateTime? dateUtc, - final String? timezone, - final int distance, - final C2ResultType type, - @DecimalIntConverter.tenths() required final double time, - @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, - final String source, - @JsonKey(name: "weight_class") final C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") final int? strokeRate, - final bool verified, - final bool ranked, - final String? comments, - final C2PrivacyLevel privacy}) = _$C2ResultsImpl; - _C2Results._() : super._(); - - factory _C2Results.fromJson(Map json) = - _$C2ResultsImpl.fromJson; - - @override - int get id; - @override - @JsonKey(name: "user_id") - int get userId; - @override - @JsonKey(name: "date") - @TimestampConverter() - DateTime get endDate; - @override - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - DateTime? get dateUtc; - @override - String? get timezone; - @override - int get distance; - @override - C2ResultType get type; - @override - @DecimalIntConverter.tenths() - double get time; - @override - @JsonKey(name: "workout_type") - C2APIWorkoutType get workoutType; - @override - String get source; - @override - @JsonKey(name: "weight_class") - C2WeightClass get weightClass; - @override - @JsonKey(name: "stroke_rate") - int? get strokeRate; - @override - bool get verified; - @override - bool get ranked; - @override - String? get comments; - @override - C2PrivacyLevel get privacy; - @override - @JsonKey(ignore: true) - _$$C2ResultsImplCopyWith<_$C2ResultsImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/src/types/c2_results.g.dart b/lib/src/types/c2_results.g.dart deleted file mode 100644 index 72b2ecc..0000000 --- a/lib/src/types/c2_results.g.dart +++ /dev/null @@ -1,93 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'c2_results.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => - _$C2ResultsImpl( - id: json['id'] as int? ?? 0, - userId: json['user_id'] as int? ?? 0, - endDate: const TimestampConverter().fromJson(json['date'] as String), - dateUtc: const TimestampOrNullConverter() - .fromJson(json['date_utc'] as String?), - timezone: json['timezone'] as String?, - distance: json['distance'] as int? ?? 0, - type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? - C2ResultType.rower, - time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: $enumDecodeNullable( - _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? - C2APIWorkoutType.JustRow, - source: json['source'] as String? ?? "c2logbook dart", - weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? - C2WeightClass.heavyweight, - strokeRate: json['stroke_rate'] as int?, - verified: json['verified'] as bool? ?? false, - ranked: json['ranked'] as bool? ?? false, - comments: json['comments'] as String?, - privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? - C2PrivacyLevel.private, - ); - -Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => - { - 'id': instance.id, - 'user_id': instance.userId, - 'date': const TimestampConverter().toJson(instance.endDate), - 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), - 'timezone': instance.timezone, - 'distance': instance.distance, - 'type': _$C2ResultTypeEnumMap[instance.type]!, - 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, - 'source': instance.source, - 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, - 'stroke_rate': instance.strokeRate, - 'verified': instance.verified, - 'ranked': instance.ranked, - 'comments': instance.comments, - 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - }; - -const _$C2ResultTypeEnumMap = { - C2ResultType.rower: 'rower', - C2ResultType.skierg: 'skierg', - C2ResultType.bike: 'bike', - C2ResultType.dynamic: 'dynamic', - C2ResultType.slides: 'slides', - C2ResultType.paddle: 'paddle', - C2ResultType.water: 'water', - C2ResultType.snow: 'snow', - C2ResultType.rollerski: 'rollerski', - C2ResultType.multierg: 'multierg', -}; - -const _$C2APIWorkoutTypeEnumMap = { - C2APIWorkoutType.unknown: 'unknown', - C2APIWorkoutType.JustRow: 'JustRow', - C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', - C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', - C2APIWorkoutType.FixedCalorie: 'FixedCalorie', - C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', - C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', - C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', - C2APIWorkoutType.VariableInterval: 'VariableInterval', - C2APIWorkoutType.VariableIntervalUndefinedRest: - 'VariableIntervalUndefinedRest', -}; - -const _$C2WeightClassEnumMap = { - C2WeightClass.lightweight: 'L', - C2WeightClass.heavyweight: 'H', -}; - -const _$C2PrivacyLevelEnumMap = { - C2PrivacyLevel.private: 'private', - C2PrivacyLevel.partners: 'partners', - C2PrivacyLevel.logged_in: 'logged_in', - C2PrivacyLevel.everyone: 'everyone', -}; diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart new file mode 100644 index 0000000..27d16b0 --- /dev/null +++ b/lib/src/types/c2_splits.dart @@ -0,0 +1,22 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Splits with _$C2Splits { + + C2Splits._(); + + factory C2Splits({ + @Default("time") String type, + @Default(0) int time, + @Default(0) int calories, + @Default(0) int strokeRate, + @Default("rower") String machine, + @Default("0") int restDistance, + @Default(null) C2HeartRate heartRate, + }) = _C2Splits; + + factory C2Splits.fromJson(Map json) => + _$C2SplitsFromJson(Map.from(json)); +} diff --git a/lib/src/types/c2_type_extensions.dart b/lib/src/types/c2_type_extensions.dart index 62a48f7..8022292 100644 --- a/lib/src/types/c2_type_extensions.dart +++ b/lib/src/types/c2_type_extensions.dart @@ -1,6 +1,6 @@ // TODO: add conversion to string to allow logged_in to be represented in dart as loggedIn -import 'c2_types.dart'; +part of 'index.dart'; //https://stackoverflow.com/a/44060511/ extension C2PrivacyExtension on C2PrivacyLevel { diff --git a/lib/src/types/c2_types.dart b/lib/src/types/c2_types.dart index 01cfa98..ff8e424 100644 --- a/lib/src/types/c2_types.dart +++ b/lib/src/types/c2_types.dart @@ -1,5 +1,5 @@ // TODO: add conversion to string to allow logged_in to be represented in dart as loggedIn -import 'package:freezed_annotation/freezed_annotation.dart'; +part of 'index.dart'; enum C2PrivacyLevel { private, partners, logged_in, everyone } diff --git a/lib/src/types/c2_user.dart b/lib/src/types/c2_user.dart index 717d6ee..2e13b0b 100644 --- a/lib/src/types/c2_user.dart +++ b/lib/src/types/c2_user.dart @@ -1,29 +1,24 @@ // ignore_for_file: invalid_annotation_target -import 'package:c2logbook/src/types/c2_types.dart'; -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'c2_user.freezed.dart'; -part 'c2_user.g.dart'; +part of 'index.dart'; @freezed class C2User with _$C2User { const factory C2User( {@Default(0) int id, @Default('') String username, - @JsonKey(name: 'first_name') @Default('') String firstName, - @JsonKey(name: 'last_name') @Default('') String lastName, + @Default('') String firstName, + @Default('') String lastName, @Default('F') String gender, - @JsonKey(name: 'dob') @Default('1970-01-01') String birthday, + @Default('1970-01-01') String birthday, @Default('') String email, @Default('') String country, - @JsonKey(name: 'profile_image') String? profileImage, - @JsonKey(name: 'age_restricted') @Default(false) bool ageRestricted, - @JsonKey(name: 'email_permission') @Default(false) bool emailPermission, - @JsonKey(name: 'max_heart_rate') int? maxHeartRate, + String? profileImage, + @Default(false) bool ageRestricted, + @Default(false) bool emailPermission, + int? maxHeartRate, int? weight, @Default([]) List roles, - @JsonKey(name: 'logbook_privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel logbookPrivacy}) = _C2User; diff --git a/lib/src/types/c2_user.freezed.dart b/lib/src/types/c2_user.freezed.dart deleted file mode 100644 index d6b659c..0000000 --- a/lib/src/types/c2_user.freezed.dart +++ /dev/null @@ -1,495 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'c2_user.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -C2User _$C2UserFromJson(Map json) { - return _C2User.fromJson(json); -} - -/// @nodoc -mixin _$C2User { - int get id => throw _privateConstructorUsedError; - String get username => throw _privateConstructorUsedError; - @JsonKey(name: 'first_name') - String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'last_name') - String get lastName => throw _privateConstructorUsedError; - String get gender => throw _privateConstructorUsedError; - @JsonKey(name: 'dob') - String get birthday => throw _privateConstructorUsedError; - String get email => throw _privateConstructorUsedError; - String get country => throw _privateConstructorUsedError; - @JsonKey(name: 'profile_image') - String? get profileImage => throw _privateConstructorUsedError; - @JsonKey(name: 'age_restricted') - bool get ageRestricted => throw _privateConstructorUsedError; - @JsonKey(name: 'email_permission') - bool get emailPermission => throw _privateConstructorUsedError; - @JsonKey(name: 'max_heart_rate') - int? get maxHeartRate => throw _privateConstructorUsedError; - int? get weight => throw _privateConstructorUsedError; - List get roles => throw _privateConstructorUsedError; - @JsonKey(name: 'logbook_privacy') - C2PrivacyLevel get logbookPrivacy => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $C2UserCopyWith get copyWith => throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $C2UserCopyWith<$Res> { - factory $C2UserCopyWith(C2User value, $Res Function(C2User) then) = - _$C2UserCopyWithImpl<$Res, C2User>; - @useResult - $Res call( - {int id, - String username, - @JsonKey(name: 'first_name') String firstName, - @JsonKey(name: 'last_name') String lastName, - String gender, - @JsonKey(name: 'dob') String birthday, - String email, - String country, - @JsonKey(name: 'profile_image') String? profileImage, - @JsonKey(name: 'age_restricted') bool ageRestricted, - @JsonKey(name: 'email_permission') bool emailPermission, - @JsonKey(name: 'max_heart_rate') int? maxHeartRate, - int? weight, - List roles, - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); -} - -/// @nodoc -class _$C2UserCopyWithImpl<$Res, $Val extends C2User> - implements $C2UserCopyWith<$Res> { - _$C2UserCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? username = null, - Object? firstName = null, - Object? lastName = null, - Object? gender = null, - Object? birthday = null, - Object? email = null, - Object? country = null, - Object? profileImage = freezed, - Object? ageRestricted = null, - Object? emailPermission = null, - Object? maxHeartRate = freezed, - Object? weight = freezed, - Object? roles = null, - Object? logbookPrivacy = null, - }) { - return _then(_value.copyWith( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - username: null == username - ? _value.username - : username // ignore: cast_nullable_to_non_nullable - as String, - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - gender: null == gender - ? _value.gender - : gender // ignore: cast_nullable_to_non_nullable - as String, - birthday: null == birthday - ? _value.birthday - : birthday // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - country: null == country - ? _value.country - : country // ignore: cast_nullable_to_non_nullable - as String, - profileImage: freezed == profileImage - ? _value.profileImage - : profileImage // ignore: cast_nullable_to_non_nullable - as String?, - ageRestricted: null == ageRestricted - ? _value.ageRestricted - : ageRestricted // ignore: cast_nullable_to_non_nullable - as bool, - emailPermission: null == emailPermission - ? _value.emailPermission - : emailPermission // ignore: cast_nullable_to_non_nullable - as bool, - maxHeartRate: freezed == maxHeartRate - ? _value.maxHeartRate - : maxHeartRate // ignore: cast_nullable_to_non_nullable - as int?, - weight: freezed == weight - ? _value.weight - : weight // ignore: cast_nullable_to_non_nullable - as int?, - roles: null == roles - ? _value.roles - : roles // ignore: cast_nullable_to_non_nullable - as List, - logbookPrivacy: null == logbookPrivacy - ? _value.logbookPrivacy - : logbookPrivacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$C2UserImplCopyWith<$Res> implements $C2UserCopyWith<$Res> { - factory _$$C2UserImplCopyWith( - _$C2UserImpl value, $Res Function(_$C2UserImpl) then) = - __$$C2UserImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int id, - String username, - @JsonKey(name: 'first_name') String firstName, - @JsonKey(name: 'last_name') String lastName, - String gender, - @JsonKey(name: 'dob') String birthday, - String email, - String country, - @JsonKey(name: 'profile_image') String? profileImage, - @JsonKey(name: 'age_restricted') bool ageRestricted, - @JsonKey(name: 'email_permission') bool emailPermission, - @JsonKey(name: 'max_heart_rate') int? maxHeartRate, - int? weight, - List roles, - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); -} - -/// @nodoc -class __$$C2UserImplCopyWithImpl<$Res> - extends _$C2UserCopyWithImpl<$Res, _$C2UserImpl> - implements _$$C2UserImplCopyWith<$Res> { - __$$C2UserImplCopyWithImpl( - _$C2UserImpl _value, $Res Function(_$C2UserImpl) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? id = null, - Object? username = null, - Object? firstName = null, - Object? lastName = null, - Object? gender = null, - Object? birthday = null, - Object? email = null, - Object? country = null, - Object? profileImage = freezed, - Object? ageRestricted = null, - Object? emailPermission = null, - Object? maxHeartRate = freezed, - Object? weight = freezed, - Object? roles = null, - Object? logbookPrivacy = null, - }) { - return _then(_$C2UserImpl( - id: null == id - ? _value.id - : id // ignore: cast_nullable_to_non_nullable - as int, - username: null == username - ? _value.username - : username // ignore: cast_nullable_to_non_nullable - as String, - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - gender: null == gender - ? _value.gender - : gender // ignore: cast_nullable_to_non_nullable - as String, - birthday: null == birthday - ? _value.birthday - : birthday // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - country: null == country - ? _value.country - : country // ignore: cast_nullable_to_non_nullable - as String, - profileImage: freezed == profileImage - ? _value.profileImage - : profileImage // ignore: cast_nullable_to_non_nullable - as String?, - ageRestricted: null == ageRestricted - ? _value.ageRestricted - : ageRestricted // ignore: cast_nullable_to_non_nullable - as bool, - emailPermission: null == emailPermission - ? _value.emailPermission - : emailPermission // ignore: cast_nullable_to_non_nullable - as bool, - maxHeartRate: freezed == maxHeartRate - ? _value.maxHeartRate - : maxHeartRate // ignore: cast_nullable_to_non_nullable - as int?, - weight: freezed == weight - ? _value.weight - : weight // ignore: cast_nullable_to_non_nullable - as int?, - roles: null == roles - ? _value._roles - : roles // ignore: cast_nullable_to_non_nullable - as List, - logbookPrivacy: null == logbookPrivacy - ? _value.logbookPrivacy - : logbookPrivacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$C2UserImpl implements _C2User { - const _$C2UserImpl( - {this.id = 0, - this.username = '', - @JsonKey(name: 'first_name') this.firstName = '', - @JsonKey(name: 'last_name') this.lastName = '', - this.gender = 'F', - @JsonKey(name: 'dob') this.birthday = '1970-01-01', - this.email = '', - this.country = '', - @JsonKey(name: 'profile_image') this.profileImage, - @JsonKey(name: 'age_restricted') this.ageRestricted = false, - @JsonKey(name: 'email_permission') this.emailPermission = false, - @JsonKey(name: 'max_heart_rate') this.maxHeartRate, - this.weight, - final List roles = const [], - @JsonKey(name: 'logbook_privacy') - this.logbookPrivacy = C2PrivacyLevel.private}) - : _roles = roles; - - factory _$C2UserImpl.fromJson(Map json) => - _$$C2UserImplFromJson(json); - - @override - @JsonKey() - final int id; - @override - @JsonKey() - final String username; - @override - @JsonKey(name: 'first_name') - final String firstName; - @override - @JsonKey(name: 'last_name') - final String lastName; - @override - @JsonKey() - final String gender; - @override - @JsonKey(name: 'dob') - final String birthday; - @override - @JsonKey() - final String email; - @override - @JsonKey() - final String country; - @override - @JsonKey(name: 'profile_image') - final String? profileImage; - @override - @JsonKey(name: 'age_restricted') - final bool ageRestricted; - @override - @JsonKey(name: 'email_permission') - final bool emailPermission; - @override - @JsonKey(name: 'max_heart_rate') - final int? maxHeartRate; - @override - final int? weight; - final List _roles; - @override - @JsonKey() - List get roles { - if (_roles is EqualUnmodifiableListView) return _roles; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_roles); - } - - @override - @JsonKey(name: 'logbook_privacy') - final C2PrivacyLevel logbookPrivacy; - - @override - String toString() { - return 'C2User(id: $id, username: $username, firstName: $firstName, lastName: $lastName, gender: $gender, birthday: $birthday, email: $email, country: $country, profileImage: $profileImage, ageRestricted: $ageRestricted, emailPermission: $emailPermission, maxHeartRate: $maxHeartRate, weight: $weight, roles: $roles, logbookPrivacy: $logbookPrivacy)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$C2UserImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.username, username) || - other.username == username) && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.gender, gender) || other.gender == gender) && - (identical(other.birthday, birthday) || - other.birthday == birthday) && - (identical(other.email, email) || other.email == email) && - (identical(other.country, country) || other.country == country) && - (identical(other.profileImage, profileImage) || - other.profileImage == profileImage) && - (identical(other.ageRestricted, ageRestricted) || - other.ageRestricted == ageRestricted) && - (identical(other.emailPermission, emailPermission) || - other.emailPermission == emailPermission) && - (identical(other.maxHeartRate, maxHeartRate) || - other.maxHeartRate == maxHeartRate) && - (identical(other.weight, weight) || other.weight == weight) && - const DeepCollectionEquality().equals(other._roles, _roles) && - (identical(other.logbookPrivacy, logbookPrivacy) || - other.logbookPrivacy == logbookPrivacy)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash( - runtimeType, - id, - username, - firstName, - lastName, - gender, - birthday, - email, - country, - profileImage, - ageRestricted, - emailPermission, - maxHeartRate, - weight, - const DeepCollectionEquality().hash(_roles), - logbookPrivacy); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$C2UserImplCopyWith<_$C2UserImpl> get copyWith => - __$$C2UserImplCopyWithImpl<_$C2UserImpl>(this, _$identity); - - @override - Map toJson() { - return _$$C2UserImplToJson( - this, - ); - } -} - -abstract class _C2User implements C2User { - const factory _C2User( - {final int id, - final String username, - @JsonKey(name: 'first_name') final String firstName, - @JsonKey(name: 'last_name') final String lastName, - final String gender, - @JsonKey(name: 'dob') final String birthday, - final String email, - final String country, - @JsonKey(name: 'profile_image') final String? profileImage, - @JsonKey(name: 'age_restricted') final bool ageRestricted, - @JsonKey(name: 'email_permission') final bool emailPermission, - @JsonKey(name: 'max_heart_rate') final int? maxHeartRate, - final int? weight, - final List roles, - @JsonKey(name: 'logbook_privacy') - final C2PrivacyLevel logbookPrivacy}) = _$C2UserImpl; - - factory _C2User.fromJson(Map json) = _$C2UserImpl.fromJson; - - @override - int get id; - @override - String get username; - @override - @JsonKey(name: 'first_name') - String get firstName; - @override - @JsonKey(name: 'last_name') - String get lastName; - @override - String get gender; - @override - @JsonKey(name: 'dob') - String get birthday; - @override - String get email; - @override - String get country; - @override - @JsonKey(name: 'profile_image') - String? get profileImage; - @override - @JsonKey(name: 'age_restricted') - bool get ageRestricted; - @override - @JsonKey(name: 'email_permission') - bool get emailPermission; - @override - @JsonKey(name: 'max_heart_rate') - int? get maxHeartRate; - @override - int? get weight; - @override - List get roles; - @override - @JsonKey(name: 'logbook_privacy') - C2PrivacyLevel get logbookPrivacy; - @override - @JsonKey(ignore: true) - _$$C2UserImplCopyWith<_$C2UserImpl> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/lib/src/types/c2_user.g.dart b/lib/src/types/c2_user.g.dart deleted file mode 100644 index a20fd42..0000000 --- a/lib/src/types/c2_user.g.dart +++ /dev/null @@ -1,55 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'c2_user.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$C2UserImpl _$$C2UserImplFromJson(Map json) => _$C2UserImpl( - id: json['id'] as int? ?? 0, - username: json['username'] as String? ?? '', - firstName: json['first_name'] as String? ?? '', - lastName: json['last_name'] as String? ?? '', - gender: json['gender'] as String? ?? 'F', - birthday: json['dob'] as String? ?? '1970-01-01', - email: json['email'] as String? ?? '', - country: json['country'] as String? ?? '', - profileImage: json['profile_image'] as String?, - ageRestricted: json['age_restricted'] as bool? ?? false, - emailPermission: json['email_permission'] as bool? ?? false, - maxHeartRate: json['max_heart_rate'] as int?, - weight: json['weight'] as int?, - roles: - (json['roles'] as List?)?.map((e) => e as String).toList() ?? - const [], - logbookPrivacy: $enumDecodeNullable( - _$C2PrivacyLevelEnumMap, json['logbook_privacy']) ?? - C2PrivacyLevel.private, - ); - -Map _$$C2UserImplToJson(_$C2UserImpl instance) => - { - 'id': instance.id, - 'username': instance.username, - 'first_name': instance.firstName, - 'last_name': instance.lastName, - 'gender': instance.gender, - 'dob': instance.birthday, - 'email': instance.email, - 'country': instance.country, - 'profile_image': instance.profileImage, - 'age_restricted': instance.ageRestricted, - 'email_permission': instance.emailPermission, - 'max_heart_rate': instance.maxHeartRate, - 'weight': instance.weight, - 'roles': instance.roles, - 'logbook_privacy': _$C2PrivacyLevelEnumMap[instance.logbookPrivacy]!, - }; - -const _$C2PrivacyLevelEnumMap = { - C2PrivacyLevel.private: 'private', - C2PrivacyLevel.partners: 'partners', - C2PrivacyLevel.logged_in: 'logged_in', - C2PrivacyLevel.everyone: 'everyone', -}; diff --git a/lib/src/types/c2_webhook_result.dart b/lib/src/types/c2_webhook_result.dart index 6dc38ed..aa5a44d 100644 --- a/lib/src/types/c2_webhook_result.dart +++ b/lib/src/types/c2_webhook_result.dart @@ -1,4 +1,4 @@ -import 'package:c2logbook/c2logbook.dart'; +part of 'index.dart'; class C2Webhook { /// Parse the data from incoming webhooks from the Concept2 API. diff --git a/lib/src/types/index.dart b/lib/src/types/index.dart new file mode 100644 index 0000000..48a40cd --- /dev/null +++ b/lib/src/types/index.dart @@ -0,0 +1,14 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import '../utils.dart'; + +part 'c2_full_results.dart'; +part 'c2_heart_rate.dart'; +part 'c2_intervals.dart'; +part 'c2_results.dart'; +part 'c2_splits.dart'; +part 'c2_type_extensions.dart'; +part 'c2_types.dart'; +part 'c2_user.dart'; +part 'c2_webhook_result.dart'; +part 'index.freezed.dart'; +part 'index.g.dart'; \ No newline at end of file diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 0c26bc6..3e0c26d 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -21,12 +21,9 @@ C2FullResults _$C2FullResultsFromJson(Map json) { /// @nodoc mixin _$C2FullResults { int get id => throw _privateConstructorUsedError; - @JsonKey(name: "user_id") int get userId => throw _privateConstructorUsedError; - @JsonKey(name: "date") @TimestampConverter() DateTime get endDate => throw _privateConstructorUsedError; - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; String? get timezone => throw _privateConstructorUsedError; @@ -34,17 +31,17 @@ mixin _$C2FullResults { C2ResultType get type => throw _privateConstructorUsedError; @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; - @JsonKey(name: "workout_type") C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; String get source => throw _privateConstructorUsedError; - @JsonKey(name: "weight_class") C2WeightClass get weightClass => throw _privateConstructorUsedError; - @JsonKey(name: "stroke_rate") int? get strokeRate => throw _privateConstructorUsedError; bool get verified => throw _privateConstructorUsedError; bool get ranked => throw _privateConstructorUsedError; String? get comments => throw _privateConstructorUsedError; C2PrivacyLevel get privacy => throw _privateConstructorUsedError; + List get intervals => throw _privateConstructorUsedError; + List get splits => throw _privateConstructorUsedError; + C2HeartRate get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -60,21 +57,26 @@ abstract class $C2FullResultsCopyWith<$Res> { @useResult $Res call( {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + int userId, + @TimestampConverter() DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + C2APIWorkoutType workoutType, String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, + C2WeightClass weightClass, + int? strokeRate, bool verified, bool ranked, String? comments, - C2PrivacyLevel privacy}); + C2PrivacyLevel privacy, + List intervals, + List splits, + C2HeartRate heartRate}); + + $C2HeartRateCopyWith<$Res> get heartRate; } /// @nodoc @@ -106,6 +108,9 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? ranked = null, Object? comments = freezed, Object? privacy = null, + Object? intervals = null, + Object? splits = null, + Object? heartRate = null, }) { return _then(_value.copyWith( id: null == id @@ -172,8 +177,28 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, + intervals: null == intervals + ? _value.intervals + : intervals // ignore: cast_nullable_to_non_nullable + as List, + splits: null == splits + ? _value.splits + : splits // ignore: cast_nullable_to_non_nullable + as List, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $C2HeartRateCopyWith<$Res> get heartRate { + return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + return _then(_value.copyWith(heartRate: value) as $Val); + }); + } } /// @nodoc @@ -186,21 +211,27 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @useResult $Res call( {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + int userId, + @TimestampConverter() DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + C2APIWorkoutType workoutType, String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, + C2WeightClass weightClass, + int? strokeRate, bool verified, bool ranked, String? comments, - C2PrivacyLevel privacy}); + C2PrivacyLevel privacy, + List intervals, + List splits, + C2HeartRate heartRate}); + + @override + $C2HeartRateCopyWith<$Res> get heartRate; } /// @nodoc @@ -230,6 +261,9 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? ranked = null, Object? comments = freezed, Object? privacy = null, + Object? intervals = null, + Object? splits = null, + Object? heartRate = null, }) { return _then(_$C2FullResultsImpl( id: null == id @@ -296,6 +330,18 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, + intervals: null == intervals + ? _value._intervals + : intervals // ignore: cast_nullable_to_non_nullable + as List, + splits: null == splits + ? _value._splits + : splits // ignore: cast_nullable_to_non_nullable + as List, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, )); } } @@ -305,24 +351,27 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> class _$C2FullResultsImpl extends _C2FullResults { _$C2FullResultsImpl( {this.id = 0, - @JsonKey(name: "user_id") this.userId = 0, - @JsonKey(name: "date") @TimestampConverter() required this.endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() this.dateUtc, + this.userId = 0, + @TimestampConverter() required this.endDate, + @TimestampOrNullConverter() this.dateUtc, this.timezone, this.distance = 0, this.type = C2ResultType.rower, @DecimalIntConverter.tenths() required this.time, - @JsonKey(name: "workout_type") this.workoutType = C2APIWorkoutType.JustRow, this.source = "c2logbook dart", - @JsonKey(name: "weight_class") this.weightClass = C2WeightClass.heavyweight, - @JsonKey(name: "stroke_rate") this.strokeRate, + this.strokeRate, this.verified = false, this.ranked = false, this.comments, - this.privacy = C2PrivacyLevel.private}) - : super._(); + this.privacy = C2PrivacyLevel.private, + final List intervals = const [], + final List splits = const [], + this.heartRate = null}) + : _intervals = intervals, + _splits = splits, + super._(); factory _$C2FullResultsImpl.fromJson(Map json) => _$$C2FullResultsImplFromJson(json); @@ -331,14 +380,12 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey() final int id; @override - @JsonKey(name: "user_id") + @JsonKey() final int userId; @override - @JsonKey(name: "date") @TimestampConverter() final DateTime endDate; @override - @JsonKey(name: "date_utc") @TimestampOrNullConverter() final DateTime? dateUtc; @override @@ -353,16 +400,15 @@ class _$C2FullResultsImpl extends _C2FullResults { @DecimalIntConverter.tenths() final double time; @override - @JsonKey(name: "workout_type") + @JsonKey() final C2APIWorkoutType workoutType; @override @JsonKey() final String source; @override - @JsonKey(name: "weight_class") + @JsonKey() final C2WeightClass weightClass; @override - @JsonKey(name: "stroke_rate") final int? strokeRate; @override @JsonKey() @@ -375,10 +421,31 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey() final C2PrivacyLevel privacy; + final List _intervals; + @override + @JsonKey() + List get intervals { + if (_intervals is EqualUnmodifiableListView) return _intervals; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_intervals); + } + + final List _splits; + @override + @JsonKey() + List get splits { + if (_splits is EqualUnmodifiableListView) return _splits; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_splits); + } + + @override + @JsonKey() + final C2HeartRate heartRate; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; + return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; } @override @@ -408,29 +475,38 @@ class _$C2FullResultsImpl extends _C2FullResults { (identical(other.ranked, ranked) || other.ranked == ranked) && (identical(other.comments, comments) || other.comments == comments) && - (identical(other.privacy, privacy) || other.privacy == privacy)); + (identical(other.privacy, privacy) || other.privacy == privacy) && + const DeepCollectionEquality() + .equals(other._intervals, _intervals) && + const DeepCollectionEquality().equals(other._splits, _splits) && + (identical(other.heartRate, heartRate) || + other.heartRate == heartRate)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - id, - userId, - endDate, - dateUtc, - timezone, - distance, - type, - time, - workoutType, - source, - weightClass, - strokeRate, - verified, - ranked, - comments, - privacy); + int get hashCode => Object.hashAll([ + runtimeType, + id, + userId, + endDate, + dateUtc, + timezone, + distance, + type, + time, + workoutType, + source, + weightClass, + strokeRate, + verified, + ranked, + comments, + privacy, + const DeepCollectionEquality().hash(_intervals), + const DeepCollectionEquality().hash(_splits), + heartRate + ]); @JsonKey(ignore: true) @override @@ -449,25 +525,24 @@ class _$C2FullResultsImpl extends _C2FullResults { abstract class _C2FullResults extends C2FullResults { factory _C2FullResults( {final int id, - @JsonKey(name: "user_id") final int userId, - @JsonKey(name: "date") - @TimestampConverter() - required final DateTime endDate, - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - final DateTime? dateUtc, + final int userId, + @TimestampConverter() required final DateTime endDate, + @TimestampOrNullConverter() final DateTime? dateUtc, final String? timezone, final int distance, final C2ResultType type, @DecimalIntConverter.tenths() required final double time, - @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, + final C2APIWorkoutType workoutType, final String source, - @JsonKey(name: "weight_class") final C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") final int? strokeRate, + final C2WeightClass weightClass, + final int? strokeRate, final bool verified, final bool ranked, final String? comments, - final C2PrivacyLevel privacy}) = _$C2FullResultsImpl; + final C2PrivacyLevel privacy, + final List intervals, + final List splits, + final C2HeartRate heartRate}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -476,14 +551,11 @@ abstract class _C2FullResults extends C2FullResults { @override int get id; @override - @JsonKey(name: "user_id") int get userId; @override - @JsonKey(name: "date") @TimestampConverter() DateTime get endDate; @override - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? get dateUtc; @override @@ -496,15 +568,12 @@ abstract class _C2FullResults extends C2FullResults { @DecimalIntConverter.tenths() double get time; @override - @JsonKey(name: "workout_type") C2APIWorkoutType get workoutType; @override String get source; @override - @JsonKey(name: "weight_class") C2WeightClass get weightClass; @override - @JsonKey(name: "stroke_rate") int? get strokeRate; @override bool get verified; @@ -515,6 +584,12 @@ abstract class _C2FullResults extends C2FullResults { @override C2PrivacyLevel get privacy; @override + List get intervals; + @override + List get splits; + @override + C2HeartRate get heartRate; + @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; @@ -526,13 +601,9 @@ C2HeartRate _$C2HeartRateFromJson(Map json) { /// @nodoc mixin _$C2HeartRate { - @JsonKey(name: "min") int get min => throw _privateConstructorUsedError; - @JsonKey(name: "average") int get average => throw _privateConstructorUsedError; - @JsonKey(name: "max") int get max => throw _privateConstructorUsedError; - @JsonKey(name: "ending") int get ending => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -547,11 +618,7 @@ abstract class $C2HeartRateCopyWith<$Res> { C2HeartRate value, $Res Function(C2HeartRate) then) = _$C2HeartRateCopyWithImpl<$Res, C2HeartRate>; @useResult - $Res call( - {@JsonKey(name: "min") int min, - @JsonKey(name: "average") int average, - @JsonKey(name: "max") int max, - @JsonKey(name: "ending") int ending}); + $Res call({int min, int average, int max, int ending}); } /// @nodoc @@ -601,11 +668,7 @@ abstract class _$$C2HeartRateImplCopyWith<$Res> __$$C2HeartRateImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {@JsonKey(name: "min") int min, - @JsonKey(name: "average") int average, - @JsonKey(name: "max") int max, - @JsonKey(name: "ending") int ending}); + $Res call({int min, int average, int max, int ending}); } /// @nodoc @@ -649,26 +712,23 @@ class __$$C2HeartRateImplCopyWithImpl<$Res> @JsonSerializable() class _$C2HeartRateImpl extends _C2HeartRate { _$C2HeartRateImpl( - {@JsonKey(name: "min") this.min = 0, - @JsonKey(name: "average") this.average = 0, - @JsonKey(name: "max") this.max = 0, - @JsonKey(name: "ending") this.ending = 0}) + {this.min = 0, this.average = 0, this.max = 0, this.ending = 0}) : super._(); factory _$C2HeartRateImpl.fromJson(Map json) => _$$C2HeartRateImplFromJson(json); @override - @JsonKey(name: "min") + @JsonKey() final int min; @override - @JsonKey(name: "average") + @JsonKey() final int average; @override - @JsonKey(name: "max") + @JsonKey() final int max; @override - @JsonKey(name: "ending") + @JsonKey() final int ending; @override @@ -707,26 +767,22 @@ class _$C2HeartRateImpl extends _C2HeartRate { abstract class _C2HeartRate extends C2HeartRate { factory _C2HeartRate( - {@JsonKey(name: "min") final int min, - @JsonKey(name: "average") final int average, - @JsonKey(name: "max") final int max, - @JsonKey(name: "ending") final int ending}) = _$C2HeartRateImpl; + {final int min, + final int average, + final int max, + final int ending}) = _$C2HeartRateImpl; _C2HeartRate._() : super._(); factory _C2HeartRate.fromJson(Map json) = _$C2HeartRateImpl.fromJson; @override - @JsonKey(name: "min") int get min; @override - @JsonKey(name: "average") int get average; @override - @JsonKey(name: "max") int get max; @override - @JsonKey(name: "ending") int get ending; @override @JsonKey(ignore: true) @@ -740,18 +796,13 @@ C2Intervals _$C2IntervalsFromJson(Map json) { /// @nodoc mixin _$C2Intervals { - @JsonKey(name: "type") String get type => throw _privateConstructorUsedError; - @JsonKey(name: "time") int get time => throw _privateConstructorUsedError; - @JsonKey(name: "calories_total") int get calories => throw _privateConstructorUsedError; - @JsonKey(name: "stroke_rate") int get strokeRate => throw _privateConstructorUsedError; - @JsonKey(name: "machine") String get machine => throw _privateConstructorUsedError; - @JsonKey(name: "rest_distance") int get restDistance => throw _privateConstructorUsedError; + C2HeartRate get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -766,12 +817,15 @@ abstract class $C2IntervalsCopyWith<$Res> { _$C2IntervalsCopyWithImpl<$Res, C2Intervals>; @useResult $Res call( - {@JsonKey(name: "type") String type, - @JsonKey(name: "time") int time, - @JsonKey(name: "calories_total") int calories, - @JsonKey(name: "stroke_rate") int strokeRate, - @JsonKey(name: "machine") String machine, - @JsonKey(name: "rest_distance") int restDistance}); + {String type, + int time, + int calories, + int strokeRate, + String machine, + int restDistance, + C2HeartRate heartRate}); + + $C2HeartRateCopyWith<$Res> get heartRate; } /// @nodoc @@ -793,6 +847,7 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, + Object? heartRate = null, }) { return _then(_value.copyWith( type: null == type @@ -819,8 +874,20 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $C2HeartRateCopyWith<$Res> get heartRate { + return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + return _then(_value.copyWith(heartRate: value) as $Val); + }); + } } /// @nodoc @@ -832,12 +899,16 @@ abstract class _$$C2IntervalsImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: "type") String type, - @JsonKey(name: "time") int time, - @JsonKey(name: "calories_total") int calories, - @JsonKey(name: "stroke_rate") int strokeRate, - @JsonKey(name: "machine") String machine, - @JsonKey(name: "rest_distance") int restDistance}); + {String type, + int time, + int calories, + int strokeRate, + String machine, + int restDistance, + C2HeartRate heartRate}); + + @override + $C2HeartRateCopyWith<$Res> get heartRate; } /// @nodoc @@ -857,6 +928,7 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, + Object? heartRate = null, }) { return _then(_$C2IntervalsImpl( type: null == type @@ -883,6 +955,10 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, )); } } @@ -891,39 +967,43 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2IntervalsImpl extends _C2Intervals { _$C2IntervalsImpl( - {@JsonKey(name: "type") this.type = "time", - @JsonKey(name: "time") this.time = 0, - @JsonKey(name: "calories_total") this.calories = 0, - @JsonKey(name: "stroke_rate") this.strokeRate = 0, - @JsonKey(name: "machine") this.machine = "rower", - @JsonKey(name: "rest_distance") this.restDistance = "0"}) + {this.type = "time", + this.time = 0, + this.calories = 0, + this.strokeRate = 0, + this.machine = "rower", + this.restDistance = "0", + this.heartRate = null}) : super._(); factory _$C2IntervalsImpl.fromJson(Map json) => _$$C2IntervalsImplFromJson(json); @override - @JsonKey(name: "type") + @JsonKey() final String type; @override - @JsonKey(name: "time") + @JsonKey() final int time; @override - @JsonKey(name: "calories_total") + @JsonKey() final int calories; @override - @JsonKey(name: "stroke_rate") + @JsonKey() final int strokeRate; @override - @JsonKey(name: "machine") + @JsonKey() final String machine; @override - @JsonKey(name: "rest_distance") + @JsonKey() final int restDistance; + @override + @JsonKey() + final C2HeartRate heartRate; @override String toString() { - return 'C2Intervals(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance)'; + return 'C2Intervals(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance, heartRate: $heartRate)'; } @override @@ -939,13 +1019,15 @@ class _$C2IntervalsImpl extends _C2Intervals { other.strokeRate == strokeRate) && (identical(other.machine, machine) || other.machine == machine) && (identical(other.restDistance, restDistance) || - other.restDistance == restDistance)); + other.restDistance == restDistance) && + (identical(other.heartRate, heartRate) || + other.heartRate == heartRate)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, type, time, calories, strokeRate, machine, restDistance); + int get hashCode => Object.hash(runtimeType, type, time, calories, strokeRate, + machine, restDistance, heartRate); @JsonKey(ignore: true) @override @@ -963,37 +1045,33 @@ class _$C2IntervalsImpl extends _C2Intervals { abstract class _C2Intervals extends C2Intervals { factory _C2Intervals( - {@JsonKey(name: "type") final String type, - @JsonKey(name: "time") final int time, - @JsonKey(name: "calories_total") final int calories, - @JsonKey(name: "stroke_rate") final int strokeRate, - @JsonKey(name: "machine") final String machine, - @JsonKey(name: "rest_distance") final int restDistance}) = - _$C2IntervalsImpl; + {final String type, + final int time, + final int calories, + final int strokeRate, + final String machine, + final int restDistance, + final C2HeartRate heartRate}) = _$C2IntervalsImpl; _C2Intervals._() : super._(); factory _C2Intervals.fromJson(Map json) = _$C2IntervalsImpl.fromJson; @override - @JsonKey(name: "type") String get type; @override - @JsonKey(name: "time") int get time; @override - @JsonKey(name: "calories_total") int get calories; @override - @JsonKey(name: "stroke_rate") int get strokeRate; @override - @JsonKey(name: "machine") String get machine; @override - @JsonKey(name: "rest_distance") int get restDistance; @override + C2HeartRate get heartRate; + @override @JsonKey(ignore: true) _$$C2IntervalsImplCopyWith<_$C2IntervalsImpl> get copyWith => throw _privateConstructorUsedError; @@ -1006,12 +1084,9 @@ C2Results _$C2ResultsFromJson(Map json) { /// @nodoc mixin _$C2Results { int get id => throw _privateConstructorUsedError; - @JsonKey(name: "user_id") int get userId => throw _privateConstructorUsedError; - @JsonKey(name: "date") @TimestampConverter() DateTime get endDate => throw _privateConstructorUsedError; - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; String? get timezone => throw _privateConstructorUsedError; @@ -1024,7 +1099,6 @@ mixin _$C2Results { String get source => throw _privateConstructorUsedError; @JsonKey(name: "weight_class") C2WeightClass get weightClass => throw _privateConstructorUsedError; - @JsonKey(name: "stroke_rate") int? get strokeRate => throw _privateConstructorUsedError; bool get verified => throw _privateConstructorUsedError; bool get ranked => throw _privateConstructorUsedError; @@ -1044,9 +1118,9 @@ abstract class $C2ResultsCopyWith<$Res> { @useResult $Res call( {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + int userId, + @TimestampConverter() DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @@ -1054,7 +1128,7 @@ abstract class $C2ResultsCopyWith<$Res> { @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, String source, @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, + int? strokeRate, bool verified, bool ranked, String? comments, @@ -1170,9 +1244,9 @@ abstract class _$$C2ResultsImplCopyWith<$Res> @useResult $Res call( {int id, - @JsonKey(name: "user_id") int userId, - @JsonKey(name: "date") @TimestampConverter() DateTime endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? dateUtc, + int userId, + @TimestampConverter() DateTime endDate, + @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @@ -1180,7 +1254,7 @@ abstract class _$$C2ResultsImplCopyWith<$Res> @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, String source, @JsonKey(name: "weight_class") C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, + int? strokeRate, bool verified, bool ranked, String? comments, @@ -1289,9 +1363,9 @@ class __$$C2ResultsImplCopyWithImpl<$Res> class _$C2ResultsImpl extends _C2Results { _$C2ResultsImpl( {this.id = 0, - @JsonKey(name: "user_id") this.userId = 0, - @JsonKey(name: "date") @TimestampConverter() required this.endDate, - @JsonKey(name: "date_utc") @TimestampOrNullConverter() this.dateUtc, + this.userId = 0, + @TimestampConverter() required this.endDate, + @TimestampOrNullConverter() this.dateUtc, this.timezone, this.distance = 0, this.type = C2ResultType.rower, @@ -1301,7 +1375,7 @@ class _$C2ResultsImpl extends _C2Results { this.source = "c2logbook dart", @JsonKey(name: "weight_class") this.weightClass = C2WeightClass.heavyweight, - @JsonKey(name: "stroke_rate") this.strokeRate, + this.strokeRate, this.verified = false, this.ranked = false, this.comments, @@ -1315,14 +1389,12 @@ class _$C2ResultsImpl extends _C2Results { @JsonKey() final int id; @override - @JsonKey(name: "user_id") + @JsonKey() final int userId; @override - @JsonKey(name: "date") @TimestampConverter() final DateTime endDate; @override - @JsonKey(name: "date_utc") @TimestampOrNullConverter() final DateTime? dateUtc; @override @@ -1346,7 +1418,6 @@ class _$C2ResultsImpl extends _C2Results { @JsonKey(name: "weight_class") final C2WeightClass weightClass; @override - @JsonKey(name: "stroke_rate") final int? strokeRate; @override @JsonKey() @@ -1433,13 +1504,9 @@ class _$C2ResultsImpl extends _C2Results { abstract class _C2Results extends C2Results { factory _C2Results( {final int id, - @JsonKey(name: "user_id") final int userId, - @JsonKey(name: "date") - @TimestampConverter() - required final DateTime endDate, - @JsonKey(name: "date_utc") - @TimestampOrNullConverter() - final DateTime? dateUtc, + final int userId, + @TimestampConverter() required final DateTime endDate, + @TimestampOrNullConverter() final DateTime? dateUtc, final String? timezone, final int distance, final C2ResultType type, @@ -1447,7 +1514,7 @@ abstract class _C2Results extends C2Results { @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, final String source, @JsonKey(name: "weight_class") final C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") final int? strokeRate, + final int? strokeRate, final bool verified, final bool ranked, final String? comments, @@ -1460,14 +1527,11 @@ abstract class _C2Results extends C2Results { @override int get id; @override - @JsonKey(name: "user_id") int get userId; @override - @JsonKey(name: "date") @TimestampConverter() DateTime get endDate; @override - @JsonKey(name: "date_utc") @TimestampOrNullConverter() DateTime? get dateUtc; @override @@ -1488,7 +1552,6 @@ abstract class _C2Results extends C2Results { @JsonKey(name: "weight_class") C2WeightClass get weightClass; @override - @JsonKey(name: "stroke_rate") int? get strokeRate; @override bool get verified; @@ -1504,6 +1567,292 @@ abstract class _C2Results extends C2Results { throw _privateConstructorUsedError; } +C2Splits _$C2SplitsFromJson(Map json) { + return _C2Splits.fromJson(json); +} + +/// @nodoc +mixin _$C2Splits { + String get type => throw _privateConstructorUsedError; + int get time => throw _privateConstructorUsedError; + int get calories => throw _privateConstructorUsedError; + int get strokeRate => throw _privateConstructorUsedError; + String get machine => throw _privateConstructorUsedError; + int get restDistance => throw _privateConstructorUsedError; + C2HeartRate get heartRate => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2SplitsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2SplitsCopyWith<$Res> { + factory $C2SplitsCopyWith(C2Splits value, $Res Function(C2Splits) then) = + _$C2SplitsCopyWithImpl<$Res, C2Splits>; + @useResult + $Res call( + {String type, + int time, + int calories, + int strokeRate, + String machine, + int restDistance, + C2HeartRate heartRate}); + + $C2HeartRateCopyWith<$Res> get heartRate; +} + +/// @nodoc +class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> + implements $C2SplitsCopyWith<$Res> { + _$C2SplitsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? time = null, + Object? calories = null, + Object? strokeRate = null, + Object? machine = null, + Object? restDistance = null, + Object? heartRate = null, + }) { + return _then(_value.copyWith( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as int, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as int, + strokeRate: null == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int, + machine: null == machine + ? _value.machine + : machine // ignore: cast_nullable_to_non_nullable + as String, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $C2HeartRateCopyWith<$Res> get heartRate { + return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + return _then(_value.copyWith(heartRate: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$C2SplitsImplCopyWith<$Res> + implements $C2SplitsCopyWith<$Res> { + factory _$$C2SplitsImplCopyWith( + _$C2SplitsImpl value, $Res Function(_$C2SplitsImpl) then) = + __$$C2SplitsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String type, + int time, + int calories, + int strokeRate, + String machine, + int restDistance, + C2HeartRate heartRate}); + + @override + $C2HeartRateCopyWith<$Res> get heartRate; +} + +/// @nodoc +class __$$C2SplitsImplCopyWithImpl<$Res> + extends _$C2SplitsCopyWithImpl<$Res, _$C2SplitsImpl> + implements _$$C2SplitsImplCopyWith<$Res> { + __$$C2SplitsImplCopyWithImpl( + _$C2SplitsImpl _value, $Res Function(_$C2SplitsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? type = null, + Object? time = null, + Object? calories = null, + Object? strokeRate = null, + Object? machine = null, + Object? restDistance = null, + Object? heartRate = null, + }) { + return _then(_$C2SplitsImpl( + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as int, + calories: null == calories + ? _value.calories + : calories // ignore: cast_nullable_to_non_nullable + as int, + strokeRate: null == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int, + machine: null == machine + ? _value.machine + : machine // ignore: cast_nullable_to_non_nullable + as String, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int, + heartRate: null == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2SplitsImpl extends _C2Splits { + _$C2SplitsImpl( + {this.type = "time", + this.time = 0, + this.calories = 0, + this.strokeRate = 0, + this.machine = "rower", + this.restDistance = "0", + this.heartRate = null}) + : super._(); + + factory _$C2SplitsImpl.fromJson(Map json) => + _$$C2SplitsImplFromJson(json); + + @override + @JsonKey() + final String type; + @override + @JsonKey() + final int time; + @override + @JsonKey() + final int calories; + @override + @JsonKey() + final int strokeRate; + @override + @JsonKey() + final String machine; + @override + @JsonKey() + final int restDistance; + @override + @JsonKey() + final C2HeartRate heartRate; + + @override + String toString() { + return 'C2Splits(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance, heartRate: $heartRate)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2SplitsImpl && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time) && + (identical(other.calories, calories) || + other.calories == calories) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && + (identical(other.machine, machine) || other.machine == machine) && + (identical(other.restDistance, restDistance) || + other.restDistance == restDistance) && + (identical(other.heartRate, heartRate) || + other.heartRate == heartRate)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, type, time, calories, strokeRate, + machine, restDistance, heartRate); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2SplitsImplCopyWith<_$C2SplitsImpl> get copyWith => + __$$C2SplitsImplCopyWithImpl<_$C2SplitsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2SplitsImplToJson( + this, + ); + } +} + +abstract class _C2Splits extends C2Splits { + factory _C2Splits( + {final String type, + final int time, + final int calories, + final int strokeRate, + final String machine, + final int restDistance, + final C2HeartRate heartRate}) = _$C2SplitsImpl; + _C2Splits._() : super._(); + + factory _C2Splits.fromJson(Map json) = + _$C2SplitsImpl.fromJson; + + @override + String get type; + @override + int get time; + @override + int get calories; + @override + int get strokeRate; + @override + String get machine; + @override + int get restDistance; + @override + C2HeartRate get heartRate; + @override + @JsonKey(ignore: true) + _$$C2SplitsImplCopyWith<_$C2SplitsImpl> get copyWith => + throw _privateConstructorUsedError; +} + C2User _$C2UserFromJson(Map json) { return _C2User.fromJson(json); } @@ -1512,26 +1861,18 @@ C2User _$C2UserFromJson(Map json) { mixin _$C2User { int get id => throw _privateConstructorUsedError; String get username => throw _privateConstructorUsedError; - @JsonKey(name: 'first_name') String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'last_name') String get lastName => throw _privateConstructorUsedError; String get gender => throw _privateConstructorUsedError; - @JsonKey(name: 'dob') String get birthday => throw _privateConstructorUsedError; String get email => throw _privateConstructorUsedError; String get country => throw _privateConstructorUsedError; - @JsonKey(name: 'profile_image') String? get profileImage => throw _privateConstructorUsedError; - @JsonKey(name: 'age_restricted') bool get ageRestricted => throw _privateConstructorUsedError; - @JsonKey(name: 'email_permission') bool get emailPermission => throw _privateConstructorUsedError; - @JsonKey(name: 'max_heart_rate') int? get maxHeartRate => throw _privateConstructorUsedError; int? get weight => throw _privateConstructorUsedError; List get roles => throw _privateConstructorUsedError; - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel get logbookPrivacy => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -1547,19 +1888,19 @@ abstract class $C2UserCopyWith<$Res> { $Res call( {int id, String username, - @JsonKey(name: 'first_name') String firstName, - @JsonKey(name: 'last_name') String lastName, + String firstName, + String lastName, String gender, - @JsonKey(name: 'dob') String birthday, + String birthday, String email, String country, - @JsonKey(name: 'profile_image') String? profileImage, - @JsonKey(name: 'age_restricted') bool ageRestricted, - @JsonKey(name: 'email_permission') bool emailPermission, - @JsonKey(name: 'max_heart_rate') int? maxHeartRate, + String? profileImage, + bool ageRestricted, + bool emailPermission, + int? maxHeartRate, int? weight, List roles, - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); + C2PrivacyLevel logbookPrivacy}); } /// @nodoc @@ -1666,19 +2007,19 @@ abstract class _$$C2UserImplCopyWith<$Res> implements $C2UserCopyWith<$Res> { $Res call( {int id, String username, - @JsonKey(name: 'first_name') String firstName, - @JsonKey(name: 'last_name') String lastName, + String firstName, + String lastName, String gender, - @JsonKey(name: 'dob') String birthday, + String birthday, String email, String country, - @JsonKey(name: 'profile_image') String? profileImage, - @JsonKey(name: 'age_restricted') bool ageRestricted, - @JsonKey(name: 'email_permission') bool emailPermission, - @JsonKey(name: 'max_heart_rate') int? maxHeartRate, + String? profileImage, + bool ageRestricted, + bool emailPermission, + int? maxHeartRate, int? weight, List roles, - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel logbookPrivacy}); + C2PrivacyLevel logbookPrivacy}); } /// @nodoc @@ -1779,19 +2120,18 @@ class _$C2UserImpl implements _C2User { const _$C2UserImpl( {this.id = 0, this.username = '', - @JsonKey(name: 'first_name') this.firstName = '', - @JsonKey(name: 'last_name') this.lastName = '', + this.firstName = '', + this.lastName = '', this.gender = 'F', - @JsonKey(name: 'dob') this.birthday = '1970-01-01', + this.birthday = '1970-01-01', this.email = '', this.country = '', - @JsonKey(name: 'profile_image') this.profileImage, - @JsonKey(name: 'age_restricted') this.ageRestricted = false, - @JsonKey(name: 'email_permission') this.emailPermission = false, - @JsonKey(name: 'max_heart_rate') this.maxHeartRate, + this.profileImage, + this.ageRestricted = false, + this.emailPermission = false, + this.maxHeartRate, this.weight, final List roles = const [], - @JsonKey(name: 'logbook_privacy') this.logbookPrivacy = C2PrivacyLevel.private}) : _roles = roles; @@ -1805,16 +2145,16 @@ class _$C2UserImpl implements _C2User { @JsonKey() final String username; @override - @JsonKey(name: 'first_name') + @JsonKey() final String firstName; @override - @JsonKey(name: 'last_name') + @JsonKey() final String lastName; @override @JsonKey() final String gender; @override - @JsonKey(name: 'dob') + @JsonKey() final String birthday; @override @JsonKey() @@ -1823,16 +2163,14 @@ class _$C2UserImpl implements _C2User { @JsonKey() final String country; @override - @JsonKey(name: 'profile_image') final String? profileImage; @override - @JsonKey(name: 'age_restricted') + @JsonKey() final bool ageRestricted; @override - @JsonKey(name: 'email_permission') + @JsonKey() final bool emailPermission; @override - @JsonKey(name: 'max_heart_rate') final int? maxHeartRate; @override final int? weight; @@ -1846,7 +2184,7 @@ class _$C2UserImpl implements _C2User { } @override - @JsonKey(name: 'logbook_privacy') + @JsonKey() final C2PrivacyLevel logbookPrivacy; @override @@ -1923,19 +2261,18 @@ abstract class _C2User implements C2User { const factory _C2User( {final int id, final String username, - @JsonKey(name: 'first_name') final String firstName, - @JsonKey(name: 'last_name') final String lastName, + final String firstName, + final String lastName, final String gender, - @JsonKey(name: 'dob') final String birthday, + final String birthday, final String email, final String country, - @JsonKey(name: 'profile_image') final String? profileImage, - @JsonKey(name: 'age_restricted') final bool ageRestricted, - @JsonKey(name: 'email_permission') final bool emailPermission, - @JsonKey(name: 'max_heart_rate') final int? maxHeartRate, + final String? profileImage, + final bool ageRestricted, + final bool emailPermission, + final int? maxHeartRate, final int? weight, final List roles, - @JsonKey(name: 'logbook_privacy') final C2PrivacyLevel logbookPrivacy}) = _$C2UserImpl; factory _C2User.fromJson(Map json) = _$C2UserImpl.fromJson; @@ -1945,38 +2282,30 @@ abstract class _C2User implements C2User { @override String get username; @override - @JsonKey(name: 'first_name') String get firstName; @override - @JsonKey(name: 'last_name') String get lastName; @override String get gender; @override - @JsonKey(name: 'dob') String get birthday; @override String get email; @override String get country; @override - @JsonKey(name: 'profile_image') String? get profileImage; @override - @JsonKey(name: 'age_restricted') bool get ageRestricted; @override - @JsonKey(name: 'email_permission') bool get emailPermission; @override - @JsonKey(name: 'max_heart_rate') int? get maxHeartRate; @override int? get weight; @override List get roles; @override - @JsonKey(name: 'logbook_privacy') C2PrivacyLevel get logbookPrivacy; @override @JsonKey(ignore: true) diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 3c1850c..3aacd1d 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -9,48 +9,62 @@ part of 'index.dart'; _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => _$C2FullResultsImpl( id: json['id'] as int? ?? 0, - userId: json['user_id'] as int? ?? 0, - endDate: const TimestampConverter().fromJson(json['date'] as String), - dateUtc: const TimestampOrNullConverter() - .fromJson(json['date_utc'] as String?), + userId: json['userId'] as int? ?? 0, + endDate: const TimestampConverter().fromJson(json['endDate'] as String), + dateUtc: + const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), timezone: json['timezone'] as String?, distance: json['distance'] as int? ?? 0, type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: $enumDecodeNullable( - _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? - C2APIWorkoutType.JustRow, + workoutType: + $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? + C2APIWorkoutType.JustRow, source: json['source'] as String? ?? "c2logbook dart", weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weightClass']) ?? C2WeightClass.heavyweight, - strokeRate: json['stroke_rate'] as int?, + strokeRate: json['strokeRate'] as int?, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, comments: json['comments'] as String?, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, + intervals: (json['intervals'] as List?) + ?.map((e) => C2Intervals.fromJson(e as Map)) + .toList() ?? + const [], + splits: (json['splits'] as List?) + ?.map((e) => C2Splits.fromJson(e as Map)) + .toList() ?? + const [], + heartRate: json['heartRate'] == null + ? null + : C2HeartRate.fromJson(json['heartRate'] as Map), ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => { 'id': instance.id, - 'user_id': instance.userId, - 'date': const TimestampConverter().toJson(instance.endDate), - 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'userId': instance.userId, + 'endDate': const TimestampConverter().toJson(instance.endDate), + 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, - 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, - 'stroke_rate': instance.strokeRate, + 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, + 'strokeRate': instance.strokeRate, 'verified': instance.verified, 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, + 'intervals': instance.intervals.map((e) => e.toJson()).toList(), + 'splits': instance.splits.map((e) => e.toJson()).toList(), + 'heartRate': instance.heartRate.toJson(), }; const _$C2ResultTypeEnumMap = { @@ -112,29 +126,33 @@ _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => _$C2IntervalsImpl( type: json['type'] as String? ?? "time", time: json['time'] as int? ?? 0, - calories: json['calories_total'] as int? ?? 0, - strokeRate: json['stroke_rate'] as int? ?? 0, + calories: json['calories'] as int? ?? 0, + strokeRate: json['strokeRate'] as int? ?? 0, machine: json['machine'] as String? ?? "rower", - restDistance: json['rest_distance'] as int? ?? "0", + restDistance: json['restDistance'] as int? ?? "0", + heartRate: json['heartRate'] == null + ? null + : C2HeartRate.fromJson(json['heartRate'] as Map), ); Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => { 'type': instance.type, 'time': instance.time, - 'calories_total': instance.calories, - 'stroke_rate': instance.strokeRate, + 'calories': instance.calories, + 'strokeRate': instance.strokeRate, 'machine': instance.machine, - 'rest_distance': instance.restDistance, + 'restDistance': instance.restDistance, + 'heartRate': instance.heartRate.toJson(), }; _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => _$C2ResultsImpl( id: json['id'] as int? ?? 0, - userId: json['user_id'] as int? ?? 0, - endDate: const TimestampConverter().fromJson(json['date'] as String), - dateUtc: const TimestampOrNullConverter() - .fromJson(json['date_utc'] as String?), + userId: json['userId'] as int? ?? 0, + endDate: const TimestampConverter().fromJson(json['endDate'] as String), + dateUtc: + const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), timezone: json['timezone'] as String?, distance: json['distance'] as int? ?? 0, type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? @@ -147,7 +165,7 @@ _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => weightClass: $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? C2WeightClass.heavyweight, - strokeRate: json['stroke_rate'] as int?, + strokeRate: json['strokeRate'] as int?, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, comments: json['comments'] as String?, @@ -158,9 +176,9 @@ _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => { 'id': instance.id, - 'user_id': instance.userId, - 'date': const TimestampConverter().toJson(instance.endDate), - 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'userId': instance.userId, + 'endDate': const TimestampConverter().toJson(instance.endDate), + 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, @@ -168,32 +186,56 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, - 'stroke_rate': instance.strokeRate, + 'strokeRate': instance.strokeRate, 'verified': instance.verified, 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, }; +_$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => + _$C2SplitsImpl( + type: json['type'] as String? ?? "time", + time: json['time'] as int? ?? 0, + calories: json['calories'] as int? ?? 0, + strokeRate: json['strokeRate'] as int? ?? 0, + machine: json['machine'] as String? ?? "rower", + restDistance: json['restDistance'] as int? ?? "0", + heartRate: json['heartRate'] == null + ? null + : C2HeartRate.fromJson(json['heartRate'] as Map), + ); + +Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => + { + 'type': instance.type, + 'time': instance.time, + 'calories': instance.calories, + 'strokeRate': instance.strokeRate, + 'machine': instance.machine, + 'restDistance': instance.restDistance, + 'heartRate': instance.heartRate.toJson(), + }; + _$C2UserImpl _$$C2UserImplFromJson(Map json) => _$C2UserImpl( id: json['id'] as int? ?? 0, username: json['username'] as String? ?? '', - firstName: json['first_name'] as String? ?? '', - lastName: json['last_name'] as String? ?? '', + firstName: json['firstName'] as String? ?? '', + lastName: json['lastName'] as String? ?? '', gender: json['gender'] as String? ?? 'F', - birthday: json['dob'] as String? ?? '1970-01-01', + birthday: json['birthday'] as String? ?? '1970-01-01', email: json['email'] as String? ?? '', country: json['country'] as String? ?? '', - profileImage: json['profile_image'] as String?, - ageRestricted: json['age_restricted'] as bool? ?? false, - emailPermission: json['email_permission'] as bool? ?? false, - maxHeartRate: json['max_heart_rate'] as int?, + profileImage: json['profileImage'] as String?, + ageRestricted: json['ageRestricted'] as bool? ?? false, + emailPermission: json['emailPermission'] as bool? ?? false, + maxHeartRate: json['maxHeartRate'] as int?, weight: json['weight'] as int?, roles: (json['roles'] as List?)?.map((e) => e as String).toList() ?? const [], logbookPrivacy: $enumDecodeNullable( - _$C2PrivacyLevelEnumMap, json['logbook_privacy']) ?? + _$C2PrivacyLevelEnumMap, json['logbookPrivacy']) ?? C2PrivacyLevel.private, ); @@ -201,17 +243,17 @@ Map _$$C2UserImplToJson(_$C2UserImpl instance) => { 'id': instance.id, 'username': instance.username, - 'first_name': instance.firstName, - 'last_name': instance.lastName, + 'firstName': instance.firstName, + 'lastName': instance.lastName, 'gender': instance.gender, - 'dob': instance.birthday, + 'birthday': instance.birthday, 'email': instance.email, 'country': instance.country, - 'profile_image': instance.profileImage, - 'age_restricted': instance.ageRestricted, - 'email_permission': instance.emailPermission, - 'max_heart_rate': instance.maxHeartRate, + 'profileImage': instance.profileImage, + 'ageRestricted': instance.ageRestricted, + 'emailPermission': instance.emailPermission, + 'maxHeartRate': instance.maxHeartRate, 'weight': instance.weight, 'roles': instance.roles, - 'logbook_privacy': _$C2PrivacyLevelEnumMap[instance.logbookPrivacy]!, + 'logbookPrivacy': _$C2PrivacyLevelEnumMap[instance.logbookPrivacy]!, }; diff --git a/test/c2logbook_test.dart b/test/c2logbook_test.dart index 25ac7ef..e6cae54 100644 --- a/test/c2logbook_test.dart +++ b/test/c2logbook_test.dart @@ -1,6 +1,7 @@ import 'package:c2logbook/c2logbook.dart'; import 'package:test/test.dart'; import 'dart:convert'; +import '../lib/src/types/index.dart'; void main() { final C2User testUser = C2User( From 13aa69eb23df3f76f2dbfb0ef64d003d36efe996 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:44:47 -0400 Subject: [PATCH 04/25] Anotha one --- lib/c2logbook.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/c2logbook.dart b/lib/c2logbook.dart index c952af3..17e6e78 100644 --- a/lib/c2logbook.dart +++ b/lib/c2logbook.dart @@ -4,5 +4,6 @@ library; export 'src/c2logbook_base.dart'; +export 'src/types/index.dart'; // TODO: Export any libraries intended for clients of this package. From 54e9bf82ccf1071930a5844d5e6a711476cdab59 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 09:56:31 -0400 Subject: [PATCH 05/25] Parsing support added for full c2 results --- example/pubspec.lock | 2 +- lib/src/types/c2_detailed_result.dart | 11 +++++++++++ lib/src/types/index.dart | 1 + pubspec.yaml | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 lib/src/types/c2_detailed_result.dart diff --git a/example/pubspec.lock b/example/pubspec.lock index 9fecb96..55741af 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -23,7 +23,7 @@ packages: path: ".." relative: true source: path - version: "0.0.2" + version: "0.0.3" characters: dependency: transitive description: diff --git a/lib/src/types/c2_detailed_result.dart b/lib/src/types/c2_detailed_result.dart new file mode 100644 index 0000000..9806611 --- /dev/null +++ b/lib/src/types/c2_detailed_result.dart @@ -0,0 +1,11 @@ +part of 'index.dart'; + +class C2DetailedResult { + /// Parse the data from incoming webhooks from the Concept2 API. + /// + /// Currently this only supports webhook data representing new workouts that have been added + static C2FullResults? parse(Map jsonBody) { + final Map jsonBodyData = jsonBody["data"]; + return C2FullResults.fromJson(jsonBodyData); + } +} diff --git a/lib/src/types/index.dart b/lib/src/types/index.dart index 48a40cd..e681870 100644 --- a/lib/src/types/index.dart +++ b/lib/src/types/index.dart @@ -1,6 +1,7 @@ import 'package:freezed_annotation/freezed_annotation.dart'; import '../utils.dart'; +part 'c2_detailed_result.dart'; part 'c2_full_results.dart'; part 'c2_heart_rate.dart'; part 'c2_intervals.dart'; diff --git a/pubspec.yaml b/pubspec.yaml index 5ae1664..fd79a39 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: c2logbook description: A Dart wrapper providing an Object-Oriented interface to the Concept2 Logbook API -version: 0.0.2 +version: 0.0.3 # repository: https://github.com/my_org/my_repo environment: From 3559304d3daefd1f220f0d661b234d98e73c9822 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:11:35 -0400 Subject: [PATCH 06/25] Added rest time --- lib/src/types/c2_full_results.dart | 1 + lib/src/types/index.freezed.dart | 27 ++++++++++++++++++++++++++- lib/src/types/index.g.dart | 3 +++ pubspec.yaml | 2 +- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 7cee125..ff30e2b 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -22,6 +22,7 @@ class C2FullResults with _$C2FullResults { @Default(0) int distance, @Default(C2ResultType.rower) C2ResultType type, @DecimalIntConverter.tenths() required double time, + @DecimalIntConverter.tenths() required double restTime, @Default(C2APIWorkoutType.JustRow) C2APIWorkoutType workoutType, @Default("c2logbook dart") String source, diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 3e0c26d..607f11d 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -31,6 +31,8 @@ mixin _$C2FullResults { C2ResultType get type => throw _privateConstructorUsedError; @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get restTime => throw _privateConstructorUsedError; C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; String get source => throw _privateConstructorUsedError; C2WeightClass get weightClass => throw _privateConstructorUsedError; @@ -64,6 +66,7 @@ abstract class $C2FullResultsCopyWith<$Res> { int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, + @DecimalIntConverter.tenths() double restTime, C2APIWorkoutType workoutType, String source, C2WeightClass weightClass, @@ -100,6 +103,7 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? distance = null, Object? type = null, Object? time = null, + Object? restTime = null, Object? workoutType = null, Object? source = null, Object? weightClass = null, @@ -145,6 +149,10 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.time : time // ignore: cast_nullable_to_non_nullable as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, workoutType: null == workoutType ? _value.workoutType : workoutType // ignore: cast_nullable_to_non_nullable @@ -218,6 +226,7 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, + @DecimalIntConverter.tenths() double restTime, C2APIWorkoutType workoutType, String source, C2WeightClass weightClass, @@ -253,6 +262,7 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? distance = null, Object? type = null, Object? time = null, + Object? restTime = null, Object? workoutType = null, Object? source = null, Object? weightClass = null, @@ -298,6 +308,10 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.time : time // ignore: cast_nullable_to_non_nullable as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, workoutType: null == workoutType ? _value.workoutType : workoutType // ignore: cast_nullable_to_non_nullable @@ -358,6 +372,7 @@ class _$C2FullResultsImpl extends _C2FullResults { this.distance = 0, this.type = C2ResultType.rower, @DecimalIntConverter.tenths() required this.time, + @DecimalIntConverter.tenths() required this.restTime, this.workoutType = C2APIWorkoutType.JustRow, this.source = "c2logbook dart", this.weightClass = C2WeightClass.heavyweight, @@ -400,6 +415,9 @@ class _$C2FullResultsImpl extends _C2FullResults { @DecimalIntConverter.tenths() final double time; @override + @DecimalIntConverter.tenths() + final double restTime; + @override @JsonKey() final C2APIWorkoutType workoutType; @override @@ -445,7 +463,7 @@ class _$C2FullResultsImpl extends _C2FullResults { @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; + return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, restTime: $restTime, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; } @override @@ -463,6 +481,8 @@ class _$C2FullResultsImpl extends _C2FullResults { other.distance == distance) && (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && + (identical(other.restTime, restTime) || + other.restTime == restTime) && (identical(other.workoutType, workoutType) || other.workoutType == workoutType) && (identical(other.source, source) || other.source == source) && @@ -495,6 +515,7 @@ class _$C2FullResultsImpl extends _C2FullResults { distance, type, time, + restTime, workoutType, source, weightClass, @@ -532,6 +553,7 @@ abstract class _C2FullResults extends C2FullResults { final int distance, final C2ResultType type, @DecimalIntConverter.tenths() required final double time, + @DecimalIntConverter.tenths() required final double restTime, final C2APIWorkoutType workoutType, final String source, final C2WeightClass weightClass, @@ -568,6 +590,9 @@ abstract class _C2FullResults extends C2FullResults { @DecimalIntConverter.tenths() double get time; @override + @DecimalIntConverter.tenths() + double get restTime; + @override C2APIWorkoutType get workoutType; @override String get source; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 3aacd1d..6191eb3 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -18,6 +18,8 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + restTime: + const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), workoutType: $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? C2APIWorkoutType.JustRow, @@ -54,6 +56,7 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, diff --git a/pubspec.yaml b/pubspec.yaml index fd79a39..e1c8b5e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: c2logbook description: A Dart wrapper providing an Object-Oriented interface to the Concept2 Logbook API -version: 0.0.3 +version: 0.0.4 # repository: https://github.com/my_org/my_repo environment: From e31c4027ca8d7ec0efaa8db9fb077652e730381c Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:17:48 -0400 Subject: [PATCH 07/25] Fixed some errors that occur on docker compose up in crewlab --- lib/src/types/c2_intervals.dart | 4 +- lib/src/types/c2_splits.dart | 2 +- lib/src/types/index.freezed.dart | 74 ++++++++++++++++++-------------- lib/src/types/index.g.dart | 6 +-- pubspec.yaml | 2 +- 5 files changed, 48 insertions(+), 40 deletions(-) diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart index 8a11c79..5604918 100644 --- a/lib/src/types/c2_intervals.dart +++ b/lib/src/types/c2_intervals.dart @@ -13,8 +13,8 @@ class C2Intervals with _$C2Intervals { @Default(0) int calories, @Default(0) int strokeRate, @Default("rower") String machine, - @Default("0") int restDistance, - @Default(null) C2HeartRate heartRate, + @Default(0) int restDistance, + @Default(null) C2HeartRate? heartRate, }) = _C2Intervals; factory C2Intervals.fromJson(Map json) => diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index 27d16b0..bd9c299 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -14,7 +14,7 @@ class C2Splits with _$C2Splits { @Default(0) int strokeRate, @Default("rower") String machine, @Default("0") int restDistance, - @Default(null) C2HeartRate heartRate, + @Default(null) C2HeartRate? heartRate, }) = _C2Splits; factory C2Splits.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 607f11d..47a5dba 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -827,7 +827,7 @@ mixin _$C2Intervals { int get strokeRate => throw _privateConstructorUsedError; String get machine => throw _privateConstructorUsedError; int get restDistance => throw _privateConstructorUsedError; - C2HeartRate get heartRate => throw _privateConstructorUsedError; + C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -848,9 +848,9 @@ abstract class $C2IntervalsCopyWith<$Res> { int strokeRate, String machine, int restDistance, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -872,7 +872,7 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_value.copyWith( type: null == type @@ -899,17 +899,21 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, ) as $Val); } @override @pragma('vm:prefer-inline') - $C2HeartRateCopyWith<$Res> get heartRate { - return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + $C2HeartRateCopyWith<$Res>? get heartRate { + if (_value.heartRate == null) { + return null; + } + + return $C2HeartRateCopyWith<$Res>(_value.heartRate!, (value) { return _then(_value.copyWith(heartRate: value) as $Val); }); } @@ -930,10 +934,10 @@ abstract class _$$C2IntervalsImplCopyWith<$Res> int strokeRate, String machine, int restDistance, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); @override - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -953,7 +957,7 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_$C2IntervalsImpl( type: null == type @@ -980,10 +984,10 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, )); } } @@ -997,7 +1001,7 @@ class _$C2IntervalsImpl extends _C2Intervals { this.calories = 0, this.strokeRate = 0, this.machine = "rower", - this.restDistance = "0", + this.restDistance = 0, this.heartRate = null}) : super._(); @@ -1024,7 +1028,7 @@ class _$C2IntervalsImpl extends _C2Intervals { final int restDistance; @override @JsonKey() - final C2HeartRate heartRate; + final C2HeartRate? heartRate; @override String toString() { @@ -1076,7 +1080,7 @@ abstract class _C2Intervals extends C2Intervals { final int strokeRate, final String machine, final int restDistance, - final C2HeartRate heartRate}) = _$C2IntervalsImpl; + final C2HeartRate? heartRate}) = _$C2IntervalsImpl; _C2Intervals._() : super._(); factory _C2Intervals.fromJson(Map json) = @@ -1095,7 +1099,7 @@ abstract class _C2Intervals extends C2Intervals { @override int get restDistance; @override - C2HeartRate get heartRate; + C2HeartRate? get heartRate; @override @JsonKey(ignore: true) _$$C2IntervalsImplCopyWith<_$C2IntervalsImpl> get copyWith => @@ -1604,7 +1608,7 @@ mixin _$C2Splits { int get strokeRate => throw _privateConstructorUsedError; String get machine => throw _privateConstructorUsedError; int get restDistance => throw _privateConstructorUsedError; - C2HeartRate get heartRate => throw _privateConstructorUsedError; + C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -1624,9 +1628,9 @@ abstract class $C2SplitsCopyWith<$Res> { int strokeRate, String machine, int restDistance, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -1648,7 +1652,7 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_value.copyWith( type: null == type @@ -1675,17 +1679,21 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, ) as $Val); } @override @pragma('vm:prefer-inline') - $C2HeartRateCopyWith<$Res> get heartRate { - return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + $C2HeartRateCopyWith<$Res>? get heartRate { + if (_value.heartRate == null) { + return null; + } + + return $C2HeartRateCopyWith<$Res>(_value.heartRate!, (value) { return _then(_value.copyWith(heartRate: value) as $Val); }); } @@ -1706,10 +1714,10 @@ abstract class _$$C2SplitsImplCopyWith<$Res> int strokeRate, String machine, int restDistance, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); @override - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -1729,7 +1737,7 @@ class __$$C2SplitsImplCopyWithImpl<$Res> Object? strokeRate = null, Object? machine = null, Object? restDistance = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_$C2SplitsImpl( type: null == type @@ -1756,10 +1764,10 @@ class __$$C2SplitsImplCopyWithImpl<$Res> ? _value.restDistance : restDistance // ignore: cast_nullable_to_non_nullable as int, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, )); } } @@ -1800,7 +1808,7 @@ class _$C2SplitsImpl extends _C2Splits { final int restDistance; @override @JsonKey() - final C2HeartRate heartRate; + final C2HeartRate? heartRate; @override String toString() { @@ -1852,7 +1860,7 @@ abstract class _C2Splits extends C2Splits { final int strokeRate, final String machine, final int restDistance, - final C2HeartRate heartRate}) = _$C2SplitsImpl; + final C2HeartRate? heartRate}) = _$C2SplitsImpl; _C2Splits._() : super._(); factory _C2Splits.fromJson(Map json) = @@ -1871,7 +1879,7 @@ abstract class _C2Splits extends C2Splits { @override int get restDistance; @override - C2HeartRate get heartRate; + C2HeartRate? get heartRate; @override @JsonKey(ignore: true) _$$C2SplitsImplCopyWith<_$C2SplitsImpl> get copyWith => diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 6191eb3..127e6d0 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -132,7 +132,7 @@ _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => calories: json['calories'] as int? ?? 0, strokeRate: json['strokeRate'] as int? ?? 0, machine: json['machine'] as String? ?? "rower", - restDistance: json['restDistance'] as int? ?? "0", + restDistance: json['restDistance'] as int? ?? 0, heartRate: json['heartRate'] == null ? null : C2HeartRate.fromJson(json['heartRate'] as Map), @@ -146,7 +146,7 @@ Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => 'strokeRate': instance.strokeRate, 'machine': instance.machine, 'restDistance': instance.restDistance, - 'heartRate': instance.heartRate.toJson(), + 'heartRate': instance.heartRate?.toJson(), }; _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => @@ -217,7 +217,7 @@ Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => 'strokeRate': instance.strokeRate, 'machine': instance.machine, 'restDistance': instance.restDistance, - 'heartRate': instance.heartRate.toJson(), + 'heartRate': instance.heartRate?.toJson(), }; _$C2UserImpl _$$C2UserImplFromJson(Map json) => _$C2UserImpl( diff --git a/pubspec.yaml b/pubspec.yaml index e1c8b5e..03ed44f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: c2logbook description: A Dart wrapper providing an Object-Oriented interface to the Concept2 Logbook API -version: 0.0.4 +version: 0.0.5 # repository: https://github.com/my_org/my_repo environment: From 5c2b68f60679d1a7b09a1e4d2cdd43a32fdb641e Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:18:05 -0400 Subject: [PATCH 08/25] Fixed some errors that occur on docker compose up in crewlab --- example/pubspec.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index 55741af..afc6383 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -23,7 +23,7 @@ packages: path: ".." relative: true source: path - version: "0.0.3" + version: "0.0.5" characters: dependency: transitive description: From 9da62a4d1523907fecca79603fcba74695e03956 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:32:26 -0400 Subject: [PATCH 09/25] I swear I fixed this wtf --- lib/src/types/c2_splits.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index bd9c299..610ebbc 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -13,7 +13,7 @@ class C2Splits with _$C2Splits { @Default(0) int calories, @Default(0) int strokeRate, @Default("rower") String machine, - @Default("0") int restDistance, + @Default(0) int restDistance, @Default(null) C2HeartRate? heartRate, }) = _C2Splits; From 6f0787bdb0389ec9c2284b591ed00c2ba380d575 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:42:45 -0400 Subject: [PATCH 10/25] More tweaking of models --- lib/src/types/c2_full_results.dart | 4 +- lib/src/types/c2_intervals.dart | 8 +- lib/src/types/c2_results.dart | 8 +- lib/src/types/c2_splits.dart | 7 +- lib/src/types/index.freezed.dart | 406 ++++++++++++++--------------- lib/src/types/index.g.dart | 57 ++-- 6 files changed, 236 insertions(+), 254 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index ff30e2b..bfc9cd7 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -16,7 +16,7 @@ class C2FullResults with _$C2FullResults { factory C2FullResults({ @Default(0) int id, @Default(0) int userId, - @TimestampConverter() required DateTime endDate, + @TimestampConverter() required DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, @Default(0) int distance, @@ -35,7 +35,7 @@ class C2FullResults with _$C2FullResults { @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, @Default([]) List intervals, @Default([]) List splits, - @Default(null) C2HeartRate heartRate, + @Default(null) C2HeartRate? heartRate, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart index 5604918..c70c5f4 100644 --- a/lib/src/types/c2_intervals.dart +++ b/lib/src/types/c2_intervals.dart @@ -9,11 +9,11 @@ class C2Intervals with _$C2Intervals { factory C2Intervals({ @Default("time") String type, - @Default(0) int time, - @Default(0) int calories, + @DecimalIntConverter.tenths() required double time, + @DecimalIntConverter.tenths() required double restTime, + @Default(0) double distance, + @Default(0) int caloriesTotal, @Default(0) int strokeRate, - @Default("rower") String machine, - @Default(0) int restDistance, @Default(null) C2HeartRate? heartRate, }) = _C2Intervals; diff --git a/lib/src/types/c2_results.dart b/lib/src/types/c2_results.dart index bcefdec..660c819 100644 --- a/lib/src/types/c2_results.dart +++ b/lib/src/types/c2_results.dart @@ -16,23 +16,21 @@ class C2Results with _$C2Results { factory C2Results({ @Default(0) int id, @Default(0) int userId, - @TimestampConverter() required DateTime endDate, + @TimestampConverter() required DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, @Default(0) int distance, @Default(C2ResultType.rower) C2ResultType type, @DecimalIntConverter.tenths() required double time, - @JsonKey(name: "workout_type") @Default(C2APIWorkoutType.JustRow) C2APIWorkoutType workoutType, @Default("c2logbook dart") String source, - @JsonKey(name: "weight_class") @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - int? strokeRate, + @Default(null) int? strokeRate, @Default(false) bool verified, @Default(false) bool ranked, - String? comments, + @Default(null) String? comments, @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, }) = _C2Results; diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index 610ebbc..544e83a 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -9,11 +9,10 @@ class C2Splits with _$C2Splits { factory C2Splits({ @Default("time") String type, - @Default(0) int time, - @Default(0) int calories, + @DecimalIntConverter.tenths() required double time, + @Default(0) double distance, + @Default(0) int caloriesTotal, @Default(0) int strokeRate, - @Default("rower") String machine, - @Default(0) int restDistance, @Default(null) C2HeartRate? heartRate, }) = _C2Splits; diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 47a5dba..5629021 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -23,7 +23,7 @@ mixin _$C2FullResults { int get id => throw _privateConstructorUsedError; int get userId => throw _privateConstructorUsedError; @TimestampConverter() - DateTime get endDate => throw _privateConstructorUsedError; + DateTime get date => throw _privateConstructorUsedError; @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; String? get timezone => throw _privateConstructorUsedError; @@ -43,7 +43,7 @@ mixin _$C2FullResults { C2PrivacyLevel get privacy => throw _privateConstructorUsedError; List get intervals => throw _privateConstructorUsedError; List get splits => throw _privateConstructorUsedError; - C2HeartRate get heartRate => throw _privateConstructorUsedError; + C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -60,7 +60,7 @@ abstract class $C2FullResultsCopyWith<$Res> { $Res call( {int id, int userId, - @TimestampConverter() DateTime endDate, + @TimestampConverter() DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, @@ -77,9 +77,9 @@ abstract class $C2FullResultsCopyWith<$Res> { C2PrivacyLevel privacy, List intervals, List splits, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -97,7 +97,7 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> $Res call({ Object? id = null, Object? userId = null, - Object? endDate = null, + Object? date = null, Object? dateUtc = freezed, Object? timezone = freezed, Object? distance = null, @@ -114,7 +114,7 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? privacy = null, Object? intervals = null, Object? splits = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_value.copyWith( id: null == id @@ -125,9 +125,9 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.userId : userId // ignore: cast_nullable_to_non_nullable as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable as DateTime, dateUtc: freezed == dateUtc ? _value.dateUtc @@ -193,17 +193,21 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.splits : splits // ignore: cast_nullable_to_non_nullable as List, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, ) as $Val); } @override @pragma('vm:prefer-inline') - $C2HeartRateCopyWith<$Res> get heartRate { - return $C2HeartRateCopyWith<$Res>(_value.heartRate, (value) { + $C2HeartRateCopyWith<$Res>? get heartRate { + if (_value.heartRate == null) { + return null; + } + + return $C2HeartRateCopyWith<$Res>(_value.heartRate!, (value) { return _then(_value.copyWith(heartRate: value) as $Val); }); } @@ -220,7 +224,7 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> $Res call( {int id, int userId, - @TimestampConverter() DateTime endDate, + @TimestampConverter() DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, @@ -237,10 +241,10 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> C2PrivacyLevel privacy, List intervals, List splits, - C2HeartRate heartRate}); + C2HeartRate? heartRate}); @override - $C2HeartRateCopyWith<$Res> get heartRate; + $C2HeartRateCopyWith<$Res>? get heartRate; } /// @nodoc @@ -256,7 +260,7 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> $Res call({ Object? id = null, Object? userId = null, - Object? endDate = null, + Object? date = null, Object? dateUtc = freezed, Object? timezone = freezed, Object? distance = null, @@ -273,7 +277,7 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? privacy = null, Object? intervals = null, Object? splits = null, - Object? heartRate = null, + Object? heartRate = freezed, }) { return _then(_$C2FullResultsImpl( id: null == id @@ -284,9 +288,9 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.userId : userId // ignore: cast_nullable_to_non_nullable as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable as DateTime, dateUtc: freezed == dateUtc ? _value.dateUtc @@ -352,10 +356,10 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value._splits : splits // ignore: cast_nullable_to_non_nullable as List, - heartRate: null == heartRate + heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate, + as C2HeartRate?, )); } } @@ -366,7 +370,7 @@ class _$C2FullResultsImpl extends _C2FullResults { _$C2FullResultsImpl( {this.id = 0, this.userId = 0, - @TimestampConverter() required this.endDate, + @TimestampConverter() required this.date, @TimestampOrNullConverter() this.dateUtc, this.timezone, this.distance = 0, @@ -399,7 +403,7 @@ class _$C2FullResultsImpl extends _C2FullResults { final int userId; @override @TimestampConverter() - final DateTime endDate; + final DateTime date; @override @TimestampOrNullConverter() final DateTime? dateUtc; @@ -459,11 +463,11 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey() - final C2HeartRate heartRate; + final C2HeartRate? heartRate; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, restTime: $restTime, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; + return 'C2FullResults(id: $id, userId: $userId, date: $date, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, restTime: $restTime, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; } @override @@ -473,7 +477,7 @@ class _$C2FullResultsImpl extends _C2FullResults { other is _$C2FullResultsImpl && (identical(other.id, id) || other.id == id) && (identical(other.userId, userId) || other.userId == userId) && - (identical(other.endDate, endDate) || other.endDate == endDate) && + (identical(other.date, date) || other.date == date) && (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && (identical(other.timezone, timezone) || other.timezone == timezone) && @@ -509,7 +513,7 @@ class _$C2FullResultsImpl extends _C2FullResults { runtimeType, id, userId, - endDate, + date, dateUtc, timezone, distance, @@ -547,7 +551,7 @@ abstract class _C2FullResults extends C2FullResults { factory _C2FullResults( {final int id, final int userId, - @TimestampConverter() required final DateTime endDate, + @TimestampConverter() required final DateTime date, @TimestampOrNullConverter() final DateTime? dateUtc, final String? timezone, final int distance, @@ -564,7 +568,7 @@ abstract class _C2FullResults extends C2FullResults { final C2PrivacyLevel privacy, final List intervals, final List splits, - final C2HeartRate heartRate}) = _$C2FullResultsImpl; + final C2HeartRate? heartRate}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -576,7 +580,7 @@ abstract class _C2FullResults extends C2FullResults { int get userId; @override @TimestampConverter() - DateTime get endDate; + DateTime get date; @override @TimestampOrNullConverter() DateTime? get dateUtc; @@ -613,7 +617,7 @@ abstract class _C2FullResults extends C2FullResults { @override List get splits; @override - C2HeartRate get heartRate; + C2HeartRate? get heartRate; @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => @@ -822,11 +826,13 @@ C2Intervals _$C2IntervalsFromJson(Map json) { /// @nodoc mixin _$C2Intervals { String get type => throw _privateConstructorUsedError; - int get time => throw _privateConstructorUsedError; - int get calories => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get time => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get restTime => throw _privateConstructorUsedError; + double get distance => throw _privateConstructorUsedError; + int get caloriesTotal => throw _privateConstructorUsedError; int get strokeRate => throw _privateConstructorUsedError; - String get machine => throw _privateConstructorUsedError; - int get restDistance => throw _privateConstructorUsedError; C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -843,11 +849,11 @@ abstract class $C2IntervalsCopyWith<$Res> { @useResult $Res call( {String type, - int time, - int calories, + @DecimalIntConverter.tenths() double time, + @DecimalIntConverter.tenths() double restTime, + double distance, + int caloriesTotal, int strokeRate, - String machine, - int restDistance, C2HeartRate? heartRate}); $C2HeartRateCopyWith<$Res>? get heartRate; @@ -868,10 +874,10 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> $Res call({ Object? type = null, Object? time = null, - Object? calories = null, + Object? restTime = null, + Object? distance = null, + Object? caloriesTotal = null, Object? strokeRate = null, - Object? machine = null, - Object? restDistance = null, Object? heartRate = freezed, }) { return _then(_value.copyWith( @@ -882,23 +888,23 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable - as int, - calories: null == calories - ? _value.calories - : calories // ignore: cast_nullable_to_non_nullable + as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as double, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable as int, strokeRate: null == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int, - machine: null == machine - ? _value.machine - : machine // ignore: cast_nullable_to_non_nullable - as String, - restDistance: null == restDistance - ? _value.restDistance - : restDistance // ignore: cast_nullable_to_non_nullable - as int, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable @@ -929,11 +935,11 @@ abstract class _$$C2IntervalsImplCopyWith<$Res> @useResult $Res call( {String type, - int time, - int calories, + @DecimalIntConverter.tenths() double time, + @DecimalIntConverter.tenths() double restTime, + double distance, + int caloriesTotal, int strokeRate, - String machine, - int restDistance, C2HeartRate? heartRate}); @override @@ -953,10 +959,10 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> $Res call({ Object? type = null, Object? time = null, - Object? calories = null, + Object? restTime = null, + Object? distance = null, + Object? caloriesTotal = null, Object? strokeRate = null, - Object? machine = null, - Object? restDistance = null, Object? heartRate = freezed, }) { return _then(_$C2IntervalsImpl( @@ -967,23 +973,23 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable - as int, - calories: null == calories - ? _value.calories - : calories // ignore: cast_nullable_to_non_nullable + as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as double, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable as int, strokeRate: null == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int, - machine: null == machine - ? _value.machine - : machine // ignore: cast_nullable_to_non_nullable - as String, - restDistance: null == restDistance - ? _value.restDistance - : restDistance // ignore: cast_nullable_to_non_nullable - as int, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable @@ -997,11 +1003,11 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> class _$C2IntervalsImpl extends _C2Intervals { _$C2IntervalsImpl( {this.type = "time", - this.time = 0, - this.calories = 0, + @DecimalIntConverter.tenths() required this.time, + @DecimalIntConverter.tenths() required this.restTime, + this.distance = 0, + this.caloriesTotal = 0, this.strokeRate = 0, - this.machine = "rower", - this.restDistance = 0, this.heartRate = null}) : super._(); @@ -1012,27 +1018,27 @@ class _$C2IntervalsImpl extends _C2Intervals { @JsonKey() final String type; @override - @JsonKey() - final int time; + @DecimalIntConverter.tenths() + final double time; @override - @JsonKey() - final int calories; + @DecimalIntConverter.tenths() + final double restTime; @override @JsonKey() - final int strokeRate; + final double distance; @override @JsonKey() - final String machine; + final int caloriesTotal; @override @JsonKey() - final int restDistance; + final int strokeRate; @override @JsonKey() final C2HeartRate? heartRate; @override String toString() { - return 'C2Intervals(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance, heartRate: $heartRate)'; + return 'C2Intervals(type: $type, time: $time, restTime: $restTime, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; } @override @@ -1042,21 +1048,22 @@ class _$C2IntervalsImpl extends _C2Intervals { other is _$C2IntervalsImpl && (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && - (identical(other.calories, calories) || - other.calories == calories) && + (identical(other.restTime, restTime) || + other.restTime == restTime) && + (identical(other.distance, distance) || + other.distance == distance) && + (identical(other.caloriesTotal, caloriesTotal) || + other.caloriesTotal == caloriesTotal) && (identical(other.strokeRate, strokeRate) || other.strokeRate == strokeRate) && - (identical(other.machine, machine) || other.machine == machine) && - (identical(other.restDistance, restDistance) || - other.restDistance == restDistance) && (identical(other.heartRate, heartRate) || other.heartRate == heartRate)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, type, time, calories, strokeRate, - machine, restDistance, heartRate); + int get hashCode => Object.hash(runtimeType, type, time, restTime, distance, + caloriesTotal, strokeRate, heartRate); @JsonKey(ignore: true) @override @@ -1075,11 +1082,11 @@ class _$C2IntervalsImpl extends _C2Intervals { abstract class _C2Intervals extends C2Intervals { factory _C2Intervals( {final String type, - final int time, - final int calories, + @DecimalIntConverter.tenths() required final double time, + @DecimalIntConverter.tenths() required final double restTime, + final double distance, + final int caloriesTotal, final int strokeRate, - final String machine, - final int restDistance, final C2HeartRate? heartRate}) = _$C2IntervalsImpl; _C2Intervals._() : super._(); @@ -1089,15 +1096,17 @@ abstract class _C2Intervals extends C2Intervals { @override String get type; @override - int get time; + @DecimalIntConverter.tenths() + double get time; @override - int get calories; + @DecimalIntConverter.tenths() + double get restTime; @override - int get strokeRate; + double get distance; @override - String get machine; + int get caloriesTotal; @override - int get restDistance; + int get strokeRate; @override C2HeartRate? get heartRate; @override @@ -1115,7 +1124,7 @@ mixin _$C2Results { int get id => throw _privateConstructorUsedError; int get userId => throw _privateConstructorUsedError; @TimestampConverter() - DateTime get endDate => throw _privateConstructorUsedError; + DateTime get date => throw _privateConstructorUsedError; @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; String? get timezone => throw _privateConstructorUsedError; @@ -1123,10 +1132,8 @@ mixin _$C2Results { C2ResultType get type => throw _privateConstructorUsedError; @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; - @JsonKey(name: "workout_type") C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; String get source => throw _privateConstructorUsedError; - @JsonKey(name: "weight_class") C2WeightClass get weightClass => throw _privateConstructorUsedError; int? get strokeRate => throw _privateConstructorUsedError; bool get verified => throw _privateConstructorUsedError; @@ -1148,15 +1155,15 @@ abstract class $C2ResultsCopyWith<$Res> { $Res call( {int id, int userId, - @TimestampConverter() DateTime endDate, + @TimestampConverter() DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + C2APIWorkoutType workoutType, String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, + C2WeightClass weightClass, int? strokeRate, bool verified, bool ranked, @@ -1179,7 +1186,7 @@ class _$C2ResultsCopyWithImpl<$Res, $Val extends C2Results> $Res call({ Object? id = null, Object? userId = null, - Object? endDate = null, + Object? date = null, Object? dateUtc = freezed, Object? timezone = freezed, Object? distance = null, @@ -1203,9 +1210,9 @@ class _$C2ResultsCopyWithImpl<$Res, $Val extends C2Results> ? _value.userId : userId // ignore: cast_nullable_to_non_nullable as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable as DateTime, dateUtc: freezed == dateUtc ? _value.dateUtc @@ -1274,15 +1281,15 @@ abstract class _$$C2ResultsImplCopyWith<$Res> $Res call( {int id, int userId, - @TimestampConverter() DateTime endDate, + @TimestampConverter() DateTime date, @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @JsonKey(name: "workout_type") C2APIWorkoutType workoutType, + C2APIWorkoutType workoutType, String source, - @JsonKey(name: "weight_class") C2WeightClass weightClass, + C2WeightClass weightClass, int? strokeRate, bool verified, bool ranked, @@ -1303,7 +1310,7 @@ class __$$C2ResultsImplCopyWithImpl<$Res> $Res call({ Object? id = null, Object? userId = null, - Object? endDate = null, + Object? date = null, Object? dateUtc = freezed, Object? timezone = freezed, Object? distance = null, @@ -1327,9 +1334,9 @@ class __$$C2ResultsImplCopyWithImpl<$Res> ? _value.userId : userId // ignore: cast_nullable_to_non_nullable as int, - endDate: null == endDate - ? _value.endDate - : endDate // ignore: cast_nullable_to_non_nullable + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable as DateTime, dateUtc: freezed == dateUtc ? _value.dateUtc @@ -1393,21 +1400,19 @@ class _$C2ResultsImpl extends _C2Results { _$C2ResultsImpl( {this.id = 0, this.userId = 0, - @TimestampConverter() required this.endDate, + @TimestampConverter() required this.date, @TimestampOrNullConverter() this.dateUtc, this.timezone, this.distance = 0, this.type = C2ResultType.rower, @DecimalIntConverter.tenths() required this.time, - @JsonKey(name: "workout_type") this.workoutType = C2APIWorkoutType.JustRow, this.source = "c2logbook dart", - @JsonKey(name: "weight_class") this.weightClass = C2WeightClass.heavyweight, - this.strokeRate, + this.strokeRate = null, this.verified = false, this.ranked = false, - this.comments, + this.comments = null, this.privacy = C2PrivacyLevel.private}) : super._(); @@ -1422,7 +1427,7 @@ class _$C2ResultsImpl extends _C2Results { final int userId; @override @TimestampConverter() - final DateTime endDate; + final DateTime date; @override @TimestampOrNullConverter() final DateTime? dateUtc; @@ -1438,15 +1443,16 @@ class _$C2ResultsImpl extends _C2Results { @DecimalIntConverter.tenths() final double time; @override - @JsonKey(name: "workout_type") + @JsonKey() final C2APIWorkoutType workoutType; @override @JsonKey() final String source; @override - @JsonKey(name: "weight_class") + @JsonKey() final C2WeightClass weightClass; @override + @JsonKey() final int? strokeRate; @override @JsonKey() @@ -1455,6 +1461,7 @@ class _$C2ResultsImpl extends _C2Results { @JsonKey() final bool ranked; @override + @JsonKey() final String? comments; @override @JsonKey() @@ -1462,7 +1469,7 @@ class _$C2ResultsImpl extends _C2Results { @override String toString() { - return 'C2Results(id: $id, userId: $userId, endDate: $endDate, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; + return 'C2Results(id: $id, userId: $userId, date: $date, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy)'; } @override @@ -1472,7 +1479,7 @@ class _$C2ResultsImpl extends _C2Results { other is _$C2ResultsImpl && (identical(other.id, id) || other.id == id) && (identical(other.userId, userId) || other.userId == userId) && - (identical(other.endDate, endDate) || other.endDate == endDate) && + (identical(other.date, date) || other.date == date) && (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && (identical(other.timezone, timezone) || other.timezone == timezone) && @@ -1501,7 +1508,7 @@ class _$C2ResultsImpl extends _C2Results { runtimeType, id, userId, - endDate, + date, dateUtc, timezone, distance, @@ -1534,15 +1541,15 @@ abstract class _C2Results extends C2Results { factory _C2Results( {final int id, final int userId, - @TimestampConverter() required final DateTime endDate, + @TimestampConverter() required final DateTime date, @TimestampOrNullConverter() final DateTime? dateUtc, final String? timezone, final int distance, final C2ResultType type, @DecimalIntConverter.tenths() required final double time, - @JsonKey(name: "workout_type") final C2APIWorkoutType workoutType, + final C2APIWorkoutType workoutType, final String source, - @JsonKey(name: "weight_class") final C2WeightClass weightClass, + final C2WeightClass weightClass, final int? strokeRate, final bool verified, final bool ranked, @@ -1559,7 +1566,7 @@ abstract class _C2Results extends C2Results { int get userId; @override @TimestampConverter() - DateTime get endDate; + DateTime get date; @override @TimestampOrNullConverter() DateTime? get dateUtc; @@ -1573,12 +1580,10 @@ abstract class _C2Results extends C2Results { @DecimalIntConverter.tenths() double get time; @override - @JsonKey(name: "workout_type") C2APIWorkoutType get workoutType; @override String get source; @override - @JsonKey(name: "weight_class") C2WeightClass get weightClass; @override int? get strokeRate; @@ -1603,11 +1608,11 @@ C2Splits _$C2SplitsFromJson(Map json) { /// @nodoc mixin _$C2Splits { String get type => throw _privateConstructorUsedError; - int get time => throw _privateConstructorUsedError; - int get calories => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get time => throw _privateConstructorUsedError; + double get distance => throw _privateConstructorUsedError; + int get caloriesTotal => throw _privateConstructorUsedError; int get strokeRate => throw _privateConstructorUsedError; - String get machine => throw _privateConstructorUsedError; - int get restDistance => throw _privateConstructorUsedError; C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -1623,11 +1628,10 @@ abstract class $C2SplitsCopyWith<$Res> { @useResult $Res call( {String type, - int time, - int calories, + @DecimalIntConverter.tenths() double time, + double distance, + int caloriesTotal, int strokeRate, - String machine, - int restDistance, C2HeartRate? heartRate}); $C2HeartRateCopyWith<$Res>? get heartRate; @@ -1648,10 +1652,9 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> $Res call({ Object? type = null, Object? time = null, - Object? calories = null, + Object? distance = null, + Object? caloriesTotal = null, Object? strokeRate = null, - Object? machine = null, - Object? restDistance = null, Object? heartRate = freezed, }) { return _then(_value.copyWith( @@ -1662,23 +1665,19 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable - as int, - calories: null == calories - ? _value.calories - : calories // ignore: cast_nullable_to_non_nullable + as double, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as double, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable as int, strokeRate: null == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int, - machine: null == machine - ? _value.machine - : machine // ignore: cast_nullable_to_non_nullable - as String, - restDistance: null == restDistance - ? _value.restDistance - : restDistance // ignore: cast_nullable_to_non_nullable - as int, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable @@ -1709,11 +1708,10 @@ abstract class _$$C2SplitsImplCopyWith<$Res> @useResult $Res call( {String type, - int time, - int calories, + @DecimalIntConverter.tenths() double time, + double distance, + int caloriesTotal, int strokeRate, - String machine, - int restDistance, C2HeartRate? heartRate}); @override @@ -1733,10 +1731,9 @@ class __$$C2SplitsImplCopyWithImpl<$Res> $Res call({ Object? type = null, Object? time = null, - Object? calories = null, + Object? distance = null, + Object? caloriesTotal = null, Object? strokeRate = null, - Object? machine = null, - Object? restDistance = null, Object? heartRate = freezed, }) { return _then(_$C2SplitsImpl( @@ -1747,23 +1744,19 @@ class __$$C2SplitsImplCopyWithImpl<$Res> time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable - as int, - calories: null == calories - ? _value.calories - : calories // ignore: cast_nullable_to_non_nullable + as double, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as double, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable as int, strokeRate: null == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int, - machine: null == machine - ? _value.machine - : machine // ignore: cast_nullable_to_non_nullable - as String, - restDistance: null == restDistance - ? _value.restDistance - : restDistance // ignore: cast_nullable_to_non_nullable - as int, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable @@ -1777,11 +1770,10 @@ class __$$C2SplitsImplCopyWithImpl<$Res> class _$C2SplitsImpl extends _C2Splits { _$C2SplitsImpl( {this.type = "time", - this.time = 0, - this.calories = 0, + @DecimalIntConverter.tenths() required this.time, + this.distance = 0, + this.caloriesTotal = 0, this.strokeRate = 0, - this.machine = "rower", - this.restDistance = "0", this.heartRate = null}) : super._(); @@ -1792,27 +1784,24 @@ class _$C2SplitsImpl extends _C2Splits { @JsonKey() final String type; @override - @JsonKey() - final int time; - @override - @JsonKey() - final int calories; + @DecimalIntConverter.tenths() + final double time; @override @JsonKey() - final int strokeRate; + final double distance; @override @JsonKey() - final String machine; + final int caloriesTotal; @override @JsonKey() - final int restDistance; + final int strokeRate; @override @JsonKey() final C2HeartRate? heartRate; @override String toString() { - return 'C2Splits(type: $type, time: $time, calories: $calories, strokeRate: $strokeRate, machine: $machine, restDistance: $restDistance, heartRate: $heartRate)'; + return 'C2Splits(type: $type, time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; } @override @@ -1822,21 +1811,20 @@ class _$C2SplitsImpl extends _C2Splits { other is _$C2SplitsImpl && (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && - (identical(other.calories, calories) || - other.calories == calories) && + (identical(other.distance, distance) || + other.distance == distance) && + (identical(other.caloriesTotal, caloriesTotal) || + other.caloriesTotal == caloriesTotal) && (identical(other.strokeRate, strokeRate) || other.strokeRate == strokeRate) && - (identical(other.machine, machine) || other.machine == machine) && - (identical(other.restDistance, restDistance) || - other.restDistance == restDistance) && (identical(other.heartRate, heartRate) || other.heartRate == heartRate)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, type, time, calories, strokeRate, - machine, restDistance, heartRate); + int get hashCode => Object.hash( + runtimeType, type, time, distance, caloriesTotal, strokeRate, heartRate); @JsonKey(ignore: true) @override @@ -1855,11 +1843,10 @@ class _$C2SplitsImpl extends _C2Splits { abstract class _C2Splits extends C2Splits { factory _C2Splits( {final String type, - final int time, - final int calories, + @DecimalIntConverter.tenths() required final double time, + final double distance, + final int caloriesTotal, final int strokeRate, - final String machine, - final int restDistance, final C2HeartRate? heartRate}) = _$C2SplitsImpl; _C2Splits._() : super._(); @@ -1869,15 +1856,14 @@ abstract class _C2Splits extends C2Splits { @override String get type; @override - int get time; - @override - int get calories; + @DecimalIntConverter.tenths() + double get time; @override - int get strokeRate; + double get distance; @override - String get machine; + int get caloriesTotal; @override - int get restDistance; + int get strokeRate; @override C2HeartRate? get heartRate; @override diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 127e6d0..825af9c 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -10,7 +10,7 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => _$C2FullResultsImpl( id: json['id'] as int? ?? 0, userId: json['userId'] as int? ?? 0, - endDate: const TimestampConverter().fromJson(json['endDate'] as String), + date: const TimestampConverter().fromJson(json['date'] as String), dateUtc: const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), timezone: json['timezone'] as String?, @@ -50,7 +50,7 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => { 'id': instance.id, 'userId': instance.userId, - 'endDate': const TimestampConverter().toJson(instance.endDate), + 'date': const TimestampConverter().toJson(instance.date), 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, 'distance': instance.distance, @@ -67,7 +67,7 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, 'intervals': instance.intervals.map((e) => e.toJson()).toList(), 'splits': instance.splits.map((e) => e.toJson()).toList(), - 'heartRate': instance.heartRate.toJson(), + 'heartRate': instance.heartRate?.toJson(), }; const _$C2ResultTypeEnumMap = { @@ -128,11 +128,12 @@ Map _$$C2HeartRateImplToJson(_$C2HeartRateImpl instance) => _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => _$C2IntervalsImpl( type: json['type'] as String? ?? "time", - time: json['time'] as int? ?? 0, - calories: json['calories'] as int? ?? 0, + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + restTime: + const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), + distance: (json['distance'] as num?)?.toDouble() ?? 0, + caloriesTotal: json['caloriesTotal'] as int? ?? 0, strokeRate: json['strokeRate'] as int? ?? 0, - machine: json['machine'] as String? ?? "rower", - restDistance: json['restDistance'] as int? ?? 0, heartRate: json['heartRate'] == null ? null : C2HeartRate.fromJson(json['heartRate'] as Map), @@ -141,11 +142,11 @@ _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => { 'type': instance.type, - 'time': instance.time, - 'calories': instance.calories, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'distance': instance.distance, + 'caloriesTotal': instance.caloriesTotal, 'strokeRate': instance.strokeRate, - 'machine': instance.machine, - 'restDistance': instance.restDistance, 'heartRate': instance.heartRate?.toJson(), }; @@ -153,7 +154,7 @@ _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => _$C2ResultsImpl( id: json['id'] as int? ?? 0, userId: json['userId'] as int? ?? 0, - endDate: const TimestampConverter().fromJson(json['endDate'] as String), + date: const TimestampConverter().fromJson(json['date'] as String), dateUtc: const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), timezone: json['timezone'] as String?, @@ -161,17 +162,17 @@ _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: $enumDecodeNullable( - _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? - C2APIWorkoutType.JustRow, + workoutType: + $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? + C2APIWorkoutType.JustRow, source: json['source'] as String? ?? "c2logbook dart", weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weightClass']) ?? C2WeightClass.heavyweight, - strokeRate: json['strokeRate'] as int?, + strokeRate: json['strokeRate'] as int? ?? null, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, - comments: json['comments'] as String?, + comments: json['comments'] as String? ?? null, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, ); @@ -180,15 +181,15 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => { 'id': instance.id, 'userId': instance.userId, - 'endDate': const TimestampConverter().toJson(instance.endDate), + 'date': const TimestampConverter().toJson(instance.date), 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, - 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, + 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, 'strokeRate': instance.strokeRate, 'verified': instance.verified, 'ranked': instance.ranked, @@ -199,11 +200,10 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( type: json['type'] as String? ?? "time", - time: json['time'] as int? ?? 0, - calories: json['calories'] as int? ?? 0, + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + distance: (json['distance'] as num?)?.toDouble() ?? 0, + caloriesTotal: json['caloriesTotal'] as int? ?? 0, strokeRate: json['strokeRate'] as int? ?? 0, - machine: json['machine'] as String? ?? "rower", - restDistance: json['restDistance'] as int? ?? "0", heartRate: json['heartRate'] == null ? null : C2HeartRate.fromJson(json['heartRate'] as Map), @@ -212,11 +212,10 @@ _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => { 'type': instance.type, - 'time': instance.time, - 'calories': instance.calories, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'distance': instance.distance, + 'caloriesTotal': instance.caloriesTotal, 'strokeRate': instance.strokeRate, - 'machine': instance.machine, - 'restDistance': instance.restDistance, 'heartRate': instance.heartRate?.toJson(), }; From 15942704b6b9a005c35ac17db7ae972525859c45 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:51:10 -0400 Subject: [PATCH 11/25] More tweaking of models --- lib/src/types/c2_full_results.dart | 9 +- lib/src/types/c2_intervals.dart | 2 +- lib/src/types/c2_splits.dart | 2 +- lib/src/types/c2_workout.dart | 20 ++ lib/src/types/index.dart | 1 + lib/src/types/index.freezed.dart | 501 +++++++++++++++++++++-------- lib/src/types/index.g.dart | 57 ++-- test/c2logbook_test.dart | 14 +- 8 files changed, 440 insertions(+), 166 deletions(-) create mode 100644 lib/src/types/c2_workout.dart diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index bfc9cd7..240c6da 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -17,25 +17,24 @@ class C2FullResults with _$C2FullResults { @Default(0) int id, @Default(0) int userId, @TimestampConverter() required DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, + @TimestampOrNullConverter() DateTime? dateUtc, @Default(0) int distance, @Default(C2ResultType.rower) C2ResultType type, @DecimalIntConverter.tenths() required double time, - @DecimalIntConverter.tenths() required double restTime, @Default(C2APIWorkoutType.JustRow) C2APIWorkoutType workoutType, @Default("c2logbook dart") String source, @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - int? strokeRate, @Default(false) bool verified, @Default(false) bool ranked, String? comments, @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - @Default([]) List intervals, - @Default([]) List splits, + @DecimalIntConverter.tenths() required double restTime, + int? strokeRate, @Default(null) C2HeartRate? heartRate, + @Default([]) C2Workout? workout, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart index c70c5f4..0e61ed1 100644 --- a/lib/src/types/c2_intervals.dart +++ b/lib/src/types/c2_intervals.dart @@ -11,7 +11,7 @@ class C2Intervals with _$C2Intervals { @Default("time") String type, @DecimalIntConverter.tenths() required double time, @DecimalIntConverter.tenths() required double restTime, - @Default(0) double distance, + @Default(0.0) double distance, @Default(0) int caloriesTotal, @Default(0) int strokeRate, @Default(null) C2HeartRate? heartRate, diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index 544e83a..f1728a3 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -10,7 +10,7 @@ class C2Splits with _$C2Splits { factory C2Splits({ @Default("time") String type, @DecimalIntConverter.tenths() required double time, - @Default(0) double distance, + @Default(0.0) double distance, @Default(0) int caloriesTotal, @Default(0) int strokeRate, @Default(null) C2HeartRate? heartRate, diff --git a/lib/src/types/c2_workout.dart b/lib/src/types/c2_workout.dart new file mode 100644 index 0000000..16820d9 --- /dev/null +++ b/lib/src/types/c2_workout.dart @@ -0,0 +1,20 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Workout with _$C2Workout { + + C2Workout._(); + + factory C2Workout({ + @Default([]) List? intervals, + @Default([]) List? splits, + @Default(null) int realTime, + @Default(0.0) double realDistance, + @DecimalIntConverter.tenths() required double restTime, + }) = _C2Workout; + + factory C2Workout.fromJson(Map json) => + _$C2WorkoutFromJson(Map.from(json)); +} diff --git a/lib/src/types/index.dart b/lib/src/types/index.dart index e681870..f9f9622 100644 --- a/lib/src/types/index.dart +++ b/lib/src/types/index.dart @@ -11,5 +11,6 @@ part 'c2_type_extensions.dart'; part 'c2_types.dart'; part 'c2_user.dart'; part 'c2_webhook_result.dart'; +part 'c2_workout.dart'; part 'index.freezed.dart'; part 'index.g.dart'; \ No newline at end of file diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 5629021..5dc43df 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -24,26 +24,25 @@ mixin _$C2FullResults { int get userId => throw _privateConstructorUsedError; @TimestampConverter() DateTime get date => throw _privateConstructorUsedError; + String? get timezone => throw _privateConstructorUsedError; @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; - String? get timezone => throw _privateConstructorUsedError; int get distance => throw _privateConstructorUsedError; C2ResultType get type => throw _privateConstructorUsedError; @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; - @DecimalIntConverter.tenths() - double get restTime => throw _privateConstructorUsedError; C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; String get source => throw _privateConstructorUsedError; C2WeightClass get weightClass => throw _privateConstructorUsedError; - int? get strokeRate => throw _privateConstructorUsedError; bool get verified => throw _privateConstructorUsedError; bool get ranked => throw _privateConstructorUsedError; String? get comments => throw _privateConstructorUsedError; C2PrivacyLevel get privacy => throw _privateConstructorUsedError; - List get intervals => throw _privateConstructorUsedError; - List get splits => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get restTime => throw _privateConstructorUsedError; + int? get strokeRate => throw _privateConstructorUsedError; C2HeartRate? get heartRate => throw _privateConstructorUsedError; + C2Workout? get workout => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -61,25 +60,25 @@ abstract class $C2FullResultsCopyWith<$Res> { {int id, int userId, @TimestampConverter() DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, + @TimestampOrNullConverter() DateTime? dateUtc, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @DecimalIntConverter.tenths() double restTime, C2APIWorkoutType workoutType, String source, C2WeightClass weightClass, - int? strokeRate, bool verified, bool ranked, String? comments, C2PrivacyLevel privacy, - List intervals, - List splits, - C2HeartRate? heartRate}); + @DecimalIntConverter.tenths() double restTime, + int? strokeRate, + C2HeartRate? heartRate, + C2Workout? workout}); $C2HeartRateCopyWith<$Res>? get heartRate; + $C2WorkoutCopyWith<$Res>? get workout; } /// @nodoc @@ -98,23 +97,22 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? id = null, Object? userId = null, Object? date = null, - Object? dateUtc = freezed, Object? timezone = freezed, + Object? dateUtc = freezed, Object? distance = null, Object? type = null, Object? time = null, - Object? restTime = null, Object? workoutType = null, Object? source = null, Object? weightClass = null, - Object? strokeRate = freezed, Object? verified = null, Object? ranked = null, Object? comments = freezed, Object? privacy = null, - Object? intervals = null, - Object? splits = null, + Object? restTime = null, + Object? strokeRate = freezed, Object? heartRate = freezed, + Object? workout = freezed, }) { return _then(_value.copyWith( id: null == id @@ -129,14 +127,14 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.date : date // ignore: cast_nullable_to_non_nullable as DateTime, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, timezone: freezed == timezone ? _value.timezone : timezone // ignore: cast_nullable_to_non_nullable as String?, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, distance: null == distance ? _value.distance : distance // ignore: cast_nullable_to_non_nullable @@ -149,10 +147,6 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.time : time // ignore: cast_nullable_to_non_nullable as double, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, workoutType: null == workoutType ? _value.workoutType : workoutType // ignore: cast_nullable_to_non_nullable @@ -165,10 +159,6 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.weightClass : weightClass // ignore: cast_nullable_to_non_nullable as C2WeightClass, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, verified: null == verified ? _value.verified : verified // ignore: cast_nullable_to_non_nullable @@ -185,18 +175,22 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, - intervals: null == intervals - ? _value.intervals - : intervals // ignore: cast_nullable_to_non_nullable - as List, - splits: null == splits - ? _value.splits - : splits // ignore: cast_nullable_to_non_nullable - as List, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable as C2HeartRate?, + workout: freezed == workout + ? _value.workout + : workout // ignore: cast_nullable_to_non_nullable + as C2Workout?, ) as $Val); } @@ -211,6 +205,18 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> return _then(_value.copyWith(heartRate: value) as $Val); }); } + + @override + @pragma('vm:prefer-inline') + $C2WorkoutCopyWith<$Res>? get workout { + if (_value.workout == null) { + return null; + } + + return $C2WorkoutCopyWith<$Res>(_value.workout!, (value) { + return _then(_value.copyWith(workout: value) as $Val); + }); + } } /// @nodoc @@ -225,26 +231,27 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> {int id, int userId, @TimestampConverter() DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, String? timezone, + @TimestampOrNullConverter() DateTime? dateUtc, int distance, C2ResultType type, @DecimalIntConverter.tenths() double time, - @DecimalIntConverter.tenths() double restTime, C2APIWorkoutType workoutType, String source, C2WeightClass weightClass, - int? strokeRate, bool verified, bool ranked, String? comments, C2PrivacyLevel privacy, - List intervals, - List splits, - C2HeartRate? heartRate}); + @DecimalIntConverter.tenths() double restTime, + int? strokeRate, + C2HeartRate? heartRate, + C2Workout? workout}); @override $C2HeartRateCopyWith<$Res>? get heartRate; + @override + $C2WorkoutCopyWith<$Res>? get workout; } /// @nodoc @@ -261,23 +268,22 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? id = null, Object? userId = null, Object? date = null, - Object? dateUtc = freezed, Object? timezone = freezed, + Object? dateUtc = freezed, Object? distance = null, Object? type = null, Object? time = null, - Object? restTime = null, Object? workoutType = null, Object? source = null, Object? weightClass = null, - Object? strokeRate = freezed, Object? verified = null, Object? ranked = null, Object? comments = freezed, Object? privacy = null, - Object? intervals = null, - Object? splits = null, + Object? restTime = null, + Object? strokeRate = freezed, Object? heartRate = freezed, + Object? workout = freezed, }) { return _then(_$C2FullResultsImpl( id: null == id @@ -292,14 +298,14 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.date : date // ignore: cast_nullable_to_non_nullable as DateTime, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, timezone: freezed == timezone ? _value.timezone : timezone // ignore: cast_nullable_to_non_nullable as String?, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, distance: null == distance ? _value.distance : distance // ignore: cast_nullable_to_non_nullable @@ -312,10 +318,6 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.time : time // ignore: cast_nullable_to_non_nullable as double, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, workoutType: null == workoutType ? _value.workoutType : workoutType // ignore: cast_nullable_to_non_nullable @@ -328,10 +330,6 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.weightClass : weightClass // ignore: cast_nullable_to_non_nullable as C2WeightClass, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, verified: null == verified ? _value.verified : verified // ignore: cast_nullable_to_non_nullable @@ -348,18 +346,22 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, - intervals: null == intervals - ? _value._intervals - : intervals // ignore: cast_nullable_to_non_nullable - as List, - splits: null == splits - ? _value._splits - : splits // ignore: cast_nullable_to_non_nullable - as List, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, heartRate: freezed == heartRate ? _value.heartRate : heartRate // ignore: cast_nullable_to_non_nullable as C2HeartRate?, + workout: freezed == workout + ? _value.workout + : workout // ignore: cast_nullable_to_non_nullable + as C2Workout?, )); } } @@ -371,26 +373,23 @@ class _$C2FullResultsImpl extends _C2FullResults { {this.id = 0, this.userId = 0, @TimestampConverter() required this.date, - @TimestampOrNullConverter() this.dateUtc, this.timezone, + @TimestampOrNullConverter() this.dateUtc, this.distance = 0, this.type = C2ResultType.rower, @DecimalIntConverter.tenths() required this.time, - @DecimalIntConverter.tenths() required this.restTime, this.workoutType = C2APIWorkoutType.JustRow, this.source = "c2logbook dart", this.weightClass = C2WeightClass.heavyweight, - this.strokeRate, this.verified = false, this.ranked = false, this.comments, this.privacy = C2PrivacyLevel.private, - final List intervals = const [], - final List splits = const [], - this.heartRate = null}) - : _intervals = intervals, - _splits = splits, - super._(); + @DecimalIntConverter.tenths() required this.restTime, + this.strokeRate, + this.heartRate = null, + this.workout = const []}) + : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => _$$C2FullResultsImplFromJson(json); @@ -405,11 +404,11 @@ class _$C2FullResultsImpl extends _C2FullResults { @TimestampConverter() final DateTime date; @override + final String? timezone; + @override @TimestampOrNullConverter() final DateTime? dateUtc; @override - final String? timezone; - @override @JsonKey() final int distance; @override @@ -419,9 +418,6 @@ class _$C2FullResultsImpl extends _C2FullResults { @DecimalIntConverter.tenths() final double time; @override - @DecimalIntConverter.tenths() - final double restTime; - @override @JsonKey() final C2APIWorkoutType workoutType; @override @@ -431,8 +427,6 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey() final C2WeightClass weightClass; @override - final int? strokeRate; - @override @JsonKey() final bool verified; @override @@ -443,31 +437,21 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey() final C2PrivacyLevel privacy; - final List _intervals; @override - @JsonKey() - List get intervals { - if (_intervals is EqualUnmodifiableListView) return _intervals; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_intervals); - } - - final List _splits; + @DecimalIntConverter.tenths() + final double restTime; @override - @JsonKey() - List get splits { - if (_splits is EqualUnmodifiableListView) return _splits; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_splits); - } - + final int? strokeRate; @override @JsonKey() final C2HeartRate? heartRate; + @override + @JsonKey() + final C2Workout? workout; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, date: $date, dateUtc: $dateUtc, timezone: $timezone, distance: $distance, type: $type, time: $time, restTime: $restTime, workoutType: $workoutType, source: $source, weightClass: $weightClass, strokeRate: $strokeRate, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, intervals: $intervals, splits: $splits, heartRate: $heartRate)'; + return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, restTime: $restTime, strokeRate: $strokeRate, heartRate: $heartRate, workout: $workout)'; } @override @@ -478,33 +462,31 @@ class _$C2FullResultsImpl extends _C2FullResults { (identical(other.id, id) || other.id == id) && (identical(other.userId, userId) || other.userId == userId) && (identical(other.date, date) || other.date == date) && - (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && (identical(other.timezone, timezone) || other.timezone == timezone) && + (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && (identical(other.distance, distance) || other.distance == distance) && (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && - (identical(other.restTime, restTime) || - other.restTime == restTime) && (identical(other.workoutType, workoutType) || other.workoutType == workoutType) && (identical(other.source, source) || other.source == source) && (identical(other.weightClass, weightClass) || other.weightClass == weightClass) && - (identical(other.strokeRate, strokeRate) || - other.strokeRate == strokeRate) && (identical(other.verified, verified) || other.verified == verified) && (identical(other.ranked, ranked) || other.ranked == ranked) && (identical(other.comments, comments) || other.comments == comments) && (identical(other.privacy, privacy) || other.privacy == privacy) && - const DeepCollectionEquality() - .equals(other._intervals, _intervals) && - const DeepCollectionEquality().equals(other._splits, _splits) && + (identical(other.restTime, restTime) || + other.restTime == restTime) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && (identical(other.heartRate, heartRate) || - other.heartRate == heartRate)); + other.heartRate == heartRate) && + (identical(other.workout, workout) || other.workout == workout)); } @JsonKey(ignore: true) @@ -514,23 +496,22 @@ class _$C2FullResultsImpl extends _C2FullResults { id, userId, date, - dateUtc, timezone, + dateUtc, distance, type, time, - restTime, workoutType, source, weightClass, - strokeRate, verified, ranked, comments, privacy, - const DeepCollectionEquality().hash(_intervals), - const DeepCollectionEquality().hash(_splits), - heartRate + restTime, + strokeRate, + heartRate, + workout ]); @JsonKey(ignore: true) @@ -552,23 +533,22 @@ abstract class _C2FullResults extends C2FullResults { {final int id, final int userId, @TimestampConverter() required final DateTime date, - @TimestampOrNullConverter() final DateTime? dateUtc, final String? timezone, + @TimestampOrNullConverter() final DateTime? dateUtc, final int distance, final C2ResultType type, @DecimalIntConverter.tenths() required final double time, - @DecimalIntConverter.tenths() required final double restTime, final C2APIWorkoutType workoutType, final String source, final C2WeightClass weightClass, - final int? strokeRate, final bool verified, final bool ranked, final String? comments, final C2PrivacyLevel privacy, - final List intervals, - final List splits, - final C2HeartRate? heartRate}) = _$C2FullResultsImpl; + @DecimalIntConverter.tenths() required final double restTime, + final int? strokeRate, + final C2HeartRate? heartRate, + final C2Workout? workout}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -582,11 +562,11 @@ abstract class _C2FullResults extends C2FullResults { @TimestampConverter() DateTime get date; @override + String? get timezone; + @override @TimestampOrNullConverter() DateTime? get dateUtc; @override - String? get timezone; - @override int get distance; @override C2ResultType get type; @@ -594,17 +574,12 @@ abstract class _C2FullResults extends C2FullResults { @DecimalIntConverter.tenths() double get time; @override - @DecimalIntConverter.tenths() - double get restTime; - @override C2APIWorkoutType get workoutType; @override String get source; @override C2WeightClass get weightClass; @override - int? get strokeRate; - @override bool get verified; @override bool get ranked; @@ -613,12 +588,15 @@ abstract class _C2FullResults extends C2FullResults { @override C2PrivacyLevel get privacy; @override - List get intervals; + @DecimalIntConverter.tenths() + double get restTime; @override - List get splits; + int? get strokeRate; @override C2HeartRate? get heartRate; @override + C2Workout? get workout; + @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; @@ -1005,7 +983,7 @@ class _$C2IntervalsImpl extends _C2Intervals { {this.type = "time", @DecimalIntConverter.tenths() required this.time, @DecimalIntConverter.tenths() required this.restTime, - this.distance = 0, + this.distance = 0.0, this.caloriesTotal = 0, this.strokeRate = 0, this.heartRate = null}) @@ -1771,7 +1749,7 @@ class _$C2SplitsImpl extends _C2Splits { _$C2SplitsImpl( {this.type = "time", @DecimalIntConverter.tenths() required this.time, - this.distance = 0, + this.distance = 0.0, this.caloriesTotal = 0, this.strokeRate = 0, this.heartRate = null}) @@ -2331,3 +2309,260 @@ abstract class _C2User implements C2User { _$$C2UserImplCopyWith<_$C2UserImpl> get copyWith => throw _privateConstructorUsedError; } + +C2Workout _$C2WorkoutFromJson(Map json) { + return _C2Workout.fromJson(json); +} + +/// @nodoc +mixin _$C2Workout { + List? get intervals => throw _privateConstructorUsedError; + List? get splits => throw _privateConstructorUsedError; + int get realTime => throw _privateConstructorUsedError; + double get realDistance => throw _privateConstructorUsedError; + @DecimalIntConverter.tenths() + double get restTime => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $C2WorkoutCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $C2WorkoutCopyWith<$Res> { + factory $C2WorkoutCopyWith(C2Workout value, $Res Function(C2Workout) then) = + _$C2WorkoutCopyWithImpl<$Res, C2Workout>; + @useResult + $Res call( + {List? intervals, + List? splits, + int realTime, + double realDistance, + @DecimalIntConverter.tenths() double restTime}); +} + +/// @nodoc +class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> + implements $C2WorkoutCopyWith<$Res> { + _$C2WorkoutCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? intervals = freezed, + Object? splits = freezed, + Object? realTime = null, + Object? realDistance = null, + Object? restTime = null, + }) { + return _then(_value.copyWith( + intervals: freezed == intervals + ? _value.intervals + : intervals // ignore: cast_nullable_to_non_nullable + as List?, + splits: freezed == splits + ? _value.splits + : splits // ignore: cast_nullable_to_non_nullable + as List?, + realTime: null == realTime + ? _value.realTime + : realTime // ignore: cast_nullable_to_non_nullable + as int, + realDistance: null == realDistance + ? _value.realDistance + : realDistance // ignore: cast_nullable_to_non_nullable + as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$C2WorkoutImplCopyWith<$Res> + implements $C2WorkoutCopyWith<$Res> { + factory _$$C2WorkoutImplCopyWith( + _$C2WorkoutImpl value, $Res Function(_$C2WorkoutImpl) then) = + __$$C2WorkoutImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {List? intervals, + List? splits, + int realTime, + double realDistance, + @DecimalIntConverter.tenths() double restTime}); +} + +/// @nodoc +class __$$C2WorkoutImplCopyWithImpl<$Res> + extends _$C2WorkoutCopyWithImpl<$Res, _$C2WorkoutImpl> + implements _$$C2WorkoutImplCopyWith<$Res> { + __$$C2WorkoutImplCopyWithImpl( + _$C2WorkoutImpl _value, $Res Function(_$C2WorkoutImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? intervals = freezed, + Object? splits = freezed, + Object? realTime = null, + Object? realDistance = null, + Object? restTime = null, + }) { + return _then(_$C2WorkoutImpl( + intervals: freezed == intervals + ? _value._intervals + : intervals // ignore: cast_nullable_to_non_nullable + as List?, + splits: freezed == splits + ? _value._splits + : splits // ignore: cast_nullable_to_non_nullable + as List?, + realTime: null == realTime + ? _value.realTime + : realTime // ignore: cast_nullable_to_non_nullable + as int, + realDistance: null == realDistance + ? _value.realDistance + : realDistance // ignore: cast_nullable_to_non_nullable + as double, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2WorkoutImpl extends _C2Workout { + _$C2WorkoutImpl( + {final List? intervals = const [], + final List? splits = const [], + this.realTime = null, + this.realDistance = 0.0, + @DecimalIntConverter.tenths() required this.restTime}) + : _intervals = intervals, + _splits = splits, + super._(); + + factory _$C2WorkoutImpl.fromJson(Map json) => + _$$C2WorkoutImplFromJson(json); + + final List? _intervals; + @override + @JsonKey() + List? get intervals { + final value = _intervals; + if (value == null) return null; + if (_intervals is EqualUnmodifiableListView) return _intervals; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + final List? _splits; + @override + @JsonKey() + List? get splits { + final value = _splits; + if (value == null) return null; + if (_splits is EqualUnmodifiableListView) return _splits; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + + @override + @JsonKey() + final int realTime; + @override + @JsonKey() + final double realDistance; + @override + @DecimalIntConverter.tenths() + final double restTime; + + @override + String toString() { + return 'C2Workout(intervals: $intervals, splits: $splits, realTime: $realTime, realDistance: $realDistance, restTime: $restTime)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$C2WorkoutImpl && + const DeepCollectionEquality() + .equals(other._intervals, _intervals) && + const DeepCollectionEquality().equals(other._splits, _splits) && + (identical(other.realTime, realTime) || + other.realTime == realTime) && + (identical(other.realDistance, realDistance) || + other.realDistance == realDistance) && + (identical(other.restTime, restTime) || + other.restTime == restTime)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_intervals), + const DeepCollectionEquality().hash(_splits), + realTime, + realDistance, + restTime); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$C2WorkoutImplCopyWith<_$C2WorkoutImpl> get copyWith => + __$$C2WorkoutImplCopyWithImpl<_$C2WorkoutImpl>(this, _$identity); + + @override + Map toJson() { + return _$$C2WorkoutImplToJson( + this, + ); + } +} + +abstract class _C2Workout extends C2Workout { + factory _C2Workout( + {final List? intervals, + final List? splits, + final int realTime, + final double realDistance, + @DecimalIntConverter.tenths() required final double restTime}) = + _$C2WorkoutImpl; + _C2Workout._() : super._(); + + factory _C2Workout.fromJson(Map json) = + _$C2WorkoutImpl.fromJson; + + @override + List? get intervals; + @override + List? get splits; + @override + int get realTime; + @override + double get realDistance; + @override + @DecimalIntConverter.tenths() + double get restTime; + @override + @JsonKey(ignore: true) + _$$C2WorkoutImplCopyWith<_$C2WorkoutImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 825af9c..939e424 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -11,15 +11,13 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => id: json['id'] as int? ?? 0, userId: json['userId'] as int? ?? 0, date: const TimestampConverter().fromJson(json['date'] as String), + timezone: json['timezone'] as String?, dateUtc: const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), - timezone: json['timezone'] as String?, distance: json['distance'] as int? ?? 0, type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - restTime: - const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), workoutType: $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? C2APIWorkoutType.JustRow, @@ -27,23 +25,20 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => weightClass: $enumDecodeNullable(_$C2WeightClassEnumMap, json['weightClass']) ?? C2WeightClass.heavyweight, - strokeRate: json['strokeRate'] as int?, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, comments: json['comments'] as String?, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, - intervals: (json['intervals'] as List?) - ?.map((e) => C2Intervals.fromJson(e as Map)) - .toList() ?? - const [], - splits: (json['splits'] as List?) - ?.map((e) => C2Splits.fromJson(e as Map)) - .toList() ?? - const [], + restTime: + const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), + strokeRate: json['strokeRate'] as int?, heartRate: json['heartRate'] == null ? null : C2HeartRate.fromJson(json['heartRate'] as Map), + workout: json['workout'] == null + ? const [] + : C2Workout.fromJson(json['workout'] as Map), ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => @@ -51,23 +46,22 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'id': instance.id, 'userId': instance.userId, 'date': const TimestampConverter().toJson(instance.date), - 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, + 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, - 'strokeRate': instance.strokeRate, 'verified': instance.verified, 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - 'intervals': instance.intervals.map((e) => e.toJson()).toList(), - 'splits': instance.splits.map((e) => e.toJson()).toList(), + 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'strokeRate': instance.strokeRate, 'heartRate': instance.heartRate?.toJson(), + 'workout': instance.workout?.toJson(), }; const _$C2ResultTypeEnumMap = { @@ -131,7 +125,7 @@ _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), restTime: const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), - distance: (json['distance'] as num?)?.toDouble() ?? 0, + distance: (json['distance'] as num?)?.toDouble() ?? 0.0, caloriesTotal: json['caloriesTotal'] as int? ?? 0, strokeRate: json['strokeRate'] as int? ?? 0, heartRate: json['heartRate'] == null @@ -201,7 +195,7 @@ _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( type: json['type'] as String? ?? "time", time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - distance: (json['distance'] as num?)?.toDouble() ?? 0, + distance: (json['distance'] as num?)?.toDouble() ?? 0.0, caloriesTotal: json['caloriesTotal'] as int? ?? 0, strokeRate: json['strokeRate'] as int? ?? 0, heartRate: json['heartRate'] == null @@ -259,3 +253,28 @@ Map _$$C2UserImplToJson(_$C2UserImpl instance) => 'roles': instance.roles, 'logbookPrivacy': _$C2PrivacyLevelEnumMap[instance.logbookPrivacy]!, }; + +_$C2WorkoutImpl _$$C2WorkoutImplFromJson(Map json) => + _$C2WorkoutImpl( + intervals: (json['intervals'] as List?) + ?.map((e) => C2Intervals.fromJson(e as Map)) + .toList() ?? + const [], + splits: (json['splits'] as List?) + ?.map((e) => C2Splits.fromJson(e as Map)) + .toList() ?? + const [], + realTime: json['realTime'] as int? ?? null, + realDistance: (json['realDistance'] as num?)?.toDouble() ?? 0.0, + restTime: + const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), + ); + +Map _$$C2WorkoutImplToJson(_$C2WorkoutImpl instance) => + { + 'intervals': instance.intervals?.map((e) => e.toJson()).toList(), + 'splits': instance.splits?.map((e) => e.toJson()).toList(), + 'realTime': instance.realTime, + 'realDistance': instance.realDistance, + 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), + }; diff --git a/test/c2logbook_test.dart b/test/c2logbook_test.dart index e6cae54..5238191 100644 --- a/test/c2logbook_test.dart +++ b/test/c2logbook_test.dart @@ -23,7 +23,7 @@ void main() { final C2Results testResultsMin = C2Results( id: 3, userId: 1, - endDate: DateTime.parse("2013-06-21 00:00:00"), + date: DateTime.parse("2013-06-21 00:00:00"), distance: 23000, type: C2ResultType.rower, time: 15235.0, @@ -36,7 +36,7 @@ void main() { final C2Results testResultsMax = C2Results( id: 3, userId: 1, - endDate: DateTime.parse("2013-06-21 00:00:00"), + date: DateTime.parse("2013-06-21 00:00:00"), dateUtc: DateTime.parse("2013-06-21 05:00:00Z"), timezone: "US/Eastern", distance: 23000, @@ -52,7 +52,7 @@ void main() { group('Parsing Tests', () { test('Test Parsing minimal Result JSON', () { - final jsonData = json.decode("""{ + final dynamic jsonData = json.decode("""{ "id": 3, "user_id": 1, "date": "2013-06-21 00:00:00", @@ -71,7 +71,7 @@ void main() { }); test('Test Parsing maximal Result JSON', () { - final jsonData = json.decode("""{ + final dynamic jsonData = json.decode("""{ "id": 3, "user_id": 1, "date": "2013-06-21 00:00:00", @@ -94,7 +94,7 @@ void main() { }); test('Test Parsing User JSON', () { - final jsonData = json.decode("""{ + final dynamic jsonData = json.decode("""{ "id": 1, "username": "David Hart", "first_name": "David", @@ -115,7 +115,7 @@ void main() { }); test("Test parsing webhook JSON (minimal)", () { - final webhookJson = json.decode("""{ + final dynamic webhookJson = json.decode("""{ "data": { "type": "result-added", "result": @@ -166,7 +166,7 @@ void main() { C2Results( id: 3, userId: 1, - endDate: DateTime.parse("2013-06-21 00:00:00"), + date: DateTime.parse("2013-06-21 00:00:00"), dateUtc: DateTime.parse("2013-06-21 05:00:00Z"), timezone: "US/Eastern", distance: 23000, From f2ecf3c5b59ad16e0ecefef97afec92f0ac7ad3b Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:54:24 -0400 Subject: [PATCH 12/25] More tweaking of models --- lib/src/types/c2_full_results.dart | 2 +- lib/src/types/index.freezed.dart | 2 +- lib/src/types/index.g.dart | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 240c6da..78a3b1f 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -34,7 +34,7 @@ class C2FullResults with _$C2FullResults { @DecimalIntConverter.tenths() required double restTime, int? strokeRate, @Default(null) C2HeartRate? heartRate, - @Default([]) C2Workout? workout, + @Default(null) C2Workout? workout, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 5dc43df..68ca309 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -388,7 +388,7 @@ class _$C2FullResultsImpl extends _C2FullResults { @DecimalIntConverter.tenths() required this.restTime, this.strokeRate, this.heartRate = null, - this.workout = const []}) + this.workout = null}) : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 939e424..9503758 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -37,7 +37,7 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => ? null : C2HeartRate.fromJson(json['heartRate'] as Map), workout: json['workout'] == null - ? const [] + ? null : C2Workout.fromJson(json['workout'] as Map), ); From 8177406b0259a890941603995b6a0f27a487e937 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 12:59:18 -0400 Subject: [PATCH 13/25] More tweaking of models --- lib/src/types/c2_workout.dart | 2 +- lib/src/types/index.freezed.dart | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/src/types/c2_workout.dart b/lib/src/types/c2_workout.dart index 16820d9..39c50c3 100644 --- a/lib/src/types/c2_workout.dart +++ b/lib/src/types/c2_workout.dart @@ -10,7 +10,7 @@ class C2Workout with _$C2Workout { factory C2Workout({ @Default([]) List? intervals, @Default([]) List? splits, - @Default(null) int realTime, + @Default(null) int? realTime, @Default(0.0) double realDistance, @DecimalIntConverter.tenths() required double restTime, }) = _C2Workout; diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 68ca309..6f3d202 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -2318,7 +2318,7 @@ C2Workout _$C2WorkoutFromJson(Map json) { mixin _$C2Workout { List? get intervals => throw _privateConstructorUsedError; List? get splits => throw _privateConstructorUsedError; - int get realTime => throw _privateConstructorUsedError; + int? get realTime => throw _privateConstructorUsedError; double get realDistance => throw _privateConstructorUsedError; @DecimalIntConverter.tenths() double get restTime => throw _privateConstructorUsedError; @@ -2337,7 +2337,7 @@ abstract class $C2WorkoutCopyWith<$Res> { $Res call( {List? intervals, List? splits, - int realTime, + int? realTime, double realDistance, @DecimalIntConverter.tenths() double restTime}); } @@ -2357,7 +2357,7 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> $Res call({ Object? intervals = freezed, Object? splits = freezed, - Object? realTime = null, + Object? realTime = freezed, Object? realDistance = null, Object? restTime = null, }) { @@ -2370,10 +2370,10 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> ? _value.splits : splits // ignore: cast_nullable_to_non_nullable as List?, - realTime: null == realTime + realTime: freezed == realTime ? _value.realTime : realTime // ignore: cast_nullable_to_non_nullable - as int, + as int?, realDistance: null == realDistance ? _value.realDistance : realDistance // ignore: cast_nullable_to_non_nullable @@ -2397,7 +2397,7 @@ abstract class _$$C2WorkoutImplCopyWith<$Res> $Res call( {List? intervals, List? splits, - int realTime, + int? realTime, double realDistance, @DecimalIntConverter.tenths() double restTime}); } @@ -2415,7 +2415,7 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> $Res call({ Object? intervals = freezed, Object? splits = freezed, - Object? realTime = null, + Object? realTime = freezed, Object? realDistance = null, Object? restTime = null, }) { @@ -2428,10 +2428,10 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> ? _value._splits : splits // ignore: cast_nullable_to_non_nullable as List?, - realTime: null == realTime + realTime: freezed == realTime ? _value.realTime : realTime // ignore: cast_nullable_to_non_nullable - as int, + as int?, realDistance: null == realDistance ? _value.realDistance : realDistance // ignore: cast_nullable_to_non_nullable @@ -2484,7 +2484,7 @@ class _$C2WorkoutImpl extends _C2Workout { @override @JsonKey() - final int realTime; + final int? realTime; @override @JsonKey() final double realDistance; @@ -2541,7 +2541,7 @@ abstract class _C2Workout extends C2Workout { factory _C2Workout( {final List? intervals, final List? splits, - final int realTime, + final int? realTime, final double realDistance, @DecimalIntConverter.tenths() required final double restTime}) = _$C2WorkoutImpl; @@ -2555,7 +2555,7 @@ abstract class _C2Workout extends C2Workout { @override List? get splits; @override - int get realTime; + int? get realTime; @override double get realDistance; @override From 4aa321cbb83c8b47b9b3f9920b46a37e1c578bfb Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:20:05 -0400 Subject: [PATCH 14/25] Re-added json keys --- lib/src/types/c2_full_results.dart | 36 +-- lib/src/types/c2_heart_rate.dart | 8 +- lib/src/types/c2_intervals.dart | 14 +- lib/src/types/c2_splits.dart | 12 +- lib/src/types/c2_user.dart | 2 +- lib/src/types/index.freezed.dart | 423 ++++++++++++++++++----------- lib/src/types/index.g.dart | 71 ++--- 7 files changed, 341 insertions(+), 225 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 78a3b1f..a751561 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -14,27 +14,27 @@ class C2FullResults with _$C2FullResults { C2FullResults._(); factory C2FullResults({ - @Default(0) int id, - @Default(0) int userId, - @TimestampConverter() required DateTime date, - String? timezone, - @TimestampOrNullConverter() DateTime? dateUtc, - @Default(0) int distance, - @Default(C2ResultType.rower) C2ResultType type, - @DecimalIntConverter.tenths() required double time, - @Default(C2APIWorkoutType.JustRow) + @JsonKey(name: 'id') @Default(0) int id, + @JsonKey(name: 'user_id') @Default(0) int userId, + @JsonKey(name: 'date') @TimestampConverter() required DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') @Default(0) int distance, + @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) C2APIWorkoutType workoutType, - @Default("c2logbook dart") String source, - @Default(C2WeightClass.heavyweight) + @JsonKey(name: 'source') @Default("c2logbook dart") String source, + @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - @Default(false) bool verified, - @Default(false) bool ranked, - String? comments, - @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'verified') @Default(false) bool verified, + @JsonKey(name: 'ranked') @Default(false) bool ranked, + @JsonKey(name: 'comments')String? comments, + @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') @DecimalIntConverter.tenths() required double restTime, int? strokeRate, - @Default(null) C2HeartRate? heartRate, - @Default(null) C2Workout? workout, + @JsonKey(name: 'date_rate') @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'workout') @Default(null) C2Workout? workout, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/c2_heart_rate.dart b/lib/src/types/c2_heart_rate.dart index f7bbae9..461298e 100644 --- a/lib/src/types/c2_heart_rate.dart +++ b/lib/src/types/c2_heart_rate.dart @@ -8,10 +8,10 @@ class C2HeartRate with _$C2HeartRate { C2HeartRate._(); factory C2HeartRate({ - @Default(0) int min, - @Default(0) int average, - @Default(0) int max, - @Default(0) int ending, + @JsonKey(name: 'min') @Default(0) int min, + @JsonKey(name: 'average') @Default(0) int average, + @JsonKey(name: 'max') @Default(0) int max, + @JsonKey(name: 'ending') @Default(0) int ending, }) = _C2HeartRate; factory C2HeartRate.fromJson(Map json) => diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart index 0e61ed1..6858793 100644 --- a/lib/src/types/c2_intervals.dart +++ b/lib/src/types/c2_intervals.dart @@ -8,13 +8,13 @@ class C2Intervals with _$C2Intervals { C2Intervals._(); factory C2Intervals({ - @Default("time") String type, - @DecimalIntConverter.tenths() required double time, - @DecimalIntConverter.tenths() required double restTime, - @Default(0.0) double distance, - @Default(0) int caloriesTotal, - @Default(0) int strokeRate, - @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'id') @Default("type") String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'distance') @Default(0.0) double distance, + @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, + @JsonKey(name: 'stroke_rate') @Default(0) int strokeRate, + @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, }) = _C2Intervals; factory C2Intervals.fromJson(Map json) => diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index f1728a3..d74ac94 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -8,12 +8,12 @@ class C2Splits with _$C2Splits { C2Splits._(); factory C2Splits({ - @Default("time") String type, - @DecimalIntConverter.tenths() required double time, - @Default(0.0) double distance, - @Default(0) int caloriesTotal, - @Default(0) int strokeRate, - @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'type') @Default("time") String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + @JsonKey(name: 'distance') @Default(0.0) double distance, + @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, + @JsonKey(name: 'stroke_rate') @Default(0) int strokeRate, + @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, }) = _C2Splits; factory C2Splits.fromJson(Map json) => diff --git a/lib/src/types/c2_user.dart b/lib/src/types/c2_user.dart index 2e13b0b..7bd7254 100644 --- a/lib/src/types/c2_user.dart +++ b/lib/src/types/c2_user.dart @@ -7,7 +7,7 @@ class C2User with _$C2User { const factory C2User( {@Default(0) int id, @Default('') String username, - @Default('') String firstName, + @Default('') String firstName, @Default('') String lastName, @Default('F') String gender, @Default('1970-01-01') String birthday, diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 6f3d202..c088e83 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -20,28 +20,46 @@ C2FullResults _$C2FullResultsFromJson(Map json) { /// @nodoc mixin _$C2FullResults { + @JsonKey(name: 'id') int get id => throw _privateConstructorUsedError; + @JsonKey(name: 'user_id') int get userId => throw _privateConstructorUsedError; + @JsonKey(name: 'date') @TimestampConverter() DateTime get date => throw _privateConstructorUsedError; + @JsonKey(name: 'timezone') String? get timezone => throw _privateConstructorUsedError; + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; + @JsonKey(name: 'distance') int get distance => throw _privateConstructorUsedError; + @JsonKey(name: 'type') C2ResultType get type => throw _privateConstructorUsedError; + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; + @JsonKey(name: 'workout_type') C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; + @JsonKey(name: 'source') String get source => throw _privateConstructorUsedError; + @JsonKey(name: 'weight_class') C2WeightClass get weightClass => throw _privateConstructorUsedError; + @JsonKey(name: 'verified') bool get verified => throw _privateConstructorUsedError; + @JsonKey(name: 'ranked') bool get ranked => throw _privateConstructorUsedError; + @JsonKey(name: 'comments') String? get comments => throw _privateConstructorUsedError; + @JsonKey(name: 'privacy') C2PrivacyLevel get privacy => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') @DecimalIntConverter.tenths() double get restTime => throw _privateConstructorUsedError; int? get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: 'date_rate') C2HeartRate? get heartRate => throw _privateConstructorUsedError; + @JsonKey(name: 'workout') C2Workout? get workout => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -57,25 +75,27 @@ abstract class $C2FullResultsCopyWith<$Res> { _$C2FullResultsCopyWithImpl<$Res, C2FullResults>; @useResult $Res call( - {int id, - int userId, - @TimestampConverter() DateTime date, - String? timezone, - @TimestampOrNullConverter() DateTime? dateUtc, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - C2APIWorkoutType workoutType, - String source, - C2WeightClass weightClass, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy, - @DecimalIntConverter.tenths() double restTime, + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') + @DecimalIntConverter.tenths() + double restTime, int? strokeRate, - C2HeartRate? heartRate, - C2Workout? workout}); + @JsonKey(name: 'date_rate') C2HeartRate? heartRate, + @JsonKey(name: 'workout') C2Workout? workout}); $C2HeartRateCopyWith<$Res>? get heartRate; $C2WorkoutCopyWith<$Res>? get workout; @@ -228,25 +248,27 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @override @useResult $Res call( - {int id, - int userId, - @TimestampConverter() DateTime date, - String? timezone, - @TimestampOrNullConverter() DateTime? dateUtc, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - C2APIWorkoutType workoutType, - String source, - C2WeightClass weightClass, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy, - @DecimalIntConverter.tenths() double restTime, + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') + @DecimalIntConverter.tenths() + double restTime, int? strokeRate, - C2HeartRate? heartRate, - C2Workout? workout}); + @JsonKey(name: 'date_rate') C2HeartRate? heartRate, + @JsonKey(name: 'workout') C2Workout? workout}); @override $C2HeartRateCopyWith<$Res>? get heartRate; @@ -370,83 +392,93 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2FullResultsImpl extends _C2FullResults { _$C2FullResultsImpl( - {this.id = 0, - this.userId = 0, - @TimestampConverter() required this.date, - this.timezone, - @TimestampOrNullConverter() this.dateUtc, - this.distance = 0, - this.type = C2ResultType.rower, - @DecimalIntConverter.tenths() required this.time, + {@JsonKey(name: 'id') this.id = 0, + @JsonKey(name: 'user_id') this.userId = 0, + @JsonKey(name: 'date') @TimestampConverter() required this.date, + @JsonKey(name: 'timezone') this.timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() this.dateUtc, + @JsonKey(name: 'distance') this.distance = 0, + @JsonKey(name: 'type') this.type = C2ResultType.rower, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: 'workout_type') this.workoutType = C2APIWorkoutType.JustRow, - this.source = "c2logbook dart", + @JsonKey(name: 'source') this.source = "c2logbook dart", + @JsonKey(name: 'weight_class') this.weightClass = C2WeightClass.heavyweight, - this.verified = false, - this.ranked = false, - this.comments, - this.privacy = C2PrivacyLevel.private, - @DecimalIntConverter.tenths() required this.restTime, + @JsonKey(name: 'verified') this.verified = false, + @JsonKey(name: 'ranked') this.ranked = false, + @JsonKey(name: 'comments') this.comments, + @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private, + @JsonKey(name: 'stroke_rate') + @DecimalIntConverter.tenths() + required this.restTime, this.strokeRate, - this.heartRate = null, - this.workout = null}) + @JsonKey(name: 'date_rate') this.heartRate = null, + @JsonKey(name: 'workout') this.workout = null}) : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => _$$C2FullResultsImplFromJson(json); @override - @JsonKey() + @JsonKey(name: 'id') final int id; @override - @JsonKey() + @JsonKey(name: 'user_id') final int userId; @override + @JsonKey(name: 'date') @TimestampConverter() final DateTime date; @override + @JsonKey(name: 'timezone') final String? timezone; @override + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() final DateTime? dateUtc; @override - @JsonKey() + @JsonKey(name: 'distance') final int distance; @override - @JsonKey() + @JsonKey(name: 'type') final C2ResultType type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() final double time; @override - @JsonKey() + @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType; @override - @JsonKey() + @JsonKey(name: 'source') final String source; @override - @JsonKey() + @JsonKey(name: 'weight_class') final C2WeightClass weightClass; @override - @JsonKey() + @JsonKey(name: 'verified') final bool verified; @override - @JsonKey() + @JsonKey(name: 'ranked') final bool ranked; @override + @JsonKey(name: 'comments') final String? comments; @override - @JsonKey() + @JsonKey(name: 'privacy') final C2PrivacyLevel privacy; @override + @JsonKey(name: 'stroke_rate') @DecimalIntConverter.tenths() final double restTime; @override final int? strokeRate; @override - @JsonKey() + @JsonKey(name: 'date_rate') final C2HeartRate? heartRate; @override - @JsonKey() + @JsonKey(name: 'workout') final C2Workout? workout; @override @@ -530,24 +562,31 @@ class _$C2FullResultsImpl extends _C2FullResults { abstract class _C2FullResults extends C2FullResults { factory _C2FullResults( - {final int id, - final int userId, - @TimestampConverter() required final DateTime date, - final String? timezone, - @TimestampOrNullConverter() final DateTime? dateUtc, - final int distance, - final C2ResultType type, - @DecimalIntConverter.tenths() required final double time, - final C2APIWorkoutType workoutType, - final String source, - final C2WeightClass weightClass, - final bool verified, - final bool ranked, - final String? comments, - final C2PrivacyLevel privacy, - @DecimalIntConverter.tenths() required final double restTime, + {@JsonKey(name: 'id') final int id, + @JsonKey(name: 'user_id') final int userId, + @JsonKey(name: 'date') @TimestampConverter() required final DateTime date, + @JsonKey(name: 'timezone') final String? timezone, + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + final DateTime? dateUtc, + @JsonKey(name: 'distance') final int distance, + @JsonKey(name: 'type') final C2ResultType type, + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + required final double time, + @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType, + @JsonKey(name: 'source') final String source, + @JsonKey(name: 'weight_class') final C2WeightClass weightClass, + @JsonKey(name: 'verified') final bool verified, + @JsonKey(name: 'ranked') final bool ranked, + @JsonKey(name: 'comments') final String? comments, + @JsonKey(name: 'privacy') final C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') + @DecimalIntConverter.tenths() + required final double restTime, final int? strokeRate, - final C2HeartRate? heartRate, + @JsonKey(name: 'date_rate') final C2HeartRate? heartRate, + @JsonKey(name: 'workout') final C2Workout? workout}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); @@ -555,46 +594,64 @@ abstract class _C2FullResults extends C2FullResults { _$C2FullResultsImpl.fromJson; @override + @JsonKey(name: 'id') int get id; @override + @JsonKey(name: 'user_id') int get userId; @override + @JsonKey(name: 'date') @TimestampConverter() DateTime get date; @override + @JsonKey(name: 'timezone') String? get timezone; @override + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? get dateUtc; @override + @JsonKey(name: 'distance') int get distance; @override + @JsonKey(name: 'type') C2ResultType get type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; @override + @JsonKey(name: 'workout_type') C2APIWorkoutType get workoutType; @override + @JsonKey(name: 'source') String get source; @override + @JsonKey(name: 'weight_class') C2WeightClass get weightClass; @override + @JsonKey(name: 'verified') bool get verified; @override + @JsonKey(name: 'ranked') bool get ranked; @override + @JsonKey(name: 'comments') String? get comments; @override + @JsonKey(name: 'privacy') C2PrivacyLevel get privacy; @override + @JsonKey(name: 'stroke_rate') @DecimalIntConverter.tenths() double get restTime; @override int? get strokeRate; @override + @JsonKey(name: 'date_rate') C2HeartRate? get heartRate; @override + @JsonKey(name: 'workout') C2Workout? get workout; @override @JsonKey(ignore: true) @@ -608,9 +665,13 @@ C2HeartRate _$C2HeartRateFromJson(Map json) { /// @nodoc mixin _$C2HeartRate { + @JsonKey(name: 'min') int get min => throw _privateConstructorUsedError; + @JsonKey(name: 'average') int get average => throw _privateConstructorUsedError; + @JsonKey(name: 'max') int get max => throw _privateConstructorUsedError; + @JsonKey(name: 'ending') int get ending => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -625,7 +686,11 @@ abstract class $C2HeartRateCopyWith<$Res> { C2HeartRate value, $Res Function(C2HeartRate) then) = _$C2HeartRateCopyWithImpl<$Res, C2HeartRate>; @useResult - $Res call({int min, int average, int max, int ending}); + $Res call( + {@JsonKey(name: 'min') int min, + @JsonKey(name: 'average') int average, + @JsonKey(name: 'max') int max, + @JsonKey(name: 'ending') int ending}); } /// @nodoc @@ -675,7 +740,11 @@ abstract class _$$C2HeartRateImplCopyWith<$Res> __$$C2HeartRateImplCopyWithImpl<$Res>; @override @useResult - $Res call({int min, int average, int max, int ending}); + $Res call( + {@JsonKey(name: 'min') int min, + @JsonKey(name: 'average') int average, + @JsonKey(name: 'max') int max, + @JsonKey(name: 'ending') int ending}); } /// @nodoc @@ -719,23 +788,26 @@ class __$$C2HeartRateImplCopyWithImpl<$Res> @JsonSerializable() class _$C2HeartRateImpl extends _C2HeartRate { _$C2HeartRateImpl( - {this.min = 0, this.average = 0, this.max = 0, this.ending = 0}) + {@JsonKey(name: 'min') this.min = 0, + @JsonKey(name: 'average') this.average = 0, + @JsonKey(name: 'max') this.max = 0, + @JsonKey(name: 'ending') this.ending = 0}) : super._(); factory _$C2HeartRateImpl.fromJson(Map json) => _$$C2HeartRateImplFromJson(json); @override - @JsonKey() + @JsonKey(name: 'min') final int min; @override - @JsonKey() + @JsonKey(name: 'average') final int average; @override - @JsonKey() + @JsonKey(name: 'max') final int max; @override - @JsonKey() + @JsonKey(name: 'ending') final int ending; @override @@ -774,22 +846,26 @@ class _$C2HeartRateImpl extends _C2HeartRate { abstract class _C2HeartRate extends C2HeartRate { factory _C2HeartRate( - {final int min, - final int average, - final int max, - final int ending}) = _$C2HeartRateImpl; + {@JsonKey(name: 'min') final int min, + @JsonKey(name: 'average') final int average, + @JsonKey(name: 'max') final int max, + @JsonKey(name: 'ending') final int ending}) = _$C2HeartRateImpl; _C2HeartRate._() : super._(); factory _C2HeartRate.fromJson(Map json) = _$C2HeartRateImpl.fromJson; @override + @JsonKey(name: 'min') int get min; @override + @JsonKey(name: 'average') int get average; @override + @JsonKey(name: 'max') int get max; @override + @JsonKey(name: 'ending') int get ending; @override @JsonKey(ignore: true) @@ -803,14 +879,21 @@ C2Intervals _$C2IntervalsFromJson(Map json) { /// @nodoc mixin _$C2Intervals { + @JsonKey(name: 'id') String get type => throw _privateConstructorUsedError; + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double get restTime => throw _privateConstructorUsedError; + @JsonKey(name: 'distance') double get distance => throw _privateConstructorUsedError; + @JsonKey(name: 'calories_total') int get caloriesTotal => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') int get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -826,13 +909,13 @@ abstract class $C2IntervalsCopyWith<$Res> { _$C2IntervalsCopyWithImpl<$Res, C2Intervals>; @useResult $Res call( - {String type, - @DecimalIntConverter.tenths() double time, - @DecimalIntConverter.tenths() double restTime, - double distance, - int caloriesTotal, - int strokeRate, - C2HeartRate? heartRate}); + {@JsonKey(name: 'id') String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'distance') double distance, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'stroke_rate') int strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate}); $C2HeartRateCopyWith<$Res>? get heartRate; } @@ -912,13 +995,13 @@ abstract class _$$C2IntervalsImplCopyWith<$Res> @override @useResult $Res call( - {String type, - @DecimalIntConverter.tenths() double time, - @DecimalIntConverter.tenths() double restTime, - double distance, - int caloriesTotal, - int strokeRate, - C2HeartRate? heartRate}); + {@JsonKey(name: 'id') String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'distance') double distance, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'stroke_rate') int strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate}); @override $C2HeartRateCopyWith<$Res>? get heartRate; @@ -980,38 +1063,42 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2IntervalsImpl extends _C2Intervals { _$C2IntervalsImpl( - {this.type = "time", - @DecimalIntConverter.tenths() required this.time, - @DecimalIntConverter.tenths() required this.restTime, - this.distance = 0.0, - this.caloriesTotal = 0, - this.strokeRate = 0, - this.heartRate = null}) + {@JsonKey(name: 'id') this.type = "type", + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + required this.restTime, + @JsonKey(name: 'distance') this.distance = 0.0, + @JsonKey(name: 'calories_total') this.caloriesTotal = 0, + @JsonKey(name: 'stroke_rate') this.strokeRate = 0, + @JsonKey(name: 'heart_rate') this.heartRate = null}) : super._(); factory _$C2IntervalsImpl.fromJson(Map json) => _$$C2IntervalsImplFromJson(json); @override - @JsonKey() + @JsonKey(name: 'id') final String type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() final double time; @override + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() final double restTime; @override - @JsonKey() + @JsonKey(name: 'distance') final double distance; @override - @JsonKey() + @JsonKey(name: 'calories_total') final int caloriesTotal; @override - @JsonKey() + @JsonKey(name: 'stroke_rate') final int strokeRate; @override - @JsonKey() + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate; @override @@ -1059,33 +1146,45 @@ class _$C2IntervalsImpl extends _C2Intervals { abstract class _C2Intervals extends C2Intervals { factory _C2Intervals( - {final String type, - @DecimalIntConverter.tenths() required final double time, - @DecimalIntConverter.tenths() required final double restTime, - final double distance, - final int caloriesTotal, - final int strokeRate, - final C2HeartRate? heartRate}) = _$C2IntervalsImpl; + {@JsonKey(name: 'id') final String type, + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + required final double time, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + required final double restTime, + @JsonKey(name: 'distance') final double distance, + @JsonKey(name: 'calories_total') final int caloriesTotal, + @JsonKey(name: 'stroke_rate') final int strokeRate, + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate}) = + _$C2IntervalsImpl; _C2Intervals._() : super._(); factory _C2Intervals.fromJson(Map json) = _$C2IntervalsImpl.fromJson; @override + @JsonKey(name: 'id') String get type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; @override + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double get restTime; @override + @JsonKey(name: 'distance') double get distance; @override + @JsonKey(name: 'calories_total') int get caloriesTotal; @override + @JsonKey(name: 'stroke_rate') int get strokeRate; @override + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate; @override @JsonKey(ignore: true) @@ -1585,12 +1684,18 @@ C2Splits _$C2SplitsFromJson(Map json) { /// @nodoc mixin _$C2Splits { + @JsonKey(name: 'type') String get type => throw _privateConstructorUsedError; + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; + @JsonKey(name: 'distance') double get distance => throw _privateConstructorUsedError; + @JsonKey(name: 'calories_total') int get caloriesTotal => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') int get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -1605,12 +1710,12 @@ abstract class $C2SplitsCopyWith<$Res> { _$C2SplitsCopyWithImpl<$Res, C2Splits>; @useResult $Res call( - {String type, - @DecimalIntConverter.tenths() double time, - double distance, - int caloriesTotal, - int strokeRate, - C2HeartRate? heartRate}); + {@JsonKey(name: 'type') String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'distance') double distance, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'stroke_rate') int strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate}); $C2HeartRateCopyWith<$Res>? get heartRate; } @@ -1685,12 +1790,12 @@ abstract class _$$C2SplitsImplCopyWith<$Res> @override @useResult $Res call( - {String type, - @DecimalIntConverter.tenths() double time, - double distance, - int caloriesTotal, - int strokeRate, - C2HeartRate? heartRate}); + {@JsonKey(name: 'type') String type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'distance') double distance, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'stroke_rate') int strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate}); @override $C2HeartRateCopyWith<$Res>? get heartRate; @@ -1747,34 +1852,35 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2SplitsImpl extends _C2Splits { _$C2SplitsImpl( - {this.type = "time", - @DecimalIntConverter.tenths() required this.time, - this.distance = 0.0, - this.caloriesTotal = 0, - this.strokeRate = 0, - this.heartRate = null}) + {@JsonKey(name: 'type') this.type = "time", + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: 'distance') this.distance = 0.0, + @JsonKey(name: 'calories_total') this.caloriesTotal = 0, + @JsonKey(name: 'stroke_rate') this.strokeRate = 0, + @JsonKey(name: 'heart_rate') this.heartRate = null}) : super._(); factory _$C2SplitsImpl.fromJson(Map json) => _$$C2SplitsImplFromJson(json); @override - @JsonKey() + @JsonKey(name: 'type') final String type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() final double time; @override - @JsonKey() + @JsonKey(name: 'distance') final double distance; @override - @JsonKey() + @JsonKey(name: 'calories_total') final int caloriesTotal; @override - @JsonKey() + @JsonKey(name: 'stroke_rate') final int strokeRate; @override - @JsonKey() + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate; @override @@ -1820,29 +1926,38 @@ class _$C2SplitsImpl extends _C2Splits { abstract class _C2Splits extends C2Splits { factory _C2Splits( - {final String type, - @DecimalIntConverter.tenths() required final double time, - final double distance, - final int caloriesTotal, - final int strokeRate, - final C2HeartRate? heartRate}) = _$C2SplitsImpl; + {@JsonKey(name: 'type') final String type, + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + required final double time, + @JsonKey(name: 'distance') final double distance, + @JsonKey(name: 'calories_total') final int caloriesTotal, + @JsonKey(name: 'stroke_rate') final int strokeRate, + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate}) = + _$C2SplitsImpl; _C2Splits._() : super._(); factory _C2Splits.fromJson(Map json) = _$C2SplitsImpl.fromJson; @override + @JsonKey(name: 'type') String get type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; @override + @JsonKey(name: 'distance') double get distance; @override + @JsonKey(name: 'calories_total') int get caloriesTotal; @override + @JsonKey(name: 'stroke_rate') int get strokeRate; @override + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate; @override @JsonKey(ignore: true) diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 9503758..bc54ffb 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -9,33 +9,33 @@ part of 'index.dart'; _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => _$C2FullResultsImpl( id: json['id'] as int? ?? 0, - userId: json['userId'] as int? ?? 0, + userId: json['user_id'] as int? ?? 0, date: const TimestampConverter().fromJson(json['date'] as String), timezone: json['timezone'] as String?, - dateUtc: - const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), + dateUtc: const TimestampOrNullConverter() + .fromJson(json['date_utc'] as String?), distance: json['distance'] as int? ?? 0, type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: - $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? - C2APIWorkoutType.JustRow, + workoutType: $enumDecodeNullable( + _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? + C2APIWorkoutType.JustRow, source: json['source'] as String? ?? "c2logbook dart", weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weightClass']) ?? + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? C2WeightClass.heavyweight, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, comments: json['comments'] as String?, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, - restTime: - const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), + restTime: const DecimalIntConverter.tenths() + .fromJson(json['stroke_rate'] as int), strokeRate: json['strokeRate'] as int?, - heartRate: json['heartRate'] == null + heartRate: json['date_rate'] == null ? null - : C2HeartRate.fromJson(json['heartRate'] as Map), + : C2HeartRate.fromJson(json['date_rate'] as Map), workout: json['workout'] == null ? null : C2Workout.fromJson(json['workout'] as Map), @@ -44,23 +44,24 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => { 'id': instance.id, - 'userId': instance.userId, + 'user_id': instance.userId, 'date': const TimestampConverter().toJson(instance.date), 'timezone': instance.timezone, - 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, - 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, + 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, 'verified': instance.verified, 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'stroke_rate': + const DecimalIntConverter.tenths().toJson(instance.restTime), 'strokeRate': instance.strokeRate, - 'heartRate': instance.heartRate?.toJson(), + 'date_rate': instance.heartRate?.toJson(), 'workout': instance.workout?.toJson(), }; @@ -121,27 +122,27 @@ Map _$$C2HeartRateImplToJson(_$C2HeartRateImpl instance) => _$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => _$C2IntervalsImpl( - type: json['type'] as String? ?? "time", + type: json['id'] as String? ?? "type", time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), restTime: - const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), + const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), distance: (json['distance'] as num?)?.toDouble() ?? 0.0, - caloriesTotal: json['caloriesTotal'] as int? ?? 0, - strokeRate: json['strokeRate'] as int? ?? 0, - heartRate: json['heartRate'] == null + caloriesTotal: json['calories_total'] as int? ?? 0, + strokeRate: json['stroke_rate'] as int? ?? 0, + heartRate: json['heart_rate'] == null ? null - : C2HeartRate.fromJson(json['heartRate'] as Map), + : C2HeartRate.fromJson(json['heart_rate'] as Map), ); Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => { - 'type': instance.type, + 'id': instance.type, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), 'distance': instance.distance, - 'caloriesTotal': instance.caloriesTotal, - 'strokeRate': instance.strokeRate, - 'heartRate': instance.heartRate?.toJson(), + 'calories_total': instance.caloriesTotal, + 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), }; _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => @@ -196,11 +197,11 @@ _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => type: json['type'] as String? ?? "time", time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), distance: (json['distance'] as num?)?.toDouble() ?? 0.0, - caloriesTotal: json['caloriesTotal'] as int? ?? 0, - strokeRate: json['strokeRate'] as int? ?? 0, - heartRate: json['heartRate'] == null + caloriesTotal: json['calories_total'] as int? ?? 0, + strokeRate: json['stroke_rate'] as int? ?? 0, + heartRate: json['heart_rate'] == null ? null - : C2HeartRate.fromJson(json['heartRate'] as Map), + : C2HeartRate.fromJson(json['heart_rate'] as Map), ); Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => @@ -208,9 +209,9 @@ Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => 'type': instance.type, 'time': const DecimalIntConverter.tenths().toJson(instance.time), 'distance': instance.distance, - 'caloriesTotal': instance.caloriesTotal, - 'strokeRate': instance.strokeRate, - 'heartRate': instance.heartRate?.toJson(), + 'calories_total': instance.caloriesTotal, + 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), }; _$C2UserImpl _$$C2UserImplFromJson(Map json) => _$C2UserImpl( From b9b4eba06572a159a7c3fa615725ee9420614056 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:27:41 -0400 Subject: [PATCH 15/25] More model alterations --- lib/src/types/c2_full_results.dart | 6 ++--- lib/src/types/index.freezed.dart | 43 +++++++++++++++--------------- lib/src/types/index.g.dart | 17 ++++++------ 3 files changed, 32 insertions(+), 34 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index a751561..3d6ea92 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -31,9 +31,9 @@ class C2FullResults with _$C2FullResults { @JsonKey(name: 'ranked') @Default(false) bool ranked, @JsonKey(name: 'comments')String? comments, @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - @JsonKey(name: 'stroke_rate') @DecimalIntConverter.tenths() required double restTime, - int? strokeRate, - @JsonKey(name: 'date_rate') @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, @JsonKey(name: 'workout') @Default(null) C2Workout? workout, }) = _C2FullResults; diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index c088e83..92437c4 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -53,11 +53,12 @@ mixin _$C2FullResults { String? get comments => throw _privateConstructorUsedError; @JsonKey(name: 'privacy') C2PrivacyLevel get privacy => throw _privateConstructorUsedError; - @JsonKey(name: 'stroke_rate') + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double get restTime => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') int? get strokeRate => throw _privateConstructorUsedError; - @JsonKey(name: 'date_rate') + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate => throw _privateConstructorUsedError; @JsonKey(name: 'workout') C2Workout? get workout => throw _privateConstructorUsedError; @@ -90,11 +91,9 @@ abstract class $C2FullResultsCopyWith<$Res> { @JsonKey(name: 'ranked') bool ranked, @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'stroke_rate') - @DecimalIntConverter.tenths() - double restTime, - int? strokeRate, - @JsonKey(name: 'date_rate') C2HeartRate? heartRate, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, @JsonKey(name: 'workout') C2Workout? workout}); $C2HeartRateCopyWith<$Res>? get heartRate; @@ -263,11 +262,9 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @JsonKey(name: 'ranked') bool ranked, @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'stroke_rate') - @DecimalIntConverter.tenths() - double restTime, - int? strokeRate, - @JsonKey(name: 'date_rate') C2HeartRate? heartRate, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, @JsonKey(name: 'workout') C2Workout? workout}); @override @@ -409,11 +406,11 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey(name: 'ranked') this.ranked = false, @JsonKey(name: 'comments') this.comments, @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private, - @JsonKey(name: 'stroke_rate') + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required this.restTime, - this.strokeRate, - @JsonKey(name: 'date_rate') this.heartRate = null, + @JsonKey(name: 'stroke_rate') this.strokeRate, + @JsonKey(name: 'heart_rate') this.heartRate = null, @JsonKey(name: 'workout') this.workout = null}) : super._(); @@ -469,13 +466,14 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey(name: 'privacy') final C2PrivacyLevel privacy; @override - @JsonKey(name: 'stroke_rate') + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() final double restTime; @override + @JsonKey(name: 'stroke_rate') final int? strokeRate; @override - @JsonKey(name: 'date_rate') + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate; @override @JsonKey(name: 'workout') @@ -581,11 +579,11 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'ranked') final bool ranked, @JsonKey(name: 'comments') final String? comments, @JsonKey(name: 'privacy') final C2PrivacyLevel privacy, - @JsonKey(name: 'stroke_rate') + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required final double restTime, - final int? strokeRate, - @JsonKey(name: 'date_rate') final C2HeartRate? heartRate, + @JsonKey(name: 'stroke_rate') final int? strokeRate, + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate, @JsonKey(name: 'workout') final C2Workout? workout}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); @@ -642,13 +640,14 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'privacy') C2PrivacyLevel get privacy; @override - @JsonKey(name: 'stroke_rate') + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double get restTime; @override + @JsonKey(name: 'stroke_rate') int? get strokeRate; @override - @JsonKey(name: 'date_rate') + @JsonKey(name: 'heart_rate') C2HeartRate? get heartRate; @override @JsonKey(name: 'workout') diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index bc54ffb..b8a76c6 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -30,12 +30,12 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => comments: json['comments'] as String?, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, - restTime: const DecimalIntConverter.tenths() - .fromJson(json['stroke_rate'] as int), - strokeRate: json['strokeRate'] as int?, - heartRate: json['date_rate'] == null + restTime: + const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), + strokeRate: json['stroke_rate'] as int?, + heartRate: json['heart_rate'] == null ? null - : C2HeartRate.fromJson(json['date_rate'] as Map), + : C2HeartRate.fromJson(json['heart_rate'] as Map), workout: json['workout'] == null ? null : C2Workout.fromJson(json['workout'] as Map), @@ -58,10 +58,9 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - 'stroke_rate': - const DecimalIntConverter.tenths().toJson(instance.restTime), - 'strokeRate': instance.strokeRate, - 'date_rate': instance.heartRate?.toJson(), + 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), 'workout': instance.workout?.toJson(), }; From a26ca1aa4e09f189198b659c5705a1ecded71a97 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:32:02 -0400 Subject: [PATCH 16/25] Alright no more mr nice guy --- lib/src/types/c2_full_results.dart | 50 +-- lib/src/types/index.freezed.dart | 519 +---------------------------- lib/src/types/index.g.dart | 126 +++---- 3 files changed, 72 insertions(+), 623 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 3d6ea92..0b152f9 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -5,36 +5,36 @@ part of 'index.dart'; @freezed class C2FullResults with _$C2FullResults { //TODO: figure out how to get this into JSON as time_formatted - String get timeFormatted => Duration( - seconds: this.time.toInt(), - milliseconds: - (this.time.remainder(1) * Duration.millisecondsPerSecond).toInt()) - .toString(); + // String get timeFormatted => Duration( + // seconds: this.time.toInt(), + // milliseconds: + // (this.time.remainder(1) * Duration.millisecondsPerSecond).toInt()) + // .toString(); C2FullResults._(); factory C2FullResults({ @JsonKey(name: 'id') @Default(0) int id, - @JsonKey(name: 'user_id') @Default(0) int userId, - @JsonKey(name: 'date') @TimestampConverter() required DateTime date, - @JsonKey(name: 'timezone') String? timezone, - @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, - @JsonKey(name: 'distance') @Default(0) int distance, - @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, - @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) - C2APIWorkoutType workoutType, - @JsonKey(name: 'source') @Default("c2logbook dart") String source, - @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) - C2WeightClass weightClass, - @JsonKey(name: 'verified') @Default(false) bool verified, - @JsonKey(name: 'ranked') @Default(false) bool ranked, - @JsonKey(name: 'comments')String? comments, - @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, - @JsonKey(name: 'stroke_rate') int? strokeRate, - @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, - @JsonKey(name: 'workout') @Default(null) C2Workout? workout, + // @JsonKey(name: 'user_id') @Default(0) int userId, + // @JsonKey(name: 'date') @TimestampConverter() required DateTime date, + // @JsonKey(name: 'timezone') String? timezone, + // @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + // @JsonKey(name: 'distance') @Default(0) int distance, + // @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, + // @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + // @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) + // C2APIWorkoutType workoutType, + // @JsonKey(name: 'source') @Default("c2logbook dart") String source, + // @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) + // C2WeightClass weightClass, + // @JsonKey(name: 'verified') @Default(false) bool verified, + // @JsonKey(name: 'ranked') @Default(false) bool ranked, + // @JsonKey(name: 'comments')String? comments, + // @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + // @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, + // @JsonKey(name: 'stroke_rate') int? strokeRate, + // @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, + // @JsonKey(name: 'workout') @Default(null) C2Workout? workout, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 92437c4..3e0c634 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -22,46 +22,6 @@ C2FullResults _$C2FullResultsFromJson(Map json) { mixin _$C2FullResults { @JsonKey(name: 'id') int get id => throw _privateConstructorUsedError; - @JsonKey(name: 'user_id') - int get userId => throw _privateConstructorUsedError; - @JsonKey(name: 'date') - @TimestampConverter() - DateTime get date => throw _privateConstructorUsedError; - @JsonKey(name: 'timezone') - String? get timezone => throw _privateConstructorUsedError; - @JsonKey(name: 'date_utc') - @TimestampOrNullConverter() - DateTime? get dateUtc => throw _privateConstructorUsedError; - @JsonKey(name: 'distance') - int get distance => throw _privateConstructorUsedError; - @JsonKey(name: 'type') - C2ResultType get type => throw _privateConstructorUsedError; - @JsonKey(name: 'time') - @DecimalIntConverter.tenths() - double get time => throw _privateConstructorUsedError; - @JsonKey(name: 'workout_type') - C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; - @JsonKey(name: 'source') - String get source => throw _privateConstructorUsedError; - @JsonKey(name: 'weight_class') - C2WeightClass get weightClass => throw _privateConstructorUsedError; - @JsonKey(name: 'verified') - bool get verified => throw _privateConstructorUsedError; - @JsonKey(name: 'ranked') - bool get ranked => throw _privateConstructorUsedError; - @JsonKey(name: 'comments') - String? get comments => throw _privateConstructorUsedError; - @JsonKey(name: 'privacy') - C2PrivacyLevel get privacy => throw _privateConstructorUsedError; - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - double get restTime => throw _privateConstructorUsedError; - @JsonKey(name: 'stroke_rate') - int? get strokeRate => throw _privateConstructorUsedError; - @JsonKey(name: 'heart_rate') - C2HeartRate? get heartRate => throw _privateConstructorUsedError; - @JsonKey(name: 'workout') - C2Workout? get workout => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -75,29 +35,7 @@ abstract class $C2FullResultsCopyWith<$Res> { C2FullResults value, $Res Function(C2FullResults) then) = _$C2FullResultsCopyWithImpl<$Res, C2FullResults>; @useResult - $Res call( - {@JsonKey(name: 'id') int id, - @JsonKey(name: 'user_id') int userId, - @JsonKey(name: 'date') @TimestampConverter() DateTime date, - @JsonKey(name: 'timezone') String? timezone, - @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, - @JsonKey(name: 'distance') int distance, - @JsonKey(name: 'type') C2ResultType type, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, - @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, - @JsonKey(name: 'source') String source, - @JsonKey(name: 'weight_class') C2WeightClass weightClass, - @JsonKey(name: 'verified') bool verified, - @JsonKey(name: 'ranked') bool ranked, - @JsonKey(name: 'comments') String? comments, - @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, - @JsonKey(name: 'stroke_rate') int? strokeRate, - @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, - @JsonKey(name: 'workout') C2Workout? workout}); - - $C2HeartRateCopyWith<$Res>? get heartRate; - $C2WorkoutCopyWith<$Res>? get workout; + $Res call({@JsonKey(name: 'id') int id}); } /// @nodoc @@ -114,128 +52,14 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> @override $Res call({ Object? id = null, - Object? userId = null, - Object? date = null, - Object? timezone = freezed, - Object? dateUtc = freezed, - Object? distance = null, - Object? type = null, - Object? time = null, - Object? workoutType = null, - Object? source = null, - Object? weightClass = null, - Object? verified = null, - Object? ranked = null, - Object? comments = freezed, - Object? privacy = null, - Object? restTime = null, - Object? strokeRate = freezed, - Object? heartRate = freezed, - Object? workout = freezed, }) { return _then(_value.copyWith( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable as int, - userId: null == userId - ? _value.userId - : userId // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - timezone: freezed == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String?, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, - distance: null == distance - ? _value.distance - : distance // ignore: cast_nullable_to_non_nullable - as int, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as C2ResultType, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as double, - workoutType: null == workoutType - ? _value.workoutType - : workoutType // ignore: cast_nullable_to_non_nullable - as C2APIWorkoutType, - source: null == source - ? _value.source - : source // ignore: cast_nullable_to_non_nullable - as String, - weightClass: null == weightClass - ? _value.weightClass - : weightClass // ignore: cast_nullable_to_non_nullable - as C2WeightClass, - verified: null == verified - ? _value.verified - : verified // ignore: cast_nullable_to_non_nullable - as bool, - ranked: null == ranked - ? _value.ranked - : ranked // ignore: cast_nullable_to_non_nullable - as bool, - comments: freezed == comments - ? _value.comments - : comments // ignore: cast_nullable_to_non_nullable - as String?, - privacy: null == privacy - ? _value.privacy - : privacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, - heartRate: freezed == heartRate - ? _value.heartRate - : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate?, - workout: freezed == workout - ? _value.workout - : workout // ignore: cast_nullable_to_non_nullable - as C2Workout?, ) as $Val); } - - @override - @pragma('vm:prefer-inline') - $C2HeartRateCopyWith<$Res>? get heartRate { - if (_value.heartRate == null) { - return null; - } - - return $C2HeartRateCopyWith<$Res>(_value.heartRate!, (value) { - return _then(_value.copyWith(heartRate: value) as $Val); - }); - } - - @override - @pragma('vm:prefer-inline') - $C2WorkoutCopyWith<$Res>? get workout { - if (_value.workout == null) { - return null; - } - - return $C2WorkoutCopyWith<$Res>(_value.workout!, (value) { - return _then(_value.copyWith(workout: value) as $Val); - }); - } } /// @nodoc @@ -246,31 +70,7 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> __$$C2FullResultsImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {@JsonKey(name: 'id') int id, - @JsonKey(name: 'user_id') int userId, - @JsonKey(name: 'date') @TimestampConverter() DateTime date, - @JsonKey(name: 'timezone') String? timezone, - @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, - @JsonKey(name: 'distance') int distance, - @JsonKey(name: 'type') C2ResultType type, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, - @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, - @JsonKey(name: 'source') String source, - @JsonKey(name: 'weight_class') C2WeightClass weightClass, - @JsonKey(name: 'verified') bool verified, - @JsonKey(name: 'ranked') bool ranked, - @JsonKey(name: 'comments') String? comments, - @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, - @JsonKey(name: 'stroke_rate') int? strokeRate, - @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, - @JsonKey(name: 'workout') C2Workout? workout}); - - @override - $C2HeartRateCopyWith<$Res>? get heartRate; - @override - $C2WorkoutCopyWith<$Res>? get workout; + $Res call({@JsonKey(name: 'id') int id}); } /// @nodoc @@ -285,102 +85,12 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> @override $Res call({ Object? id = null, - Object? userId = null, - Object? date = null, - Object? timezone = freezed, - Object? dateUtc = freezed, - Object? distance = null, - Object? type = null, - Object? time = null, - Object? workoutType = null, - Object? source = null, - Object? weightClass = null, - Object? verified = null, - Object? ranked = null, - Object? comments = freezed, - Object? privacy = null, - Object? restTime = null, - Object? strokeRate = freezed, - Object? heartRate = freezed, - Object? workout = freezed, }) { return _then(_$C2FullResultsImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable as int, - userId: null == userId - ? _value.userId - : userId // ignore: cast_nullable_to_non_nullable - as int, - date: null == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as DateTime, - timezone: freezed == timezone - ? _value.timezone - : timezone // ignore: cast_nullable_to_non_nullable - as String?, - dateUtc: freezed == dateUtc - ? _value.dateUtc - : dateUtc // ignore: cast_nullable_to_non_nullable - as DateTime?, - distance: null == distance - ? _value.distance - : distance // ignore: cast_nullable_to_non_nullable - as int, - type: null == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as C2ResultType, - time: null == time - ? _value.time - : time // ignore: cast_nullable_to_non_nullable - as double, - workoutType: null == workoutType - ? _value.workoutType - : workoutType // ignore: cast_nullable_to_non_nullable - as C2APIWorkoutType, - source: null == source - ? _value.source - : source // ignore: cast_nullable_to_non_nullable - as String, - weightClass: null == weightClass - ? _value.weightClass - : weightClass // ignore: cast_nullable_to_non_nullable - as C2WeightClass, - verified: null == verified - ? _value.verified - : verified // ignore: cast_nullable_to_non_nullable - as bool, - ranked: null == ranked - ? _value.ranked - : ranked // ignore: cast_nullable_to_non_nullable - as bool, - comments: freezed == comments - ? _value.comments - : comments // ignore: cast_nullable_to_non_nullable - as String?, - privacy: null == privacy - ? _value.privacy - : privacy // ignore: cast_nullable_to_non_nullable - as C2PrivacyLevel, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, - strokeRate: freezed == strokeRate - ? _value.strokeRate - : strokeRate // ignore: cast_nullable_to_non_nullable - as int?, - heartRate: freezed == heartRate - ? _value.heartRate - : heartRate // ignore: cast_nullable_to_non_nullable - as C2HeartRate?, - workout: freezed == workout - ? _value.workout - : workout // ignore: cast_nullable_to_non_nullable - as C2Workout?, )); } } @@ -388,31 +98,7 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$C2FullResultsImpl extends _C2FullResults { - _$C2FullResultsImpl( - {@JsonKey(name: 'id') this.id = 0, - @JsonKey(name: 'user_id') this.userId = 0, - @JsonKey(name: 'date') @TimestampConverter() required this.date, - @JsonKey(name: 'timezone') this.timezone, - @JsonKey(name: 'date_utc') @TimestampOrNullConverter() this.dateUtc, - @JsonKey(name: 'distance') this.distance = 0, - @JsonKey(name: 'type') this.type = C2ResultType.rower, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, - @JsonKey(name: 'workout_type') - this.workoutType = C2APIWorkoutType.JustRow, - @JsonKey(name: 'source') this.source = "c2logbook dart", - @JsonKey(name: 'weight_class') - this.weightClass = C2WeightClass.heavyweight, - @JsonKey(name: 'verified') this.verified = false, - @JsonKey(name: 'ranked') this.ranked = false, - @JsonKey(name: 'comments') this.comments, - @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private, - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - required this.restTime, - @JsonKey(name: 'stroke_rate') this.strokeRate, - @JsonKey(name: 'heart_rate') this.heartRate = null, - @JsonKey(name: 'workout') this.workout = null}) - : super._(); + _$C2FullResultsImpl({@JsonKey(name: 'id') this.id = 0}) : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => _$$C2FullResultsImplFromJson(json); @@ -420,68 +106,10 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey(name: 'id') final int id; - @override - @JsonKey(name: 'user_id') - final int userId; - @override - @JsonKey(name: 'date') - @TimestampConverter() - final DateTime date; - @override - @JsonKey(name: 'timezone') - final String? timezone; - @override - @JsonKey(name: 'date_utc') - @TimestampOrNullConverter() - final DateTime? dateUtc; - @override - @JsonKey(name: 'distance') - final int distance; - @override - @JsonKey(name: 'type') - final C2ResultType type; - @override - @JsonKey(name: 'time') - @DecimalIntConverter.tenths() - final double time; - @override - @JsonKey(name: 'workout_type') - final C2APIWorkoutType workoutType; - @override - @JsonKey(name: 'source') - final String source; - @override - @JsonKey(name: 'weight_class') - final C2WeightClass weightClass; - @override - @JsonKey(name: 'verified') - final bool verified; - @override - @JsonKey(name: 'ranked') - final bool ranked; - @override - @JsonKey(name: 'comments') - final String? comments; - @override - @JsonKey(name: 'privacy') - final C2PrivacyLevel privacy; - @override - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - final double restTime; - @override - @JsonKey(name: 'stroke_rate') - final int? strokeRate; - @override - @JsonKey(name: 'heart_rate') - final C2HeartRate? heartRate; - @override - @JsonKey(name: 'workout') - final C2Workout? workout; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, restTime: $restTime, strokeRate: $strokeRate, heartRate: $heartRate, workout: $workout)'; + return 'C2FullResults(id: $id)'; } @override @@ -489,60 +117,12 @@ class _$C2FullResultsImpl extends _C2FullResults { return identical(this, other) || (other.runtimeType == runtimeType && other is _$C2FullResultsImpl && - (identical(other.id, id) || other.id == id) && - (identical(other.userId, userId) || other.userId == userId) && - (identical(other.date, date) || other.date == date) && - (identical(other.timezone, timezone) || - other.timezone == timezone) && - (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && - (identical(other.distance, distance) || - other.distance == distance) && - (identical(other.type, type) || other.type == type) && - (identical(other.time, time) || other.time == time) && - (identical(other.workoutType, workoutType) || - other.workoutType == workoutType) && - (identical(other.source, source) || other.source == source) && - (identical(other.weightClass, weightClass) || - other.weightClass == weightClass) && - (identical(other.verified, verified) || - other.verified == verified) && - (identical(other.ranked, ranked) || other.ranked == ranked) && - (identical(other.comments, comments) || - other.comments == comments) && - (identical(other.privacy, privacy) || other.privacy == privacy) && - (identical(other.restTime, restTime) || - other.restTime == restTime) && - (identical(other.strokeRate, strokeRate) || - other.strokeRate == strokeRate) && - (identical(other.heartRate, heartRate) || - other.heartRate == heartRate) && - (identical(other.workout, workout) || other.workout == workout)); + (identical(other.id, id) || other.id == id)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hashAll([ - runtimeType, - id, - userId, - date, - timezone, - dateUtc, - distance, - type, - time, - workoutType, - source, - weightClass, - verified, - ranked, - comments, - privacy, - restTime, - strokeRate, - heartRate, - workout - ]); + int get hashCode => Object.hash(runtimeType, id); @JsonKey(ignore: true) @override @@ -559,33 +139,8 @@ class _$C2FullResultsImpl extends _C2FullResults { } abstract class _C2FullResults extends C2FullResults { - factory _C2FullResults( - {@JsonKey(name: 'id') final int id, - @JsonKey(name: 'user_id') final int userId, - @JsonKey(name: 'date') @TimestampConverter() required final DateTime date, - @JsonKey(name: 'timezone') final String? timezone, - @JsonKey(name: 'date_utc') - @TimestampOrNullConverter() - final DateTime? dateUtc, - @JsonKey(name: 'distance') final int distance, - @JsonKey(name: 'type') final C2ResultType type, - @JsonKey(name: 'time') - @DecimalIntConverter.tenths() - required final double time, - @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType, - @JsonKey(name: 'source') final String source, - @JsonKey(name: 'weight_class') final C2WeightClass weightClass, - @JsonKey(name: 'verified') final bool verified, - @JsonKey(name: 'ranked') final bool ranked, - @JsonKey(name: 'comments') final String? comments, - @JsonKey(name: 'privacy') final C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - required final double restTime, - @JsonKey(name: 'stroke_rate') final int? strokeRate, - @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate, - @JsonKey(name: 'workout') - final C2Workout? workout}) = _$C2FullResultsImpl; + factory _C2FullResults({@JsonKey(name: 'id') final int id}) = + _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -595,64 +150,6 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'id') int get id; @override - @JsonKey(name: 'user_id') - int get userId; - @override - @JsonKey(name: 'date') - @TimestampConverter() - DateTime get date; - @override - @JsonKey(name: 'timezone') - String? get timezone; - @override - @JsonKey(name: 'date_utc') - @TimestampOrNullConverter() - DateTime? get dateUtc; - @override - @JsonKey(name: 'distance') - int get distance; - @override - @JsonKey(name: 'type') - C2ResultType get type; - @override - @JsonKey(name: 'time') - @DecimalIntConverter.tenths() - double get time; - @override - @JsonKey(name: 'workout_type') - C2APIWorkoutType get workoutType; - @override - @JsonKey(name: 'source') - String get source; - @override - @JsonKey(name: 'weight_class') - C2WeightClass get weightClass; - @override - @JsonKey(name: 'verified') - bool get verified; - @override - @JsonKey(name: 'ranked') - bool get ranked; - @override - @JsonKey(name: 'comments') - String? get comments; - @override - @JsonKey(name: 'privacy') - C2PrivacyLevel get privacy; - @override - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - double get restTime; - @override - @JsonKey(name: 'stroke_rate') - int? get strokeRate; - @override - @JsonKey(name: 'heart_rate') - C2HeartRate? get heartRate; - @override - @JsonKey(name: 'workout') - C2Workout? get workout; - @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index b8a76c6..78fc86f 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -9,100 +9,13 @@ part of 'index.dart'; _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => _$C2FullResultsImpl( id: json['id'] as int? ?? 0, - userId: json['user_id'] as int? ?? 0, - date: const TimestampConverter().fromJson(json['date'] as String), - timezone: json['timezone'] as String?, - dateUtc: const TimestampOrNullConverter() - .fromJson(json['date_utc'] as String?), - distance: json['distance'] as int? ?? 0, - type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? - C2ResultType.rower, - time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: $enumDecodeNullable( - _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? - C2APIWorkoutType.JustRow, - source: json['source'] as String? ?? "c2logbook dart", - weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? - C2WeightClass.heavyweight, - verified: json['verified'] as bool? ?? false, - ranked: json['ranked'] as bool? ?? false, - comments: json['comments'] as String?, - privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? - C2PrivacyLevel.private, - restTime: - const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), - strokeRate: json['stroke_rate'] as int?, - heartRate: json['heart_rate'] == null - ? null - : C2HeartRate.fromJson(json['heart_rate'] as Map), - workout: json['workout'] == null - ? null - : C2Workout.fromJson(json['workout'] as Map), ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => { 'id': instance.id, - 'user_id': instance.userId, - 'date': const TimestampConverter().toJson(instance.date), - 'timezone': instance.timezone, - 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), - 'distance': instance.distance, - 'type': _$C2ResultTypeEnumMap[instance.type]!, - 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, - 'source': instance.source, - 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, - 'verified': instance.verified, - 'ranked': instance.ranked, - 'comments': instance.comments, - 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), - 'stroke_rate': instance.strokeRate, - 'heart_rate': instance.heartRate?.toJson(), - 'workout': instance.workout?.toJson(), }; -const _$C2ResultTypeEnumMap = { - C2ResultType.rower: 'rower', - C2ResultType.skierg: 'skierg', - C2ResultType.bike: 'bike', - C2ResultType.dynamic: 'dynamic', - C2ResultType.slides: 'slides', - C2ResultType.paddle: 'paddle', - C2ResultType.water: 'water', - C2ResultType.snow: 'snow', - C2ResultType.rollerski: 'rollerski', - C2ResultType.multierg: 'multierg', -}; - -const _$C2APIWorkoutTypeEnumMap = { - C2APIWorkoutType.unknown: 'unknown', - C2APIWorkoutType.JustRow: 'JustRow', - C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', - C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', - C2APIWorkoutType.FixedCalorie: 'FixedCalorie', - C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', - C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', - C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', - C2APIWorkoutType.VariableInterval: 'VariableInterval', - C2APIWorkoutType.VariableIntervalUndefinedRest: - 'VariableIntervalUndefinedRest', -}; - -const _$C2WeightClassEnumMap = { - C2WeightClass.lightweight: 'L', - C2WeightClass.heavyweight: 'H', -}; - -const _$C2PrivacyLevelEnumMap = { - C2PrivacyLevel.private: 'private', - C2PrivacyLevel.partners: 'partners', - C2PrivacyLevel.logged_in: 'logged_in', - C2PrivacyLevel.everyone: 'everyone', -}; - _$C2HeartRateImpl _$$C2HeartRateImplFromJson(Map json) => _$C2HeartRateImpl( min: json['min'] as int? ?? 0, @@ -191,6 +104,45 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, }; +const _$C2ResultTypeEnumMap = { + C2ResultType.rower: 'rower', + C2ResultType.skierg: 'skierg', + C2ResultType.bike: 'bike', + C2ResultType.dynamic: 'dynamic', + C2ResultType.slides: 'slides', + C2ResultType.paddle: 'paddle', + C2ResultType.water: 'water', + C2ResultType.snow: 'snow', + C2ResultType.rollerski: 'rollerski', + C2ResultType.multierg: 'multierg', +}; + +const _$C2APIWorkoutTypeEnumMap = { + C2APIWorkoutType.unknown: 'unknown', + C2APIWorkoutType.JustRow: 'JustRow', + C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', + C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', + C2APIWorkoutType.FixedCalorie: 'FixedCalorie', + C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', + C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', + C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', + C2APIWorkoutType.VariableInterval: 'VariableInterval', + C2APIWorkoutType.VariableIntervalUndefinedRest: + 'VariableIntervalUndefinedRest', +}; + +const _$C2WeightClassEnumMap = { + C2WeightClass.lightweight: 'L', + C2WeightClass.heavyweight: 'H', +}; + +const _$C2PrivacyLevelEnumMap = { + C2PrivacyLevel.private: 'private', + C2PrivacyLevel.partners: 'partners', + C2PrivacyLevel.logged_in: 'logged_in', + C2PrivacyLevel.everyone: 'everyone', +}; + _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( type: json['type'] as String? ?? "time", From 81f1731dc2db204a2f63c9beee3f8d4b47889346 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:41:46 -0400 Subject: [PATCH 17/25] Alright no more mr nice guy --- lib/src/types/c2_full_results.dart | 24 +-- lib/src/types/index.freezed.dart | 271 ++++++++++++++++++++++++++++- lib/src/types/index.g.dart | 90 ++++++---- 3 files changed, 333 insertions(+), 52 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 0b152f9..f8450a6 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -15,18 +15,18 @@ class C2FullResults with _$C2FullResults { factory C2FullResults({ @JsonKey(name: 'id') @Default(0) int id, - // @JsonKey(name: 'user_id') @Default(0) int userId, - // @JsonKey(name: 'date') @TimestampConverter() required DateTime date, - // @JsonKey(name: 'timezone') String? timezone, - // @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, - // @JsonKey(name: 'distance') @Default(0) int distance, - // @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, - // @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, - // @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) - // C2APIWorkoutType workoutType, - // @JsonKey(name: 'source') @Default("c2logbook dart") String source, - // @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) - // C2WeightClass weightClass, + @JsonKey(name: 'user_id') @Default(0) int userId, + @JsonKey(name: 'date') @TimestampConverter() required DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') @Default(0) int distance, + @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) + C2APIWorkoutType workoutType, + @JsonKey(name: 'source') @Default("c2logbook dart") String source, + @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) + C2WeightClass weightClass, // @JsonKey(name: 'verified') @Default(false) bool verified, // @JsonKey(name: 'ranked') @Default(false) bool ranked, // @JsonKey(name: 'comments')String? comments, diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 3e0c634..765000d 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -22,6 +22,29 @@ C2FullResults _$C2FullResultsFromJson(Map json) { mixin _$C2FullResults { @JsonKey(name: 'id') int get id => throw _privateConstructorUsedError; + @JsonKey(name: 'user_id') + int get userId => throw _privateConstructorUsedError; + @JsonKey(name: 'date') + @TimestampConverter() + DateTime get date => throw _privateConstructorUsedError; + @JsonKey(name: 'timezone') + String? get timezone => throw _privateConstructorUsedError; + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + DateTime? get dateUtc => throw _privateConstructorUsedError; + @JsonKey(name: 'distance') + int get distance => throw _privateConstructorUsedError; + @JsonKey(name: 'type') + C2ResultType get type => throw _privateConstructorUsedError; + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + double get time => throw _privateConstructorUsedError; + @JsonKey(name: 'workout_type') + C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; + @JsonKey(name: 'source') + String get source => throw _privateConstructorUsedError; + @JsonKey(name: 'weight_class') + C2WeightClass get weightClass => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -35,7 +58,18 @@ abstract class $C2FullResultsCopyWith<$Res> { C2FullResults value, $Res Function(C2FullResults) then) = _$C2FullResultsCopyWithImpl<$Res, C2FullResults>; @useResult - $Res call({@JsonKey(name: 'id') int id}); + $Res call( + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass}); } /// @nodoc @@ -52,12 +86,62 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> @override $Res call({ Object? id = null, + Object? userId = null, + Object? date = null, + Object? timezone = freezed, + Object? dateUtc = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, }) { return _then(_value.copyWith( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, ) as $Val); } } @@ -70,7 +154,18 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> __$$C2FullResultsImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: 'id') int id}); + $Res call( + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass}); } /// @nodoc @@ -85,12 +180,62 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> @override $Res call({ Object? id = null, + Object? userId = null, + Object? date = null, + Object? timezone = freezed, + Object? dateUtc = freezed, + Object? distance = null, + Object? type = null, + Object? time = null, + Object? workoutType = null, + Object? source = null, + Object? weightClass = null, }) { return _then(_$C2FullResultsImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable as int, + userId: null == userId + ? _value.userId + : userId // ignore: cast_nullable_to_non_nullable + as int, + date: null == date + ? _value.date + : date // ignore: cast_nullable_to_non_nullable + as DateTime, + timezone: freezed == timezone + ? _value.timezone + : timezone // ignore: cast_nullable_to_non_nullable + as String?, + dateUtc: freezed == dateUtc + ? _value.dateUtc + : dateUtc // ignore: cast_nullable_to_non_nullable + as DateTime?, + distance: null == distance + ? _value.distance + : distance // ignore: cast_nullable_to_non_nullable + as int, + type: null == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as C2ResultType, + time: null == time + ? _value.time + : time // ignore: cast_nullable_to_non_nullable + as double, + workoutType: null == workoutType + ? _value.workoutType + : workoutType // ignore: cast_nullable_to_non_nullable + as C2APIWorkoutType, + source: null == source + ? _value.source + : source // ignore: cast_nullable_to_non_nullable + as String, + weightClass: null == weightClass + ? _value.weightClass + : weightClass // ignore: cast_nullable_to_non_nullable + as C2WeightClass, )); } } @@ -98,7 +243,21 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() class _$C2FullResultsImpl extends _C2FullResults { - _$C2FullResultsImpl({@JsonKey(name: 'id') this.id = 0}) : super._(); + _$C2FullResultsImpl( + {@JsonKey(name: 'id') this.id = 0, + @JsonKey(name: 'user_id') this.userId = 0, + @JsonKey(name: 'date') @TimestampConverter() required this.date, + @JsonKey(name: 'timezone') this.timezone, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() this.dateUtc, + @JsonKey(name: 'distance') this.distance = 0, + @JsonKey(name: 'type') this.type = C2ResultType.rower, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: 'workout_type') + this.workoutType = C2APIWorkoutType.JustRow, + @JsonKey(name: 'source') this.source = "c2logbook dart", + @JsonKey(name: 'weight_class') + this.weightClass = C2WeightClass.heavyweight}) + : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => _$$C2FullResultsImplFromJson(json); @@ -106,10 +265,43 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey(name: 'id') final int id; + @override + @JsonKey(name: 'user_id') + final int userId; + @override + @JsonKey(name: 'date') + @TimestampConverter() + final DateTime date; + @override + @JsonKey(name: 'timezone') + final String? timezone; + @override + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + final DateTime? dateUtc; + @override + @JsonKey(name: 'distance') + final int distance; + @override + @JsonKey(name: 'type') + final C2ResultType type; + @override + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + final double time; + @override + @JsonKey(name: 'workout_type') + final C2APIWorkoutType workoutType; + @override + @JsonKey(name: 'source') + final String source; + @override + @JsonKey(name: 'weight_class') + final C2WeightClass weightClass; @override String toString() { - return 'C2FullResults(id: $id)'; + return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass)'; } @override @@ -117,12 +309,27 @@ class _$C2FullResultsImpl extends _C2FullResults { return identical(this, other) || (other.runtimeType == runtimeType && other is _$C2FullResultsImpl && - (identical(other.id, id) || other.id == id)); + (identical(other.id, id) || other.id == id) && + (identical(other.userId, userId) || other.userId == userId) && + (identical(other.date, date) || other.date == date) && + (identical(other.timezone, timezone) || + other.timezone == timezone) && + (identical(other.dateUtc, dateUtc) || other.dateUtc == dateUtc) && + (identical(other.distance, distance) || + other.distance == distance) && + (identical(other.type, type) || other.type == type) && + (identical(other.time, time) || other.time == time) && + (identical(other.workoutType, workoutType) || + other.workoutType == workoutType) && + (identical(other.source, source) || other.source == source) && + (identical(other.weightClass, weightClass) || + other.weightClass == weightClass)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id); + int get hashCode => Object.hash(runtimeType, id, userId, date, timezone, + dateUtc, distance, type, time, workoutType, source, weightClass); @JsonKey(ignore: true) @override @@ -139,8 +346,23 @@ class _$C2FullResultsImpl extends _C2FullResults { } abstract class _C2FullResults extends C2FullResults { - factory _C2FullResults({@JsonKey(name: 'id') final int id}) = - _$C2FullResultsImpl; + factory _C2FullResults( + {@JsonKey(name: 'id') final int id, + @JsonKey(name: 'user_id') final int userId, + @JsonKey(name: 'date') @TimestampConverter() required final DateTime date, + @JsonKey(name: 'timezone') final String? timezone, + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + final DateTime? dateUtc, + @JsonKey(name: 'distance') final int distance, + @JsonKey(name: 'type') final C2ResultType type, + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + required final double time, + @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType, + @JsonKey(name: 'source') final String source, + @JsonKey(name: 'weight_class') + final C2WeightClass weightClass}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -150,6 +372,39 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'id') int get id; @override + @JsonKey(name: 'user_id') + int get userId; + @override + @JsonKey(name: 'date') + @TimestampConverter() + DateTime get date; + @override + @JsonKey(name: 'timezone') + String? get timezone; + @override + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + DateTime? get dateUtc; + @override + @JsonKey(name: 'distance') + int get distance; + @override + @JsonKey(name: 'type') + C2ResultType get type; + @override + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + double get time; + @override + @JsonKey(name: 'workout_type') + C2APIWorkoutType get workoutType; + @override + @JsonKey(name: 'source') + String get source; + @override + @JsonKey(name: 'weight_class') + C2WeightClass get weightClass; + @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 78fc86f..002d4fb 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -9,13 +9,71 @@ part of 'index.dart'; _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => _$C2FullResultsImpl( id: json['id'] as int? ?? 0, + userId: json['user_id'] as int? ?? 0, + date: const TimestampConverter().fromJson(json['date'] as String), + timezone: json['timezone'] as String?, + dateUtc: const TimestampOrNullConverter() + .fromJson(json['date_utc'] as String?), + distance: json['distance'] as int? ?? 0, + type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? + C2ResultType.rower, + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + workoutType: $enumDecodeNullable( + _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? + C2APIWorkoutType.JustRow, + source: json['source'] as String? ?? "c2logbook dart", + weightClass: + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? + C2WeightClass.heavyweight, ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => { 'id': instance.id, + 'user_id': instance.userId, + 'date': const TimestampConverter().toJson(instance.date), + 'timezone': instance.timezone, + 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'distance': instance.distance, + 'type': _$C2ResultTypeEnumMap[instance.type]!, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'source': instance.source, + 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, }; +const _$C2ResultTypeEnumMap = { + C2ResultType.rower: 'rower', + C2ResultType.skierg: 'skierg', + C2ResultType.bike: 'bike', + C2ResultType.dynamic: 'dynamic', + C2ResultType.slides: 'slides', + C2ResultType.paddle: 'paddle', + C2ResultType.water: 'water', + C2ResultType.snow: 'snow', + C2ResultType.rollerski: 'rollerski', + C2ResultType.multierg: 'multierg', +}; + +const _$C2APIWorkoutTypeEnumMap = { + C2APIWorkoutType.unknown: 'unknown', + C2APIWorkoutType.JustRow: 'JustRow', + C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', + C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', + C2APIWorkoutType.FixedCalorie: 'FixedCalorie', + C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', + C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', + C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', + C2APIWorkoutType.VariableInterval: 'VariableInterval', + C2APIWorkoutType.VariableIntervalUndefinedRest: + 'VariableIntervalUndefinedRest', +}; + +const _$C2WeightClassEnumMap = { + C2WeightClass.lightweight: 'L', + C2WeightClass.heavyweight: 'H', +}; + _$C2HeartRateImpl _$$C2HeartRateImplFromJson(Map json) => _$C2HeartRateImpl( min: json['min'] as int? ?? 0, @@ -104,38 +162,6 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, }; -const _$C2ResultTypeEnumMap = { - C2ResultType.rower: 'rower', - C2ResultType.skierg: 'skierg', - C2ResultType.bike: 'bike', - C2ResultType.dynamic: 'dynamic', - C2ResultType.slides: 'slides', - C2ResultType.paddle: 'paddle', - C2ResultType.water: 'water', - C2ResultType.snow: 'snow', - C2ResultType.rollerski: 'rollerski', - C2ResultType.multierg: 'multierg', -}; - -const _$C2APIWorkoutTypeEnumMap = { - C2APIWorkoutType.unknown: 'unknown', - C2APIWorkoutType.JustRow: 'JustRow', - C2APIWorkoutType.FixedDistanceSplits: 'FixedDistanceSplits', - C2APIWorkoutType.FixedTimeSplits: 'FixedTimeSplits', - C2APIWorkoutType.FixedCalorie: 'FixedCalorie', - C2APIWorkoutType.FixedTimeInterval: 'FixedTimeInterval', - C2APIWorkoutType.FixedDistanceInterval: 'FixedDistanceInterval', - C2APIWorkoutType.FixedCalorieInterval: 'FixedCalorieInterval', - C2APIWorkoutType.VariableInterval: 'VariableInterval', - C2APIWorkoutType.VariableIntervalUndefinedRest: - 'VariableIntervalUndefinedRest', -}; - -const _$C2WeightClassEnumMap = { - C2WeightClass.lightweight: 'L', - C2WeightClass.heavyweight: 'H', -}; - const _$C2PrivacyLevelEnumMap = { C2PrivacyLevel.private: 'private', C2PrivacyLevel.partners: 'partners', From ea413e0c7d32b45ec04eb0b342ac6e1febd8d024 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:46:55 -0400 Subject: [PATCH 18/25] Alright no more mr nice guy --- lib/src/types/c2_full_results.dart | 12 +- lib/src/types/index.freezed.dart | 184 +++++++++++++++++++++++++++-- lib/src/types/index.g.dart | 28 +++-- 3 files changed, 202 insertions(+), 22 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index f8450a6..5442ea1 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -27,12 +27,12 @@ class C2FullResults with _$C2FullResults { @JsonKey(name: 'source') @Default("c2logbook dart") String source, @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - // @JsonKey(name: 'verified') @Default(false) bool verified, - // @JsonKey(name: 'ranked') @Default(false) bool ranked, - // @JsonKey(name: 'comments')String? comments, - // @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - // @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, - // @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'verified') @Default(false) bool verified, + @JsonKey(name: 'ranked') @Default(false) bool ranked, + @JsonKey(name: 'comments')String? comments, + @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate, // @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, // @JsonKey(name: 'workout') @Default(null) C2Workout? workout, }) = _C2FullResults; diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 765000d..41078cb 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -45,6 +45,19 @@ mixin _$C2FullResults { String get source => throw _privateConstructorUsedError; @JsonKey(name: 'weight_class') C2WeightClass get weightClass => throw _privateConstructorUsedError; + @JsonKey(name: 'verified') + bool get verified => throw _privateConstructorUsedError; + @JsonKey(name: 'ranked') + bool get ranked => throw _privateConstructorUsedError; + @JsonKey(name: 'comments') + String? get comments => throw _privateConstructorUsedError; + @JsonKey(name: 'privacy') + C2PrivacyLevel get privacy => throw _privateConstructorUsedError; + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double get restTime => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') + int? get strokeRate => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -69,7 +82,13 @@ abstract class $C2FullResultsCopyWith<$Res> { @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, @JsonKey(name: 'source') String source, - @JsonKey(name: 'weight_class') C2WeightClass weightClass}); + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate}); } /// @nodoc @@ -96,6 +115,12 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? workoutType = null, Object? source = null, Object? weightClass = null, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + Object? restTime = null, + Object? strokeRate = freezed, }) { return _then(_value.copyWith( id: null == id @@ -142,6 +167,30 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.weightClass : weightClass // ignore: cast_nullable_to_non_nullable as C2WeightClass, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, ) as $Val); } } @@ -165,7 +214,13 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, @JsonKey(name: 'source') String source, - @JsonKey(name: 'weight_class') C2WeightClass weightClass}); + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'stroke_rate') int? strokeRate}); } /// @nodoc @@ -190,6 +245,12 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? workoutType = null, Object? source = null, Object? weightClass = null, + Object? verified = null, + Object? ranked = null, + Object? comments = freezed, + Object? privacy = null, + Object? restTime = null, + Object? strokeRate = freezed, }) { return _then(_$C2FullResultsImpl( id: null == id @@ -236,6 +297,30 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.weightClass : weightClass // ignore: cast_nullable_to_non_nullable as C2WeightClass, + verified: null == verified + ? _value.verified + : verified // ignore: cast_nullable_to_non_nullable + as bool, + ranked: null == ranked + ? _value.ranked + : ranked // ignore: cast_nullable_to_non_nullable + as bool, + comments: freezed == comments + ? _value.comments + : comments // ignore: cast_nullable_to_non_nullable + as String?, + privacy: null == privacy + ? _value.privacy + : privacy // ignore: cast_nullable_to_non_nullable + as C2PrivacyLevel, + restTime: null == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double, + strokeRate: freezed == strokeRate + ? _value.strokeRate + : strokeRate // ignore: cast_nullable_to_non_nullable + as int?, )); } } @@ -256,7 +341,15 @@ class _$C2FullResultsImpl extends _C2FullResults { this.workoutType = C2APIWorkoutType.JustRow, @JsonKey(name: 'source') this.source = "c2logbook dart", @JsonKey(name: 'weight_class') - this.weightClass = C2WeightClass.heavyweight}) + this.weightClass = C2WeightClass.heavyweight, + @JsonKey(name: 'verified') this.verified = false, + @JsonKey(name: 'ranked') this.ranked = false, + @JsonKey(name: 'comments') this.comments, + @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + required this.restTime, + @JsonKey(name: 'stroke_rate') this.strokeRate}) : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => @@ -298,10 +391,29 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey(name: 'weight_class') final C2WeightClass weightClass; + @override + @JsonKey(name: 'verified') + final bool verified; + @override + @JsonKey(name: 'ranked') + final bool ranked; + @override + @JsonKey(name: 'comments') + final String? comments; + @override + @JsonKey(name: 'privacy') + final C2PrivacyLevel privacy; + @override + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + final double restTime; + @override + @JsonKey(name: 'stroke_rate') + final int? strokeRate; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass)'; + return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, restTime: $restTime, strokeRate: $strokeRate)'; } @override @@ -323,13 +435,40 @@ class _$C2FullResultsImpl extends _C2FullResults { other.workoutType == workoutType) && (identical(other.source, source) || other.source == source) && (identical(other.weightClass, weightClass) || - other.weightClass == weightClass)); + other.weightClass == weightClass) && + (identical(other.verified, verified) || + other.verified == verified) && + (identical(other.ranked, ranked) || other.ranked == ranked) && + (identical(other.comments, comments) || + other.comments == comments) && + (identical(other.privacy, privacy) || other.privacy == privacy) && + (identical(other.restTime, restTime) || + other.restTime == restTime) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, id, userId, date, timezone, - dateUtc, distance, type, time, workoutType, source, weightClass); + int get hashCode => Object.hash( + runtimeType, + id, + userId, + date, + timezone, + dateUtc, + distance, + type, + time, + workoutType, + source, + weightClass, + verified, + ranked, + comments, + privacy, + restTime, + strokeRate); @JsonKey(ignore: true) @override @@ -361,8 +500,16 @@ abstract class _C2FullResults extends C2FullResults { required final double time, @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType, @JsonKey(name: 'source') final String source, - @JsonKey(name: 'weight_class') - final C2WeightClass weightClass}) = _$C2FullResultsImpl; + @JsonKey(name: 'weight_class') final C2WeightClass weightClass, + @JsonKey(name: 'verified') final bool verified, + @JsonKey(name: 'ranked') final bool ranked, + @JsonKey(name: 'comments') final String? comments, + @JsonKey(name: 'privacy') final C2PrivacyLevel privacy, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + required final double restTime, + @JsonKey(name: 'stroke_rate') + final int? strokeRate}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -405,6 +552,25 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'weight_class') C2WeightClass get weightClass; @override + @JsonKey(name: 'verified') + bool get verified; + @override + @JsonKey(name: 'ranked') + bool get ranked; + @override + @JsonKey(name: 'comments') + String? get comments; + @override + @JsonKey(name: 'privacy') + C2PrivacyLevel get privacy; + @override + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double get restTime; + @override + @JsonKey(name: 'stroke_rate') + int? get strokeRate; + @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 002d4fb..6c4f57c 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -25,6 +25,14 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => weightClass: $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? C2WeightClass.heavyweight, + verified: json['verified'] as bool? ?? false, + ranked: json['ranked'] as bool? ?? false, + comments: json['comments'] as String?, + privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? + C2PrivacyLevel.private, + restTime: + const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), + strokeRate: json['stroke_rate'] as int?, ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => @@ -40,6 +48,12 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, + 'verified': instance.verified, + 'ranked': instance.ranked, + 'comments': instance.comments, + 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, + 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'stroke_rate': instance.strokeRate, }; const _$C2ResultTypeEnumMap = { @@ -74,6 +88,13 @@ const _$C2WeightClassEnumMap = { C2WeightClass.heavyweight: 'H', }; +const _$C2PrivacyLevelEnumMap = { + C2PrivacyLevel.private: 'private', + C2PrivacyLevel.partners: 'partners', + C2PrivacyLevel.logged_in: 'logged_in', + C2PrivacyLevel.everyone: 'everyone', +}; + _$C2HeartRateImpl _$$C2HeartRateImplFromJson(Map json) => _$C2HeartRateImpl( min: json['min'] as int? ?? 0, @@ -162,13 +183,6 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, }; -const _$C2PrivacyLevelEnumMap = { - C2PrivacyLevel.private: 'private', - C2PrivacyLevel.partners: 'partners', - C2PrivacyLevel.logged_in: 'logged_in', - C2PrivacyLevel.everyone: 'everyone', -}; - _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( type: json['type'] as String? ?? "time", From 9c93cb5b8268f9a43240fdfe61d8dad87e4a060f Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:52:48 -0400 Subject: [PATCH 19/25] Alright no more mr nice guy --- lib/src/types/c2_full_results.dart | 5 +- lib/src/types/c2_workout.dart | 7 +- lib/src/types/index.freezed.dart | 264 +++++++++++++++++------------ lib/src/types/index.g.dart | 17 +- 4 files changed, 167 insertions(+), 126 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 5442ea1..d0070f8 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -33,8 +33,9 @@ class C2FullResults with _$C2FullResults { @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, @JsonKey(name: 'stroke_rate') int? strokeRate, - // @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, - // @JsonKey(name: 'workout') @Default(null) C2Workout? workout, + @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'workout') @Default(null) C2Workout? workout, + @JsonKey(name: 'rest_distance') @Default(0.0) double restDistance, }) = _C2FullResults; factory C2FullResults.fromJson(Map json) => diff --git a/lib/src/types/c2_workout.dart b/lib/src/types/c2_workout.dart index 39c50c3..1dbc834 100644 --- a/lib/src/types/c2_workout.dart +++ b/lib/src/types/c2_workout.dart @@ -8,11 +8,8 @@ class C2Workout with _$C2Workout { C2Workout._(); factory C2Workout({ - @Default([]) List? intervals, - @Default([]) List? splits, - @Default(null) int? realTime, - @Default(0.0) double realDistance, - @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'intervals') @Default([]) List? intervals, + @JsonKey(name: 'splits') @Default([]) List? splits, }) = _C2Workout; factory C2Workout.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 41078cb..8b3f00d 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -58,6 +58,12 @@ mixin _$C2FullResults { double get restTime => throw _privateConstructorUsedError; @JsonKey(name: 'stroke_rate') int? get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: 'heart_rate') + C2HeartRate? get heartRate => throw _privateConstructorUsedError; + @JsonKey(name: 'workout') + C2Workout? get workout => throw _privateConstructorUsedError; + @JsonKey(name: 'rest_distance') + double get restDistance => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -88,7 +94,13 @@ abstract class $C2FullResultsCopyWith<$Res> { @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, - @JsonKey(name: 'stroke_rate') int? strokeRate}); + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, + @JsonKey(name: 'workout') C2Workout? workout, + @JsonKey(name: 'rest_distance') double restDistance}); + + $C2HeartRateCopyWith<$Res>? get heartRate; + $C2WorkoutCopyWith<$Res>? get workout; } /// @nodoc @@ -121,6 +133,9 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? privacy = null, Object? restTime = null, Object? strokeRate = freezed, + Object? heartRate = freezed, + Object? workout = freezed, + Object? restDistance = null, }) { return _then(_value.copyWith( id: null == id @@ -191,8 +206,44 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int?, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + workout: freezed == workout + ? _value.workout + : workout // ignore: cast_nullable_to_non_nullable + as C2Workout?, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as double, ) as $Val); } + + @override + @pragma('vm:prefer-inline') + $C2HeartRateCopyWith<$Res>? get heartRate { + if (_value.heartRate == null) { + return null; + } + + return $C2HeartRateCopyWith<$Res>(_value.heartRate!, (value) { + return _then(_value.copyWith(heartRate: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $C2WorkoutCopyWith<$Res>? get workout { + if (_value.workout == null) { + return null; + } + + return $C2WorkoutCopyWith<$Res>(_value.workout!, (value) { + return _then(_value.copyWith(workout: value) as $Val); + }); + } } /// @nodoc @@ -220,7 +271,15 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, - @JsonKey(name: 'stroke_rate') int? strokeRate}); + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, + @JsonKey(name: 'workout') C2Workout? workout, + @JsonKey(name: 'rest_distance') double restDistance}); + + @override + $C2HeartRateCopyWith<$Res>? get heartRate; + @override + $C2WorkoutCopyWith<$Res>? get workout; } /// @nodoc @@ -251,6 +310,9 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? privacy = null, Object? restTime = null, Object? strokeRate = freezed, + Object? heartRate = freezed, + Object? workout = freezed, + Object? restDistance = null, }) { return _then(_$C2FullResultsImpl( id: null == id @@ -321,6 +383,18 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable as int?, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + workout: freezed == workout + ? _value.workout + : workout // ignore: cast_nullable_to_non_nullable + as C2Workout?, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as double, )); } } @@ -349,7 +423,10 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required this.restTime, - @JsonKey(name: 'stroke_rate') this.strokeRate}) + @JsonKey(name: 'stroke_rate') this.strokeRate, + @JsonKey(name: 'heart_rate') this.heartRate = null, + @JsonKey(name: 'workout') this.workout = null, + @JsonKey(name: 'rest_distance') this.restDistance = 0.0}) : super._(); factory _$C2FullResultsImpl.fromJson(Map json) => @@ -410,10 +487,19 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey(name: 'stroke_rate') final int? strokeRate; + @override + @JsonKey(name: 'heart_rate') + final C2HeartRate? heartRate; + @override + @JsonKey(name: 'workout') + final C2Workout? workout; + @override + @JsonKey(name: 'rest_distance') + final double restDistance; @override String toString() { - return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, restTime: $restTime, strokeRate: $strokeRate)'; + return 'C2FullResults(id: $id, userId: $userId, date: $date, timezone: $timezone, dateUtc: $dateUtc, distance: $distance, type: $type, time: $time, workoutType: $workoutType, source: $source, weightClass: $weightClass, verified: $verified, ranked: $ranked, comments: $comments, privacy: $privacy, restTime: $restTime, strokeRate: $strokeRate, heartRate: $heartRate, workout: $workout, restDistance: $restDistance)'; } @override @@ -445,30 +531,39 @@ class _$C2FullResultsImpl extends _C2FullResults { (identical(other.restTime, restTime) || other.restTime == restTime) && (identical(other.strokeRate, strokeRate) || - other.strokeRate == strokeRate)); + other.strokeRate == strokeRate) && + (identical(other.heartRate, heartRate) || + other.heartRate == heartRate) && + (identical(other.workout, workout) || other.workout == workout) && + (identical(other.restDistance, restDistance) || + other.restDistance == restDistance)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - id, - userId, - date, - timezone, - dateUtc, - distance, - type, - time, - workoutType, - source, - weightClass, - verified, - ranked, - comments, - privacy, - restTime, - strokeRate); + int get hashCode => Object.hashAll([ + runtimeType, + id, + userId, + date, + timezone, + dateUtc, + distance, + type, + time, + workoutType, + source, + weightClass, + verified, + ranked, + comments, + privacy, + restTime, + strokeRate, + heartRate, + workout, + restDistance + ]); @JsonKey(ignore: true) @override @@ -508,8 +603,11 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required final double restTime, - @JsonKey(name: 'stroke_rate') - final int? strokeRate}) = _$C2FullResultsImpl; + @JsonKey(name: 'stroke_rate') final int? strokeRate, + @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate, + @JsonKey(name: 'workout') final C2Workout? workout, + @JsonKey(name: 'rest_distance') + final double restDistance}) = _$C2FullResultsImpl; _C2FullResults._() : super._(); factory _C2FullResults.fromJson(Map json) = @@ -571,6 +669,15 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'stroke_rate') int? get strokeRate; @override + @JsonKey(name: 'heart_rate') + C2HeartRate? get heartRate; + @override + @JsonKey(name: 'workout') + C2Workout? get workout; + @override + @JsonKey(name: 'rest_distance') + double get restDistance; + @override @JsonKey(ignore: true) _$$C2FullResultsImplCopyWith<_$C2FullResultsImpl> get copyWith => throw _privateConstructorUsedError; @@ -2348,12 +2455,10 @@ C2Workout _$C2WorkoutFromJson(Map json) { /// @nodoc mixin _$C2Workout { + @JsonKey(name: 'intervals') List? get intervals => throw _privateConstructorUsedError; + @JsonKey(name: 'splits') List? get splits => throw _privateConstructorUsedError; - int? get realTime => throw _privateConstructorUsedError; - double get realDistance => throw _privateConstructorUsedError; - @DecimalIntConverter.tenths() - double get restTime => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -2367,11 +2472,8 @@ abstract class $C2WorkoutCopyWith<$Res> { _$C2WorkoutCopyWithImpl<$Res, C2Workout>; @useResult $Res call( - {List? intervals, - List? splits, - int? realTime, - double realDistance, - @DecimalIntConverter.tenths() double restTime}); + {@JsonKey(name: 'intervals') List? intervals, + @JsonKey(name: 'splits') List? splits}); } /// @nodoc @@ -2389,9 +2491,6 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> $Res call({ Object? intervals = freezed, Object? splits = freezed, - Object? realTime = freezed, - Object? realDistance = null, - Object? restTime = null, }) { return _then(_value.copyWith( intervals: freezed == intervals @@ -2402,18 +2501,6 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> ? _value.splits : splits // ignore: cast_nullable_to_non_nullable as List?, - realTime: freezed == realTime - ? _value.realTime - : realTime // ignore: cast_nullable_to_non_nullable - as int?, - realDistance: null == realDistance - ? _value.realDistance - : realDistance // ignore: cast_nullable_to_non_nullable - as double, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, ) as $Val); } } @@ -2427,11 +2514,8 @@ abstract class _$$C2WorkoutImplCopyWith<$Res> @override @useResult $Res call( - {List? intervals, - List? splits, - int? realTime, - double realDistance, - @DecimalIntConverter.tenths() double restTime}); + {@JsonKey(name: 'intervals') List? intervals, + @JsonKey(name: 'splits') List? splits}); } /// @nodoc @@ -2447,9 +2531,6 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> $Res call({ Object? intervals = freezed, Object? splits = freezed, - Object? realTime = freezed, - Object? realDistance = null, - Object? restTime = null, }) { return _then(_$C2WorkoutImpl( intervals: freezed == intervals @@ -2460,18 +2541,6 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> ? _value._splits : splits // ignore: cast_nullable_to_non_nullable as List?, - realTime: freezed == realTime - ? _value.realTime - : realTime // ignore: cast_nullable_to_non_nullable - as int?, - realDistance: null == realDistance - ? _value.realDistance - : realDistance // ignore: cast_nullable_to_non_nullable - as double, - restTime: null == restTime - ? _value.restTime - : restTime // ignore: cast_nullable_to_non_nullable - as double, )); } } @@ -2480,11 +2549,10 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> @JsonSerializable() class _$C2WorkoutImpl extends _C2Workout { _$C2WorkoutImpl( - {final List? intervals = const [], - final List? splits = const [], - this.realTime = null, - this.realDistance = 0.0, - @DecimalIntConverter.tenths() required this.restTime}) + {@JsonKey(name: 'intervals') + final List? intervals = const [], + @JsonKey(name: 'splits') + final List? splits = const []}) : _intervals = intervals, _splits = splits, super._(); @@ -2494,7 +2562,7 @@ class _$C2WorkoutImpl extends _C2Workout { final List? _intervals; @override - @JsonKey() + @JsonKey(name: 'intervals') List? get intervals { final value = _intervals; if (value == null) return null; @@ -2505,7 +2573,7 @@ class _$C2WorkoutImpl extends _C2Workout { final List? _splits; @override - @JsonKey() + @JsonKey(name: 'splits') List? get splits { final value = _splits; if (value == null) return null; @@ -2514,19 +2582,9 @@ class _$C2WorkoutImpl extends _C2Workout { return EqualUnmodifiableListView(value); } - @override - @JsonKey() - final int? realTime; - @override - @JsonKey() - final double realDistance; - @override - @DecimalIntConverter.tenths() - final double restTime; - @override String toString() { - return 'C2Workout(intervals: $intervals, splits: $splits, realTime: $realTime, realDistance: $realDistance, restTime: $restTime)'; + return 'C2Workout(intervals: $intervals, splits: $splits)'; } @override @@ -2536,13 +2594,7 @@ class _$C2WorkoutImpl extends _C2Workout { other is _$C2WorkoutImpl && const DeepCollectionEquality() .equals(other._intervals, _intervals) && - const DeepCollectionEquality().equals(other._splits, _splits) && - (identical(other.realTime, realTime) || - other.realTime == realTime) && - (identical(other.realDistance, realDistance) || - other.realDistance == realDistance) && - (identical(other.restTime, restTime) || - other.restTime == restTime)); + const DeepCollectionEquality().equals(other._splits, _splits)); } @JsonKey(ignore: true) @@ -2550,10 +2602,7 @@ class _$C2WorkoutImpl extends _C2Workout { int get hashCode => Object.hash( runtimeType, const DeepCollectionEquality().hash(_intervals), - const DeepCollectionEquality().hash(_splits), - realTime, - realDistance, - restTime); + const DeepCollectionEquality().hash(_splits)); @JsonKey(ignore: true) @override @@ -2571,29 +2620,20 @@ class _$C2WorkoutImpl extends _C2Workout { abstract class _C2Workout extends C2Workout { factory _C2Workout( - {final List? intervals, - final List? splits, - final int? realTime, - final double realDistance, - @DecimalIntConverter.tenths() required final double restTime}) = - _$C2WorkoutImpl; + {@JsonKey(name: 'intervals') final List? intervals, + @JsonKey(name: 'splits') final List? splits}) = _$C2WorkoutImpl; _C2Workout._() : super._(); factory _C2Workout.fromJson(Map json) = _$C2WorkoutImpl.fromJson; @override + @JsonKey(name: 'intervals') List? get intervals; @override + @JsonKey(name: 'splits') List? get splits; @override - int? get realTime; - @override - double get realDistance; - @override - @DecimalIntConverter.tenths() - double get restTime; - @override @JsonKey(ignore: true) _$$C2WorkoutImplCopyWith<_$C2WorkoutImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 6c4f57c..f68ccac 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -33,6 +33,13 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => restTime: const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), strokeRate: json['stroke_rate'] as int?, + heartRate: json['heart_rate'] == null + ? null + : C2HeartRate.fromJson(json['heart_rate'] as Map), + workout: json['workout'] == null + ? null + : C2Workout.fromJson(json['workout'] as Map), + restDistance: (json['rest_distance'] as num?)?.toDouble() ?? 0.0, ); Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => @@ -54,6 +61,9 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), + 'workout': instance.workout?.toJson(), + 'rest_distance': instance.restDistance, }; const _$C2ResultTypeEnumMap = { @@ -256,17 +266,10 @@ _$C2WorkoutImpl _$$C2WorkoutImplFromJson(Map json) => ?.map((e) => C2Splits.fromJson(e as Map)) .toList() ?? const [], - realTime: json['realTime'] as int? ?? null, - realDistance: (json['realDistance'] as num?)?.toDouble() ?? 0.0, - restTime: - const DecimalIntConverter.tenths().fromJson(json['restTime'] as int), ); Map _$$C2WorkoutImplToJson(_$C2WorkoutImpl instance) => { 'intervals': instance.intervals?.map((e) => e.toJson()).toList(), 'splits': instance.splits?.map((e) => e.toJson()).toList(), - 'realTime': instance.realTime, - 'realDistance': instance.realDistance, - 'restTime': const DecimalIntConverter.tenths().toJson(instance.restTime), }; From 6371c93bd9a7ca59e82fa2c4ad2daab8e2c804bc Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:26:17 -0400 Subject: [PATCH 20/25] Alright no more mr nice guy --- lib/src/types/c2_intervals.dart | 2 +- lib/src/types/c2_splits.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/src/types/c2_intervals.dart b/lib/src/types/c2_intervals.dart index 6858793..a4c43ca 100644 --- a/lib/src/types/c2_intervals.dart +++ b/lib/src/types/c2_intervals.dart @@ -8,7 +8,7 @@ class C2Intervals with _$C2Intervals { C2Intervals._(); factory C2Intervals({ - @JsonKey(name: 'id') @Default("type") String type, + @JsonKey(name: 'id') @Default("type") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, @JsonKey(name: 'distance') @Default(0.0) double distance, diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index d74ac94..2b65e5f 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -8,7 +8,7 @@ class C2Splits with _$C2Splits { C2Splits._(); factory C2Splits({ - @JsonKey(name: 'type') @Default("time") String type, + @JsonKey(name: 'type') @Default("time") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, @JsonKey(name: 'distance') @Default(0.0) double distance, @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, From a6a124a751c724426cae4a0d3196d472f99dc4ab Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:28:15 -0400 Subject: [PATCH 21/25] Alright no more mr nice guy --- lib/src/types/index.freezed.dart | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 8b3f00d..2d42f47 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -904,7 +904,7 @@ C2Intervals _$C2IntervalsFromJson(Map json) { /// @nodoc mixin _$C2Intervals { @JsonKey(name: 'id') - String get type => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; @@ -933,7 +933,7 @@ abstract class $C2IntervalsCopyWith<$Res> { _$C2IntervalsCopyWithImpl<$Res, C2Intervals>; @useResult $Res call( - {@JsonKey(name: 'id') String type, + {@JsonKey(name: 'id') String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, @JsonKey(name: 'distance') double distance, @@ -957,7 +957,7 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = null, + Object? type = freezed, Object? time = null, Object? restTime = null, Object? distance = null, @@ -966,10 +966,10 @@ class _$C2IntervalsCopyWithImpl<$Res, $Val extends C2Intervals> Object? heartRate = freezed, }) { return _then(_value.copyWith( - type: null == type + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1019,7 +1019,7 @@ abstract class _$$C2IntervalsImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'id') String type, + {@JsonKey(name: 'id') String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, @JsonKey(name: 'distance') double distance, @@ -1042,7 +1042,7 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = null, + Object? type = freezed, Object? time = null, Object? restTime = null, Object? distance = null, @@ -1051,10 +1051,10 @@ class __$$C2IntervalsImplCopyWithImpl<$Res> Object? heartRate = freezed, }) { return _then(_$C2IntervalsImpl( - type: null == type + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1103,7 +1103,7 @@ class _$C2IntervalsImpl extends _C2Intervals { @override @JsonKey(name: 'id') - final String type; + final String? type; @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() @@ -1170,7 +1170,7 @@ class _$C2IntervalsImpl extends _C2Intervals { abstract class _C2Intervals extends C2Intervals { factory _C2Intervals( - {@JsonKey(name: 'id') final String type, + {@JsonKey(name: 'id') final String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required final double time, @@ -1189,7 +1189,7 @@ abstract class _C2Intervals extends C2Intervals { @override @JsonKey(name: 'id') - String get type; + String? get type; @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() @@ -1709,7 +1709,7 @@ C2Splits _$C2SplitsFromJson(Map json) { /// @nodoc mixin _$C2Splits { @JsonKey(name: 'type') - String get type => throw _privateConstructorUsedError; + String? get type => throw _privateConstructorUsedError; @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; @@ -1734,7 +1734,7 @@ abstract class $C2SplitsCopyWith<$Res> { _$C2SplitsCopyWithImpl<$Res, C2Splits>; @useResult $Res call( - {@JsonKey(name: 'type') String type, + {@JsonKey(name: 'type') String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @@ -1757,7 +1757,7 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = null, + Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1765,10 +1765,10 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> Object? heartRate = freezed, }) { return _then(_value.copyWith( - type: null == type + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1814,7 +1814,7 @@ abstract class _$$C2SplitsImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'type') String type, + {@JsonKey(name: 'type') String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @@ -1836,7 +1836,7 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = null, + Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1844,10 +1844,10 @@ class __$$C2SplitsImplCopyWithImpl<$Res> Object? heartRate = freezed, }) { return _then(_$C2SplitsImpl( - type: null == type + type: freezed == type ? _value.type : type // ignore: cast_nullable_to_non_nullable - as String, + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1889,7 +1889,7 @@ class _$C2SplitsImpl extends _C2Splits { @override @JsonKey(name: 'type') - final String type; + final String? type; @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() @@ -1950,7 +1950,7 @@ class _$C2SplitsImpl extends _C2Splits { abstract class _C2Splits extends C2Splits { factory _C2Splits( - {@JsonKey(name: 'type') final String type, + {@JsonKey(name: 'type') final String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required final double time, @@ -1966,7 +1966,7 @@ abstract class _C2Splits extends C2Splits { @override @JsonKey(name: 'type') - String get type; + String? get type; @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() From 8c437a3c0f461749245074cbe455213c089fb381 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:38:33 -0400 Subject: [PATCH 22/25] Alright no more mr nice guy --- lib/src/types/c2_splits.dart | 2 +- lib/src/types/index.freezed.dart | 39 ++++++++------------------------ lib/src/types/index.g.dart | 2 -- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index 2b65e5f..0e8046c 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -8,7 +8,7 @@ class C2Splits with _$C2Splits { C2Splits._(); factory C2Splits({ - @JsonKey(name: 'type') @Default("time") String? type, + // @JsonKey(name: 'type') @Default("time") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, @JsonKey(name: 'distance') @Default(0.0) double distance, @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 2d42f47..0080559 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -1708,8 +1708,7 @@ C2Splits _$C2SplitsFromJson(Map json) { /// @nodoc mixin _$C2Splits { - @JsonKey(name: 'type') - String? get type => throw _privateConstructorUsedError; +// @JsonKey(name: 'type') @Default("time") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; @@ -1734,8 +1733,7 @@ abstract class $C2SplitsCopyWith<$Res> { _$C2SplitsCopyWithImpl<$Res, C2Splits>; @useResult $Res call( - {@JsonKey(name: 'type') String? type, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + {@JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @JsonKey(name: 'stroke_rate') int strokeRate, @@ -1757,7 +1755,6 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1765,10 +1762,6 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> Object? heartRate = freezed, }) { return _then(_value.copyWith( - type: freezed == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1814,8 +1807,7 @@ abstract class _$$C2SplitsImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'type') String? type, - @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + {@JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @JsonKey(name: 'stroke_rate') int strokeRate, @@ -1836,7 +1828,6 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ - Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1844,10 +1835,6 @@ class __$$C2SplitsImplCopyWithImpl<$Res> Object? heartRate = freezed, }) { return _then(_$C2SplitsImpl( - type: freezed == type - ? _value.type - : type // ignore: cast_nullable_to_non_nullable - as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1876,8 +1863,7 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2SplitsImpl extends _C2Splits { _$C2SplitsImpl( - {@JsonKey(name: 'type') this.type = "time", - @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + {@JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, @JsonKey(name: 'distance') this.distance = 0.0, @JsonKey(name: 'calories_total') this.caloriesTotal = 0, @JsonKey(name: 'stroke_rate') this.strokeRate = 0, @@ -1887,9 +1873,7 @@ class _$C2SplitsImpl extends _C2Splits { factory _$C2SplitsImpl.fromJson(Map json) => _$$C2SplitsImplFromJson(json); - @override - @JsonKey(name: 'type') - final String? type; +// @JsonKey(name: 'type') @Default("time") String? type, @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() @@ -1909,7 +1893,7 @@ class _$C2SplitsImpl extends _C2Splits { @override String toString() { - return 'C2Splits(type: $type, time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; + return 'C2Splits(time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; } @override @@ -1917,7 +1901,6 @@ class _$C2SplitsImpl extends _C2Splits { return identical(this, other) || (other.runtimeType == runtimeType && other is _$C2SplitsImpl && - (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && (identical(other.distance, distance) || other.distance == distance) && @@ -1932,7 +1915,7 @@ class _$C2SplitsImpl extends _C2Splits { @JsonKey(ignore: true) @override int get hashCode => Object.hash( - runtimeType, type, time, distance, caloriesTotal, strokeRate, heartRate); + runtimeType, time, distance, caloriesTotal, strokeRate, heartRate); @JsonKey(ignore: true) @override @@ -1950,8 +1933,7 @@ class _$C2SplitsImpl extends _C2Splits { abstract class _C2Splits extends C2Splits { factory _C2Splits( - {@JsonKey(name: 'type') final String? type, - @JsonKey(name: 'time') + {@JsonKey(name: 'time') @DecimalIntConverter.tenths() required final double time, @JsonKey(name: 'distance') final double distance, @@ -1964,10 +1946,7 @@ abstract class _C2Splits extends C2Splits { factory _C2Splits.fromJson(Map json) = _$C2SplitsImpl.fromJson; - @override - @JsonKey(name: 'type') - String? get type; - @override + @override // @JsonKey(name: 'type') @Default("time") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index f68ccac..81365a9 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -195,7 +195,6 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( - type: json['type'] as String? ?? "time", time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), distance: (json['distance'] as num?)?.toDouble() ?? 0.0, caloriesTotal: json['calories_total'] as int? ?? 0, @@ -207,7 +206,6 @@ _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => { - 'type': instance.type, 'time': const DecimalIntConverter.tenths().toJson(instance.time), 'distance': instance.distance, 'calories_total': instance.caloriesTotal, From 847a587c5af2bd5e2b00535d2422389b25f0e1f0 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:42:02 -0400 Subject: [PATCH 23/25] Alright no more mr nice guy --- lib/src/types/c2_splits.dart | 2 +- lib/src/types/c2_workout.dart | 2 +- lib/src/types/index.freezed.dart | 93 ++++++++++++++------------------ lib/src/types/index.g.dart | 7 +-- 4 files changed, 43 insertions(+), 61 deletions(-) diff --git a/lib/src/types/c2_splits.dart b/lib/src/types/c2_splits.dart index 0e8046c..2b65e5f 100644 --- a/lib/src/types/c2_splits.dart +++ b/lib/src/types/c2_splits.dart @@ -8,7 +8,7 @@ class C2Splits with _$C2Splits { C2Splits._(); factory C2Splits({ - // @JsonKey(name: 'type') @Default("time") String? type, + @JsonKey(name: 'type') @Default("time") String? type, @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, @JsonKey(name: 'distance') @Default(0.0) double distance, @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, diff --git a/lib/src/types/c2_workout.dart b/lib/src/types/c2_workout.dart index 1dbc834..a1aaf8e 100644 --- a/lib/src/types/c2_workout.dart +++ b/lib/src/types/c2_workout.dart @@ -9,7 +9,7 @@ class C2Workout with _$C2Workout { factory C2Workout({ @JsonKey(name: 'intervals') @Default([]) List? intervals, - @JsonKey(name: 'splits') @Default([]) List? splits, + // @JsonKey(name: 'splits') @Default([]) List? splits, }) = _C2Workout; factory C2Workout.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 0080559..beb821e 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -1708,7 +1708,8 @@ C2Splits _$C2SplitsFromJson(Map json) { /// @nodoc mixin _$C2Splits { -// @JsonKey(name: 'type') @Default("time") String? type, + @JsonKey(name: 'type') + String? get type => throw _privateConstructorUsedError; @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; @@ -1733,7 +1734,8 @@ abstract class $C2SplitsCopyWith<$Res> { _$C2SplitsCopyWithImpl<$Res, C2Splits>; @useResult $Res call( - {@JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + {@JsonKey(name: 'type') String? type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @JsonKey(name: 'stroke_rate') int strokeRate, @@ -1755,6 +1757,7 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> @pragma('vm:prefer-inline') @override $Res call({ + Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1762,6 +1765,10 @@ class _$C2SplitsCopyWithImpl<$Res, $Val extends C2Splits> Object? heartRate = freezed, }) { return _then(_value.copyWith( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1807,7 +1814,8 @@ abstract class _$$C2SplitsImplCopyWith<$Res> @override @useResult $Res call( - {@JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + {@JsonKey(name: 'type') String? type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, @JsonKey(name: 'distance') double distance, @JsonKey(name: 'calories_total') int caloriesTotal, @JsonKey(name: 'stroke_rate') int strokeRate, @@ -1828,6 +1836,7 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @pragma('vm:prefer-inline') @override $Res call({ + Object? type = freezed, Object? time = null, Object? distance = null, Object? caloriesTotal = null, @@ -1835,6 +1844,10 @@ class __$$C2SplitsImplCopyWithImpl<$Res> Object? heartRate = freezed, }) { return _then(_$C2SplitsImpl( + type: freezed == type + ? _value.type + : type // ignore: cast_nullable_to_non_nullable + as String?, time: null == time ? _value.time : time // ignore: cast_nullable_to_non_nullable @@ -1863,7 +1876,8 @@ class __$$C2SplitsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2SplitsImpl extends _C2Splits { _$C2SplitsImpl( - {@JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + {@JsonKey(name: 'type') this.type = "time", + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, @JsonKey(name: 'distance') this.distance = 0.0, @JsonKey(name: 'calories_total') this.caloriesTotal = 0, @JsonKey(name: 'stroke_rate') this.strokeRate = 0, @@ -1873,7 +1887,9 @@ class _$C2SplitsImpl extends _C2Splits { factory _$C2SplitsImpl.fromJson(Map json) => _$$C2SplitsImplFromJson(json); -// @JsonKey(name: 'type') @Default("time") String? type, + @override + @JsonKey(name: 'type') + final String? type; @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() @@ -1893,7 +1909,7 @@ class _$C2SplitsImpl extends _C2Splits { @override String toString() { - return 'C2Splits(time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; + return 'C2Splits(type: $type, time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate)'; } @override @@ -1901,6 +1917,7 @@ class _$C2SplitsImpl extends _C2Splits { return identical(this, other) || (other.runtimeType == runtimeType && other is _$C2SplitsImpl && + (identical(other.type, type) || other.type == type) && (identical(other.time, time) || other.time == time) && (identical(other.distance, distance) || other.distance == distance) && @@ -1915,7 +1932,7 @@ class _$C2SplitsImpl extends _C2Splits { @JsonKey(ignore: true) @override int get hashCode => Object.hash( - runtimeType, time, distance, caloriesTotal, strokeRate, heartRate); + runtimeType, type, time, distance, caloriesTotal, strokeRate, heartRate); @JsonKey(ignore: true) @override @@ -1933,7 +1950,8 @@ class _$C2SplitsImpl extends _C2Splits { abstract class _C2Splits extends C2Splits { factory _C2Splits( - {@JsonKey(name: 'time') + {@JsonKey(name: 'type') final String? type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required final double time, @JsonKey(name: 'distance') final double distance, @@ -1946,7 +1964,10 @@ abstract class _C2Splits extends C2Splits { factory _C2Splits.fromJson(Map json) = _$C2SplitsImpl.fromJson; - @override // @JsonKey(name: 'type') @Default("time") String? type, + @override + @JsonKey(name: 'type') + String? get type; + @override @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; @@ -2436,8 +2457,6 @@ C2Workout _$C2WorkoutFromJson(Map json) { mixin _$C2Workout { @JsonKey(name: 'intervals') List? get intervals => throw _privateConstructorUsedError; - @JsonKey(name: 'splits') - List? get splits => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -2450,9 +2469,7 @@ abstract class $C2WorkoutCopyWith<$Res> { factory $C2WorkoutCopyWith(C2Workout value, $Res Function(C2Workout) then) = _$C2WorkoutCopyWithImpl<$Res, C2Workout>; @useResult - $Res call( - {@JsonKey(name: 'intervals') List? intervals, - @JsonKey(name: 'splits') List? splits}); + $Res call({@JsonKey(name: 'intervals') List? intervals}); } /// @nodoc @@ -2469,17 +2486,12 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> @override $Res call({ Object? intervals = freezed, - Object? splits = freezed, }) { return _then(_value.copyWith( intervals: freezed == intervals ? _value.intervals : intervals // ignore: cast_nullable_to_non_nullable as List?, - splits: freezed == splits - ? _value.splits - : splits // ignore: cast_nullable_to_non_nullable - as List?, ) as $Val); } } @@ -2492,9 +2504,7 @@ abstract class _$$C2WorkoutImplCopyWith<$Res> __$$C2WorkoutImplCopyWithImpl<$Res>; @override @useResult - $Res call( - {@JsonKey(name: 'intervals') List? intervals, - @JsonKey(name: 'splits') List? splits}); + $Res call({@JsonKey(name: 'intervals') List? intervals}); } /// @nodoc @@ -2509,17 +2519,12 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> @override $Res call({ Object? intervals = freezed, - Object? splits = freezed, }) { return _then(_$C2WorkoutImpl( intervals: freezed == intervals ? _value._intervals : intervals // ignore: cast_nullable_to_non_nullable as List?, - splits: freezed == splits - ? _value._splits - : splits // ignore: cast_nullable_to_non_nullable - as List?, )); } } @@ -2529,11 +2534,8 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> class _$C2WorkoutImpl extends _C2Workout { _$C2WorkoutImpl( {@JsonKey(name: 'intervals') - final List? intervals = const [], - @JsonKey(name: 'splits') - final List? splits = const []}) + final List? intervals = const []}) : _intervals = intervals, - _splits = splits, super._(); factory _$C2WorkoutImpl.fromJson(Map json) => @@ -2550,20 +2552,9 @@ class _$C2WorkoutImpl extends _C2Workout { return EqualUnmodifiableListView(value); } - final List? _splits; - @override - @JsonKey(name: 'splits') - List? get splits { - final value = _splits; - if (value == null) return null; - if (_splits is EqualUnmodifiableListView) return _splits; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(value); - } - @override String toString() { - return 'C2Workout(intervals: $intervals, splits: $splits)'; + return 'C2Workout(intervals: $intervals)'; } @override @@ -2572,16 +2563,13 @@ class _$C2WorkoutImpl extends _C2Workout { (other.runtimeType == runtimeType && other is _$C2WorkoutImpl && const DeepCollectionEquality() - .equals(other._intervals, _intervals) && - const DeepCollectionEquality().equals(other._splits, _splits)); + .equals(other._intervals, _intervals)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash( - runtimeType, - const DeepCollectionEquality().hash(_intervals), - const DeepCollectionEquality().hash(_splits)); + int get hashCode => + Object.hash(runtimeType, const DeepCollectionEquality().hash(_intervals)); @JsonKey(ignore: true) @override @@ -2599,8 +2587,8 @@ class _$C2WorkoutImpl extends _C2Workout { abstract class _C2Workout extends C2Workout { factory _C2Workout( - {@JsonKey(name: 'intervals') final List? intervals, - @JsonKey(name: 'splits') final List? splits}) = _$C2WorkoutImpl; + {@JsonKey(name: 'intervals') final List? intervals}) = + _$C2WorkoutImpl; _C2Workout._() : super._(); factory _C2Workout.fromJson(Map json) = @@ -2610,9 +2598,6 @@ abstract class _C2Workout extends C2Workout { @JsonKey(name: 'intervals') List? get intervals; @override - @JsonKey(name: 'splits') - List? get splits; - @override @JsonKey(ignore: true) _$$C2WorkoutImplCopyWith<_$C2WorkoutImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 81365a9..070f60b 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -195,6 +195,7 @@ Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => _$C2SplitsImpl( + type: json['type'] as String? ?? "time", time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), distance: (json['distance'] as num?)?.toDouble() ?? 0.0, caloriesTotal: json['calories_total'] as int? ?? 0, @@ -206,6 +207,7 @@ _$C2SplitsImpl _$$C2SplitsImplFromJson(Map json) => Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => { + 'type': instance.type, 'time': const DecimalIntConverter.tenths().toJson(instance.time), 'distance': instance.distance, 'calories_total': instance.caloriesTotal, @@ -260,14 +262,9 @@ _$C2WorkoutImpl _$$C2WorkoutImplFromJson(Map json) => ?.map((e) => C2Intervals.fromJson(e as Map)) .toList() ?? const [], - splits: (json['splits'] as List?) - ?.map((e) => C2Splits.fromJson(e as Map)) - .toList() ?? - const [], ); Map _$$C2WorkoutImplToJson(_$C2WorkoutImpl instance) => { 'intervals': instance.intervals?.map((e) => e.toJson()).toList(), - 'splits': instance.splits?.map((e) => e.toJson()).toList(), }; From 81820c0f78d6c5a8a3b5709436b13899e254dcd8 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Tue, 12 Mar 2024 14:46:36 -0400 Subject: [PATCH 24/25] Alright no more mr nice guy --- lib/src/types/c2_full_results.dart | 2 +- lib/src/types/c2_workout.dart | 2 +- lib/src/types/index.freezed.dart | 86 +++++++++++++++++++++--------- lib/src/types/index.g.dart | 24 +++++++-- 4 files changed, 85 insertions(+), 29 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index d0070f8..0e32fcd 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -31,7 +31,7 @@ class C2FullResults with _$C2FullResults { @JsonKey(name: 'ranked') @Default(false) bool ranked, @JsonKey(name: 'comments')String? comments, @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() required double restTime, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double? restTime, @JsonKey(name: 'stroke_rate') int? strokeRate, @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, @JsonKey(name: 'workout') @Default(null) C2Workout? workout, diff --git a/lib/src/types/c2_workout.dart b/lib/src/types/c2_workout.dart index a1aaf8e..1dbc834 100644 --- a/lib/src/types/c2_workout.dart +++ b/lib/src/types/c2_workout.dart @@ -9,7 +9,7 @@ class C2Workout with _$C2Workout { factory C2Workout({ @JsonKey(name: 'intervals') @Default([]) List? intervals, - // @JsonKey(name: 'splits') @Default([]) List? splits, + @JsonKey(name: 'splits') @Default([]) List? splits, }) = _C2Workout; factory C2Workout.fromJson(Map json) => diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index beb821e..2ef6191 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -55,7 +55,7 @@ mixin _$C2FullResults { C2PrivacyLevel get privacy => throw _privateConstructorUsedError; @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() - double get restTime => throw _privateConstructorUsedError; + double? get restTime => throw _privateConstructorUsedError; @JsonKey(name: 'stroke_rate') int? get strokeRate => throw _privateConstructorUsedError; @JsonKey(name: 'heart_rate') @@ -93,7 +93,9 @@ abstract class $C2FullResultsCopyWith<$Res> { @JsonKey(name: 'ranked') bool ranked, @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? restTime, @JsonKey(name: 'stroke_rate') int? strokeRate, @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, @JsonKey(name: 'workout') C2Workout? workout, @@ -131,7 +133,7 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> Object? ranked = null, Object? comments = freezed, Object? privacy = null, - Object? restTime = null, + Object? restTime = freezed, Object? strokeRate = freezed, Object? heartRate = freezed, Object? workout = freezed, @@ -198,10 +200,10 @@ class _$C2FullResultsCopyWithImpl<$Res, $Val extends C2FullResults> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, - restTime: null == restTime + restTime: freezed == restTime ? _value.restTime : restTime // ignore: cast_nullable_to_non_nullable - as double, + as double?, strokeRate: freezed == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable @@ -270,7 +272,9 @@ abstract class _$$C2FullResultsImplCopyWith<$Res> @JsonKey(name: 'ranked') bool ranked, @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') C2PrivacyLevel privacy, - @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double restTime, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? restTime, @JsonKey(name: 'stroke_rate') int? strokeRate, @JsonKey(name: 'heart_rate') C2HeartRate? heartRate, @JsonKey(name: 'workout') C2Workout? workout, @@ -308,7 +312,7 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> Object? ranked = null, Object? comments = freezed, Object? privacy = null, - Object? restTime = null, + Object? restTime = freezed, Object? strokeRate = freezed, Object? heartRate = freezed, Object? workout = freezed, @@ -375,10 +379,10 @@ class __$$C2FullResultsImplCopyWithImpl<$Res> ? _value.privacy : privacy // ignore: cast_nullable_to_non_nullable as C2PrivacyLevel, - restTime: null == restTime + restTime: freezed == restTime ? _value.restTime : restTime // ignore: cast_nullable_to_non_nullable - as double, + as double?, strokeRate: freezed == strokeRate ? _value.strokeRate : strokeRate // ignore: cast_nullable_to_non_nullable @@ -420,9 +424,7 @@ class _$C2FullResultsImpl extends _C2FullResults { @JsonKey(name: 'ranked') this.ranked = false, @JsonKey(name: 'comments') this.comments, @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private, - @JsonKey(name: 'rest_time') - @DecimalIntConverter.tenths() - required this.restTime, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() this.restTime, @JsonKey(name: 'stroke_rate') this.strokeRate, @JsonKey(name: 'heart_rate') this.heartRate = null, @JsonKey(name: 'workout') this.workout = null, @@ -483,7 +485,7 @@ class _$C2FullResultsImpl extends _C2FullResults { @override @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() - final double restTime; + final double? restTime; @override @JsonKey(name: 'stroke_rate') final int? strokeRate; @@ -602,7 +604,7 @@ abstract class _C2FullResults extends C2FullResults { @JsonKey(name: 'privacy') final C2PrivacyLevel privacy, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() - required final double restTime, + final double? restTime, @JsonKey(name: 'stroke_rate') final int? strokeRate, @JsonKey(name: 'heart_rate') final C2HeartRate? heartRate, @JsonKey(name: 'workout') final C2Workout? workout, @@ -664,7 +666,7 @@ abstract class _C2FullResults extends C2FullResults { @override @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() - double get restTime; + double? get restTime; @override @JsonKey(name: 'stroke_rate') int? get strokeRate; @@ -2457,6 +2459,8 @@ C2Workout _$C2WorkoutFromJson(Map json) { mixin _$C2Workout { @JsonKey(name: 'intervals') List? get intervals => throw _privateConstructorUsedError; + @JsonKey(name: 'splits') + List? get splits => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -2469,7 +2473,9 @@ abstract class $C2WorkoutCopyWith<$Res> { factory $C2WorkoutCopyWith(C2Workout value, $Res Function(C2Workout) then) = _$C2WorkoutCopyWithImpl<$Res, C2Workout>; @useResult - $Res call({@JsonKey(name: 'intervals') List? intervals}); + $Res call( + {@JsonKey(name: 'intervals') List? intervals, + @JsonKey(name: 'splits') List? splits}); } /// @nodoc @@ -2486,12 +2492,17 @@ class _$C2WorkoutCopyWithImpl<$Res, $Val extends C2Workout> @override $Res call({ Object? intervals = freezed, + Object? splits = freezed, }) { return _then(_value.copyWith( intervals: freezed == intervals ? _value.intervals : intervals // ignore: cast_nullable_to_non_nullable as List?, + splits: freezed == splits + ? _value.splits + : splits // ignore: cast_nullable_to_non_nullable + as List?, ) as $Val); } } @@ -2504,7 +2515,9 @@ abstract class _$$C2WorkoutImplCopyWith<$Res> __$$C2WorkoutImplCopyWithImpl<$Res>; @override @useResult - $Res call({@JsonKey(name: 'intervals') List? intervals}); + $Res call( + {@JsonKey(name: 'intervals') List? intervals, + @JsonKey(name: 'splits') List? splits}); } /// @nodoc @@ -2519,12 +2532,17 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> @override $Res call({ Object? intervals = freezed, + Object? splits = freezed, }) { return _then(_$C2WorkoutImpl( intervals: freezed == intervals ? _value._intervals : intervals // ignore: cast_nullable_to_non_nullable as List?, + splits: freezed == splits + ? _value._splits + : splits // ignore: cast_nullable_to_non_nullable + as List?, )); } } @@ -2534,8 +2552,11 @@ class __$$C2WorkoutImplCopyWithImpl<$Res> class _$C2WorkoutImpl extends _C2Workout { _$C2WorkoutImpl( {@JsonKey(name: 'intervals') - final List? intervals = const []}) + final List? intervals = const [], + @JsonKey(name: 'splits') + final List? splits = const []}) : _intervals = intervals, + _splits = splits, super._(); factory _$C2WorkoutImpl.fromJson(Map json) => @@ -2552,9 +2573,20 @@ class _$C2WorkoutImpl extends _C2Workout { return EqualUnmodifiableListView(value); } + final List? _splits; + @override + @JsonKey(name: 'splits') + List? get splits { + final value = _splits; + if (value == null) return null; + if (_splits is EqualUnmodifiableListView) return _splits; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(value); + } + @override String toString() { - return 'C2Workout(intervals: $intervals)'; + return 'C2Workout(intervals: $intervals, splits: $splits)'; } @override @@ -2563,13 +2595,16 @@ class _$C2WorkoutImpl extends _C2Workout { (other.runtimeType == runtimeType && other is _$C2WorkoutImpl && const DeepCollectionEquality() - .equals(other._intervals, _intervals)); + .equals(other._intervals, _intervals) && + const DeepCollectionEquality().equals(other._splits, _splits)); } @JsonKey(ignore: true) @override - int get hashCode => - Object.hash(runtimeType, const DeepCollectionEquality().hash(_intervals)); + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_intervals), + const DeepCollectionEquality().hash(_splits)); @JsonKey(ignore: true) @override @@ -2587,8 +2622,8 @@ class _$C2WorkoutImpl extends _C2Workout { abstract class _C2Workout extends C2Workout { factory _C2Workout( - {@JsonKey(name: 'intervals') final List? intervals}) = - _$C2WorkoutImpl; + {@JsonKey(name: 'intervals') final List? intervals, + @JsonKey(name: 'splits') final List? splits}) = _$C2WorkoutImpl; _C2Workout._() : super._(); factory _C2Workout.fromJson(Map json) = @@ -2598,6 +2633,9 @@ abstract class _C2Workout extends C2Workout { @JsonKey(name: 'intervals') List? get intervals; @override + @JsonKey(name: 'splits') + List? get splits; + @override @JsonKey(ignore: true) _$$C2WorkoutImplCopyWith<_$C2WorkoutImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index 070f60b..a61f37b 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -30,8 +30,8 @@ _$C2FullResultsImpl _$$C2FullResultsImplFromJson(Map json) => comments: json['comments'] as String?, privacy: $enumDecodeNullable(_$C2PrivacyLevelEnumMap, json['privacy']) ?? C2PrivacyLevel.private, - restTime: - const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), + restTime: _$JsonConverterFromJson( + json['rest_time'], const DecimalIntConverter.tenths().fromJson), strokeRate: json['stroke_rate'] as int?, heartRate: json['heart_rate'] == null ? null @@ -59,7 +59,8 @@ Map _$$C2FullResultsImplToJson(_$C2FullResultsImpl instance) => 'ranked': instance.ranked, 'comments': instance.comments, 'privacy': _$C2PrivacyLevelEnumMap[instance.privacy]!, - 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'rest_time': _$JsonConverterToJson( + instance.restTime, const DecimalIntConverter.tenths().toJson), 'stroke_rate': instance.strokeRate, 'heart_rate': instance.heartRate?.toJson(), 'workout': instance.workout?.toJson(), @@ -105,6 +106,18 @@ const _$C2PrivacyLevelEnumMap = { C2PrivacyLevel.everyone: 'everyone', }; +Value? _$JsonConverterFromJson( + Object? json, + Value? Function(Json json) fromJson, +) => + json == null ? null : fromJson(json as Json); + +Json? _$JsonConverterToJson( + Value? value, + Json? Function(Value value) toJson, +) => + value == null ? null : toJson(value); + _$C2HeartRateImpl _$$C2HeartRateImplFromJson(Map json) => _$C2HeartRateImpl( min: json['min'] as int? ?? 0, @@ -262,9 +275,14 @@ _$C2WorkoutImpl _$$C2WorkoutImplFromJson(Map json) => ?.map((e) => C2Intervals.fromJson(e as Map)) .toList() ?? const [], + splits: (json['splits'] as List?) + ?.map((e) => C2Splits.fromJson(e as Map)) + .toList() ?? + const [], ); Map _$$C2WorkoutImplToJson(_$C2WorkoutImpl instance) => { 'intervals': instance.intervals?.map((e) => e.toJson()).toList(), + 'splits': instance.splits?.map((e) => e.toJson()).toList(), }; From 8acef32953f90a3142253f716a17a8c6d7013484 Mon Sep 17 00:00:00 2001 From: pfredCL <95325187+pfredCL@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:31:14 -0400 Subject: [PATCH 25/25] Refactored and simplified file structure and added data models for intervals, heart rate, and full results (retrieved from a GET call on C2's api rather than from their webhook payload) --- lib/src/types/c2_full_results.dart | 2 +- lib/src/types/c2_results.dart | 34 +++--- lib/src/types/index.freezed.dart | 189 ++++++++++++++++++----------- lib/src/types/index.g.dart | 26 ++-- 4 files changed, 147 insertions(+), 104 deletions(-) diff --git a/lib/src/types/c2_full_results.dart b/lib/src/types/c2_full_results.dart index 0e32fcd..70c2bb5 100644 --- a/lib/src/types/c2_full_results.dart +++ b/lib/src/types/c2_full_results.dart @@ -29,7 +29,7 @@ class C2FullResults with _$C2FullResults { C2WeightClass weightClass, @JsonKey(name: 'verified') @Default(false) bool verified, @JsonKey(name: 'ranked') @Default(false) bool ranked, - @JsonKey(name: 'comments')String? comments, + @JsonKey(name: 'comments') String? comments, @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double? restTime, @JsonKey(name: 'stroke_rate') int? strokeRate, diff --git a/lib/src/types/c2_results.dart b/lib/src/types/c2_results.dart index 660c819..9135dc9 100644 --- a/lib/src/types/c2_results.dart +++ b/lib/src/types/c2_results.dart @@ -14,26 +14,26 @@ class C2Results with _$C2Results { C2Results._(); factory C2Results({ - @Default(0) int id, - @Default(0) int userId, - @TimestampConverter() required DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, - String? timezone, - @Default(0) int distance, - @Default(C2ResultType.rower) C2ResultType type, - @DecimalIntConverter.tenths() required double time, - @Default(C2APIWorkoutType.JustRow) + @JsonKey(name: 'id') @Default(0) int id, + @JsonKey(name: 'user_id') @Default(0) int userId, + @JsonKey(name: 'date') @TimestampConverter() required DateTime date, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'distance') @Default(0) int distance, + @JsonKey(name: 'type') @Default(C2ResultType.rower) C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required double time, + @JsonKey(name: 'workout_type') @Default(C2APIWorkoutType.JustRow) C2APIWorkoutType workoutType, - @Default("c2logbook dart") String source, - @Default(C2WeightClass.heavyweight) + @JsonKey(name: 'source') @Default("c2logbook dart") String source, + @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - @Default(null) int? strokeRate, - @Default(false) bool verified, - @Default(false) bool ranked, - @Default(null) String? comments, - @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') @Default(null) int? strokeRate, + @JsonKey(name: 'verified') @Default(false) bool verified, + @JsonKey(name: 'ranked') @Default(false) bool ranked, + @JsonKey(name: 'comments') @Default(null) String? comments, + @JsonKey(name: 'privacy') @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, }) = _C2Results; factory C2Results.fromJson(Map json) => _$C2ResultsFromJson(Map.from(json)); -} +} \ No newline at end of file diff --git a/lib/src/types/index.freezed.dart b/lib/src/types/index.freezed.dart index 2ef6191..ecdada8 100644 --- a/lib/src/types/index.freezed.dart +++ b/lib/src/types/index.freezed.dart @@ -1224,24 +1224,40 @@ C2Results _$C2ResultsFromJson(Map json) { /// @nodoc mixin _$C2Results { + @JsonKey(name: 'id') int get id => throw _privateConstructorUsedError; + @JsonKey(name: 'user_id') int get userId => throw _privateConstructorUsedError; + @JsonKey(name: 'date') @TimestampConverter() DateTime get date => throw _privateConstructorUsedError; + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? get dateUtc => throw _privateConstructorUsedError; + @JsonKey(name: 'timezone') String? get timezone => throw _privateConstructorUsedError; + @JsonKey(name: 'distance') int get distance => throw _privateConstructorUsedError; + @JsonKey(name: 'type') C2ResultType get type => throw _privateConstructorUsedError; + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time => throw _privateConstructorUsedError; + @JsonKey(name: 'workout_type') C2APIWorkoutType get workoutType => throw _privateConstructorUsedError; + @JsonKey(name: 'source') String get source => throw _privateConstructorUsedError; + @JsonKey(name: 'weight_class') C2WeightClass get weightClass => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_rate') int? get strokeRate => throw _privateConstructorUsedError; + @JsonKey(name: 'verified') bool get verified => throw _privateConstructorUsedError; + @JsonKey(name: 'ranked') bool get ranked => throw _privateConstructorUsedError; + @JsonKey(name: 'comments') String? get comments => throw _privateConstructorUsedError; + @JsonKey(name: 'privacy') C2PrivacyLevel get privacy => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -1256,22 +1272,22 @@ abstract class $C2ResultsCopyWith<$Res> { _$C2ResultsCopyWithImpl<$Res, C2Results>; @useResult $Res call( - {int id, - int userId, - @TimestampConverter() DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, - String? timezone, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - C2APIWorkoutType workoutType, - String source, - C2WeightClass weightClass, - int? strokeRate, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy}); + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy}); } /// @nodoc @@ -1382,22 +1398,22 @@ abstract class _$$C2ResultsImplCopyWith<$Res> @override @useResult $Res call( - {int id, - int userId, - @TimestampConverter() DateTime date, - @TimestampOrNullConverter() DateTime? dateUtc, - String? timezone, - int distance, - C2ResultType type, - @DecimalIntConverter.tenths() double time, - C2APIWorkoutType workoutType, - String source, - C2WeightClass weightClass, - int? strokeRate, - bool verified, - bool ranked, - String? comments, - C2PrivacyLevel privacy}); + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime date, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? dateUtc, + @JsonKey(name: 'timezone') String? timezone, + @JsonKey(name: 'distance') int distance, + @JsonKey(name: 'type') C2ResultType type, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double time, + @JsonKey(name: 'workout_type') C2APIWorkoutType workoutType, + @JsonKey(name: 'source') String source, + @JsonKey(name: 'weight_class') C2WeightClass weightClass, + @JsonKey(name: 'stroke_rate') int? strokeRate, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy}); } /// @nodoc @@ -1501,73 +1517,79 @@ class __$$C2ResultsImplCopyWithImpl<$Res> @JsonSerializable() class _$C2ResultsImpl extends _C2Results { _$C2ResultsImpl( - {this.id = 0, - this.userId = 0, - @TimestampConverter() required this.date, - @TimestampOrNullConverter() this.dateUtc, - this.timezone, - this.distance = 0, - this.type = C2ResultType.rower, - @DecimalIntConverter.tenths() required this.time, + {@JsonKey(name: 'id') this.id = 0, + @JsonKey(name: 'user_id') this.userId = 0, + @JsonKey(name: 'date') @TimestampConverter() required this.date, + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() this.dateUtc, + @JsonKey(name: 'timezone') this.timezone, + @JsonKey(name: 'distance') this.distance = 0, + @JsonKey(name: 'type') this.type = C2ResultType.rower, + @JsonKey(name: 'time') @DecimalIntConverter.tenths() required this.time, + @JsonKey(name: 'workout_type') this.workoutType = C2APIWorkoutType.JustRow, - this.source = "c2logbook dart", + @JsonKey(name: 'source') this.source = "c2logbook dart", + @JsonKey(name: 'weight_class') this.weightClass = C2WeightClass.heavyweight, - this.strokeRate = null, - this.verified = false, - this.ranked = false, - this.comments = null, - this.privacy = C2PrivacyLevel.private}) + @JsonKey(name: 'stroke_rate') this.strokeRate = null, + @JsonKey(name: 'verified') this.verified = false, + @JsonKey(name: 'ranked') this.ranked = false, + @JsonKey(name: 'comments') this.comments = null, + @JsonKey(name: 'privacy') this.privacy = C2PrivacyLevel.private}) : super._(); factory _$C2ResultsImpl.fromJson(Map json) => _$$C2ResultsImplFromJson(json); @override - @JsonKey() + @JsonKey(name: 'id') final int id; @override - @JsonKey() + @JsonKey(name: 'user_id') final int userId; @override + @JsonKey(name: 'date') @TimestampConverter() final DateTime date; @override + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() final DateTime? dateUtc; @override + @JsonKey(name: 'timezone') final String? timezone; @override - @JsonKey() + @JsonKey(name: 'distance') final int distance; @override - @JsonKey() + @JsonKey(name: 'type') final C2ResultType type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() final double time; @override - @JsonKey() + @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType; @override - @JsonKey() + @JsonKey(name: 'source') final String source; @override - @JsonKey() + @JsonKey(name: 'weight_class') final C2WeightClass weightClass; @override - @JsonKey() + @JsonKey(name: 'stroke_rate') final int? strokeRate; @override - @JsonKey() + @JsonKey(name: 'verified') final bool verified; @override - @JsonKey() + @JsonKey(name: 'ranked') final bool ranked; @override - @JsonKey() + @JsonKey(name: 'comments') final String? comments; @override - @JsonKey() + @JsonKey(name: 'privacy') final C2PrivacyLevel privacy; @override @@ -1642,21 +1664,26 @@ class _$C2ResultsImpl extends _C2Results { abstract class _C2Results extends C2Results { factory _C2Results( - {final int id, - final int userId, - @TimestampConverter() required final DateTime date, - @TimestampOrNullConverter() final DateTime? dateUtc, - final String? timezone, - final int distance, - final C2ResultType type, - @DecimalIntConverter.tenths() required final double time, - final C2APIWorkoutType workoutType, - final String source, - final C2WeightClass weightClass, - final int? strokeRate, - final bool verified, - final bool ranked, - final String? comments, + {@JsonKey(name: 'id') final int id, + @JsonKey(name: 'user_id') final int userId, + @JsonKey(name: 'date') @TimestampConverter() required final DateTime date, + @JsonKey(name: 'date_utc') + @TimestampOrNullConverter() + final DateTime? dateUtc, + @JsonKey(name: 'timezone') final String? timezone, + @JsonKey(name: 'distance') final int distance, + @JsonKey(name: 'type') final C2ResultType type, + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + required final double time, + @JsonKey(name: 'workout_type') final C2APIWorkoutType workoutType, + @JsonKey(name: 'source') final String source, + @JsonKey(name: 'weight_class') final C2WeightClass weightClass, + @JsonKey(name: 'stroke_rate') final int? strokeRate, + @JsonKey(name: 'verified') final bool verified, + @JsonKey(name: 'ranked') final bool ranked, + @JsonKey(name: 'comments') final String? comments, + @JsonKey(name: 'privacy') final C2PrivacyLevel privacy}) = _$C2ResultsImpl; _C2Results._() : super._(); @@ -1664,39 +1691,55 @@ abstract class _C2Results extends C2Results { _$C2ResultsImpl.fromJson; @override + @JsonKey(name: 'id') int get id; @override + @JsonKey(name: 'user_id') int get userId; @override + @JsonKey(name: 'date') @TimestampConverter() DateTime get date; @override + @JsonKey(name: 'date_utc') @TimestampOrNullConverter() DateTime? get dateUtc; @override + @JsonKey(name: 'timezone') String? get timezone; @override + @JsonKey(name: 'distance') int get distance; @override + @JsonKey(name: 'type') C2ResultType get type; @override + @JsonKey(name: 'time') @DecimalIntConverter.tenths() double get time; @override + @JsonKey(name: 'workout_type') C2APIWorkoutType get workoutType; @override + @JsonKey(name: 'source') String get source; @override + @JsonKey(name: 'weight_class') C2WeightClass get weightClass; @override + @JsonKey(name: 'stroke_rate') int? get strokeRate; @override + @JsonKey(name: 'verified') bool get verified; @override + @JsonKey(name: 'ranked') bool get ranked; @override + @JsonKey(name: 'comments') String? get comments; @override + @JsonKey(name: 'privacy') C2PrivacyLevel get privacy; @override @JsonKey(ignore: true) diff --git a/lib/src/types/index.g.dart b/lib/src/types/index.g.dart index a61f37b..aebd52c 100644 --- a/lib/src/types/index.g.dart +++ b/lib/src/types/index.g.dart @@ -162,23 +162,23 @@ Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => _$C2ResultsImpl( id: json['id'] as int? ?? 0, - userId: json['userId'] as int? ?? 0, + userId: json['user_id'] as int? ?? 0, date: const TimestampConverter().fromJson(json['date'] as String), - dateUtc: - const TimestampOrNullConverter().fromJson(json['dateUtc'] as String?), + dateUtc: const TimestampOrNullConverter() + .fromJson(json['date_utc'] as String?), timezone: json['timezone'] as String?, distance: json['distance'] as int? ?? 0, type: $enumDecodeNullable(_$C2ResultTypeEnumMap, json['type']) ?? C2ResultType.rower, time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), - workoutType: - $enumDecodeNullable(_$C2APIWorkoutTypeEnumMap, json['workoutType']) ?? - C2APIWorkoutType.JustRow, + workoutType: $enumDecodeNullable( + _$C2APIWorkoutTypeEnumMap, json['workout_type']) ?? + C2APIWorkoutType.JustRow, source: json['source'] as String? ?? "c2logbook dart", weightClass: - $enumDecodeNullable(_$C2WeightClassEnumMap, json['weightClass']) ?? + $enumDecodeNullable(_$C2WeightClassEnumMap, json['weight_class']) ?? C2WeightClass.heavyweight, - strokeRate: json['strokeRate'] as int? ?? null, + strokeRate: json['stroke_rate'] as int? ?? null, verified: json['verified'] as bool? ?? false, ranked: json['ranked'] as bool? ?? false, comments: json['comments'] as String? ?? null, @@ -189,17 +189,17 @@ _$C2ResultsImpl _$$C2ResultsImplFromJson(Map json) => Map _$$C2ResultsImplToJson(_$C2ResultsImpl instance) => { 'id': instance.id, - 'userId': instance.userId, + 'user_id': instance.userId, 'date': const TimestampConverter().toJson(instance.date), - 'dateUtc': const TimestampOrNullConverter().toJson(instance.dateUtc), + 'date_utc': const TimestampOrNullConverter().toJson(instance.dateUtc), 'timezone': instance.timezone, 'distance': instance.distance, 'type': _$C2ResultTypeEnumMap[instance.type]!, 'time': const DecimalIntConverter.tenths().toJson(instance.time), - 'workoutType': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, + 'workout_type': _$C2APIWorkoutTypeEnumMap[instance.workoutType]!, 'source': instance.source, - 'weightClass': _$C2WeightClassEnumMap[instance.weightClass]!, - 'strokeRate': instance.strokeRate, + 'weight_class': _$C2WeightClassEnumMap[instance.weightClass]!, + 'stroke_rate': instance.strokeRate, 'verified': instance.verified, 'ranked': instance.ranked, 'comments': instance.comments,