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..afc6383 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.5" characters: dependency: transitive description: @@ -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 b74ac5c..17e6e78 100644 --- a/lib/c2logbook.dart +++ b/lib/c2logbook.dart @@ -4,9 +4,6 @@ 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/index.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_detailed_result.dart b/lib/src/types/c2_detailed_result.dart new file mode 100644 index 0000000..dfd3f6e --- /dev/null +++ b/lib/src/types/c2_detailed_result.dart @@ -0,0 +1,13 @@ +part of 'index.dart'; + +@Deprecated( + 'This class will soon be removed. Please use methods on [C2Logbook] or manually pick out the `data` key from the Concept2 API response and feed it into [C2Results.fromJson] yourself') +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/c2_full_results.dart b/lib/src/types/c2_full_results.dart new file mode 100644 index 0000000..1a47853 --- /dev/null +++ b/lib/src/types/c2_full_results.dart @@ -0,0 +1,41 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@Deprecated('This class will soon be removed in favor of [C2Results]') +@freezed +class C2FullResults with _$C2FullResults { + 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() 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: 'rest_distance') @Default(0.0) double restDistance, + }) = _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..0e9d3d7 --- /dev/null +++ b/lib/src/types/c2_heart_rate.dart @@ -0,0 +1,18 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2HeartRate with _$C2HeartRate { + C2HeartRate._(); + + factory C2HeartRate( + {@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, + @JsonKey(name: 'rest') @Default(0) int rest}) = _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..47ac0bb --- /dev/null +++ b/lib/src/types/c2_intervals.dart @@ -0,0 +1,24 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Intervals with _$C2Intervals { + C2Intervals._(); + + factory C2Intervals({ + @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, + @JsonKey(name: 'rest_distance') @Default(null) int? restDistance, + }) = _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..2764baf 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 { @@ -20,26 +14,37 @@ class C2Results with _$C2Results { 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, - String? timezone, - @Default(0) int distance, - @Default(C2ResultType.rower) C2ResultType type, - @DecimalIntConverter.tenths() required double time, - @JsonKey(name: "workout_type") + @JsonKey(name: 'id') @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, + @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, - @JsonKey(name: "weight_class") + @JsonKey(name: 'source') @Default("c2logbook dart") String source, + @JsonKey(name: 'weight_class') @Default(C2WeightClass.heavyweight) C2WeightClass weightClass, - @JsonKey(name: "stroke_rate") int? strokeRate, - @Default(false) bool verified, - @Default(false) bool ranked, - String? comments, - @Default(C2PrivacyLevel.private) C2PrivacyLevel privacy, + @JsonKey(name: 'stroke_rate') @Default(null) int? strokeRate, + @JsonKey(name: 'heart_rate') @Default(null) C2HeartRate? heartRate, + @JsonKey(name: 'calories_total') @Default(0) int caloriesTotal, + @JsonKey(name: 'drag_factor') @Default(0) int dragFactor, + @JsonKey(name: 'stroke_count') @Default(0) int strokeCount, + @JsonKey(name: 'workout') @Default(null) C2Workout? workout, + // REQUIRED/FOR INTERVAL WORKOUTS ONLY + @JsonKey(name: 'rest_distance') @Default(0.0) double restDistance, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() double? restTime, + // END REQUIRED/FOR INTERVAL WORKOUTS ONLY + @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) => 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..9d698a1 --- /dev/null +++ b/lib/src/types/c2_splits.dart @@ -0,0 +1,20 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Splits with _$C2Splits { + C2Splits._(); + + factory C2Splits({ + @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) => + _$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..f042d3f 100644 --- a/lib/src/types/c2_user.dart +++ b/lib/src/types/c2_user.dart @@ -1,10 +1,6 @@ // 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 { 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/c2_workout.dart b/lib/src/types/c2_workout.dart new file mode 100644 index 0000000..00332c8 --- /dev/null +++ b/lib/src/types/c2_workout.dart @@ -0,0 +1,18 @@ +// ignore_for_file: invalid_annotation_target + +part of 'index.dart'; + +@freezed +class C2Workout with _$C2Workout { + C2Workout._(); + + factory C2Workout({ + @JsonKey(name: 'intervals') + @Default([]) + List? intervals, + @JsonKey(name: 'splits') @Default([]) List? splits, + }) = _C2Workout; + + factory C2Workout.fromJson(Map json) => + _$C2WorkoutFromJson(Map.from(json)); +} diff --git a/lib/src/types/index.dart b/lib/src/types/index.dart new file mode 100644 index 0000000..6ae2858 --- /dev/null +++ b/lib/src/types/index.dart @@ -0,0 +1,16 @@ +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'; +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 'c2_workout.dart'; +part 'index.freezed.dart'; +part '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..042cea3 --- /dev/null +++ b/lib/src/types/index.freezed.dart @@ -0,0 +1,2974 @@ +// 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 { + @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; + @JsonKey(name: 'rest_distance') + double get restDistance => 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( + {@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, + @JsonKey(name: 'rest_distance') double restDistance}); + + $C2HeartRateCopyWith<$Res>? get heartRate; + $C2WorkoutCopyWith<$Res>? get workout; +} + +/// @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? 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 = freezed, + Object? strokeRate = freezed, + Object? heartRate = freezed, + Object? workout = freezed, + Object? restDistance = 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, + 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: freezed == 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?, + 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 +abstract class _$$C2FullResultsImplCopyWith<$Res> + implements $C2FullResultsCopyWith<$Res> { + factory _$$C2FullResultsImplCopyWith( + _$C2FullResultsImpl value, $Res Function(_$C2FullResultsImpl) then) = + __$$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, + @JsonKey(name: 'rest_distance') double restDistance}); + + @override + $C2HeartRateCopyWith<$Res>? get heartRate; + @override + $C2WorkoutCopyWith<$Res>? get workout; +} + +/// @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? 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 = freezed, + Object? strokeRate = freezed, + Object? heartRate = freezed, + Object? workout = freezed, + Object? restDistance = 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, + 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: freezed == 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?, + restDistance: null == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as double, + )); + } +} + +/// @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() this.restTime, + @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) => + _$$C2FullResultsImplFromJson(json); + + @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 + @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, heartRate: $heartRate, workout: $workout, restDistance: $restDistance)'; + } + + @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.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.restDistance, restDistance) || + other.restDistance == restDistance)); + } + + @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, + restDistance + ]); + + @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( + {@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() + final double? restTime, + @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) = + _$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: '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(name: 'rest_distance') + double get restDistance; + @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; + @JsonKey(name: 'rest') + int get rest => 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, + @JsonKey(name: 'rest') int rest}); +} + +/// @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, + Object? rest = 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, + rest: null == rest + ? _value.rest + : rest // 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, + @JsonKey(name: 'rest') int rest}); +} + +/// @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, + Object? rest = 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, + rest: null == rest + ? _value.rest + : rest // 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, + @JsonKey(name: 'rest') this.rest = 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 + @JsonKey(name: 'rest') + final int rest; + + @override + String toString() { + return 'C2HeartRate(min: $min, average: $average, max: $max, ending: $ending, rest: $rest)'; + } + + @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) && + (identical(other.rest, rest) || other.rest == rest)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, min, average, max, ending, rest); + + @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, + @JsonKey(name: 'rest') final int rest}) = _$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(name: 'rest') + int get rest; + @override + @JsonKey(ignore: true) + _$$C2HeartRateImplCopyWith<_$C2HeartRateImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2Intervals _$C2IntervalsFromJson(Map json) { + return _C2Intervals.fromJson(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; + @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: '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, + @JsonKey(name: 'rest_distance') int? restDistance}); + + $C2HeartRateCopyWith<$Res>? get heartRate; +} + +/// @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 = freezed, + Object? time = null, + Object? restTime = null, + Object? distance = null, + Object? caloriesTotal = null, + Object? strokeRate = null, + Object? heartRate = freezed, + Object? restDistance = 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 + 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, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + restDistance: freezed == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int?, + ) 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); + }); + } +} + +/// @nodoc +abstract class _$$C2IntervalsImplCopyWith<$Res> + implements $C2IntervalsCopyWith<$Res> { + factory _$$C2IntervalsImplCopyWith( + _$C2IntervalsImpl value, $Res Function(_$C2IntervalsImpl) then) = + __$$C2IntervalsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@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, + @JsonKey(name: 'rest_distance') int? restDistance}); + + @override + $C2HeartRateCopyWith<$Res>? get heartRate; +} + +/// @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 = freezed, + Object? time = null, + Object? restTime = null, + Object? distance = null, + Object? caloriesTotal = null, + Object? strokeRate = null, + Object? heartRate = freezed, + Object? restDistance = freezed, + }) { + return _then(_$C2IntervalsImpl( + 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 + 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, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + restDistance: freezed == restDistance + ? _value.restDistance + : restDistance // ignore: cast_nullable_to_non_nullable + as int?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2IntervalsImpl extends _C2Intervals { + _$C2IntervalsImpl( + {@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, + @JsonKey(name: 'rest_distance') this.restDistance = null}) + : super._(); + + factory _$C2IntervalsImpl.fromJson(Map json) => + _$$C2IntervalsImplFromJson(json); + + @override + @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(name: 'distance') + final double distance; + @override + @JsonKey(name: 'calories_total') + final int caloriesTotal; + @override + @JsonKey(name: 'stroke_rate') + final int strokeRate; + @override + @JsonKey(name: 'heart_rate') + final C2HeartRate? heartRate; + @override + @JsonKey(name: 'rest_distance') + final int? restDistance; + + @override + String toString() { + return 'C2Intervals(type: $type, time: $time, restTime: $restTime, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, heartRate: $heartRate, 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.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.heartRate, heartRate) || + other.heartRate == heartRate) && + (identical(other.restDistance, restDistance) || + other.restDistance == restDistance)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, type, time, restTime, distance, + caloriesTotal, strokeRate, heartRate, 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: '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, + @JsonKey(name: 'rest_distance') final int? restDistance}) = + _$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(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 { + @JsonKey(name: 'id') + 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; + @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: 'heart_rate') + C2HeartRate? get heartRate => throw _privateConstructorUsedError; + @JsonKey(name: 'calories_total') + int get caloriesTotal => throw _privateConstructorUsedError; + @JsonKey(name: 'drag_factor') + int get dragFactor => throw _privateConstructorUsedError; + @JsonKey(name: 'stroke_count') + int get strokeCount => throw _privateConstructorUsedError; + @JsonKey(name: 'workout') + C2Workout? get workout => + throw _privateConstructorUsedError; // REQUIRED/FOR INTERVAL WORKOUTS ONLY + @JsonKey(name: 'rest_distance') + double get restDistance => throw _privateConstructorUsedError; + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? get restTime => + throw _privateConstructorUsedError; // END REQUIRED/FOR INTERVAL WORKOUTS ONLY + @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; + @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( + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime endDate, + @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: 'heart_rate') C2HeartRate? heartRate, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'drag_factor') int dragFactor, + @JsonKey(name: 'stroke_count') int strokeCount, + @JsonKey(name: 'workout') C2Workout? workout, + @JsonKey(name: 'rest_distance') double restDistance, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? restTime, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy}); + + $C2HeartRateCopyWith<$Res>? get heartRate; + $C2WorkoutCopyWith<$Res>? get workout; +} + +/// @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? heartRate = freezed, + Object? caloriesTotal = null, + Object? dragFactor = null, + Object? strokeCount = null, + Object? workout = freezed, + Object? restDistance = null, + Object? restTime = 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?, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable + as int, + dragFactor: null == dragFactor + ? _value.dragFactor + : dragFactor // ignore: cast_nullable_to_non_nullable + as int, + strokeCount: null == strokeCount + ? _value.strokeCount + : strokeCount // ignore: cast_nullable_to_non_nullable + as int, + 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, + restTime: freezed == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double?, + 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); + } + + @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 +abstract class _$$C2ResultsImplCopyWith<$Res> + implements $C2ResultsCopyWith<$Res> { + factory _$$C2ResultsImplCopyWith( + _$C2ResultsImpl value, $Res Function(_$C2ResultsImpl) then) = + __$$C2ResultsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'id') int id, + @JsonKey(name: 'user_id') int userId, + @JsonKey(name: 'date') @TimestampConverter() DateTime endDate, + @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: 'heart_rate') C2HeartRate? heartRate, + @JsonKey(name: 'calories_total') int caloriesTotal, + @JsonKey(name: 'drag_factor') int dragFactor, + @JsonKey(name: 'stroke_count') int strokeCount, + @JsonKey(name: 'workout') C2Workout? workout, + @JsonKey(name: 'rest_distance') double restDistance, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? restTime, + @JsonKey(name: 'verified') bool verified, + @JsonKey(name: 'ranked') bool ranked, + @JsonKey(name: 'comments') String? comments, + @JsonKey(name: 'privacy') C2PrivacyLevel privacy}); + + @override + $C2HeartRateCopyWith<$Res>? get heartRate; + @override + $C2WorkoutCopyWith<$Res>? get workout; +} + +/// @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? heartRate = freezed, + Object? caloriesTotal = null, + Object? dragFactor = null, + Object? strokeCount = null, + Object? workout = freezed, + Object? restDistance = null, + Object? restTime = 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?, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + caloriesTotal: null == caloriesTotal + ? _value.caloriesTotal + : caloriesTotal // ignore: cast_nullable_to_non_nullable + as int, + dragFactor: null == dragFactor + ? _value.dragFactor + : dragFactor // ignore: cast_nullable_to_non_nullable + as int, + strokeCount: null == strokeCount + ? _value.strokeCount + : strokeCount // ignore: cast_nullable_to_non_nullable + as int, + 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, + restTime: freezed == restTime + ? _value.restTime + : restTime // ignore: cast_nullable_to_non_nullable + as double?, + 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( + {@JsonKey(name: 'id') this.id = 0, + @JsonKey(name: 'user_id') this.userId = 0, + @JsonKey(name: 'date') @TimestampConverter() required this.endDate, + @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, + @JsonKey(name: 'source') this.source = "c2logbook dart", + @JsonKey(name: 'weight_class') + this.weightClass = C2WeightClass.heavyweight, + @JsonKey(name: 'stroke_rate') this.strokeRate = null, + @JsonKey(name: 'heart_rate') this.heartRate = null, + @JsonKey(name: 'calories_total') this.caloriesTotal = 0, + @JsonKey(name: 'drag_factor') this.dragFactor = 0, + @JsonKey(name: 'stroke_count') this.strokeCount = 0, + @JsonKey(name: 'workout') this.workout = null, + @JsonKey(name: 'rest_distance') this.restDistance = 0.0, + @JsonKey(name: 'rest_time') @DecimalIntConverter.tenths() this.restTime, + @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(name: 'id') + 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 + @JsonKey(name: 'timezone') + final String? timezone; + @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: 'stroke_rate') + final int? strokeRate; + @override + @JsonKey(name: 'heart_rate') + final C2HeartRate? heartRate; + @override + @JsonKey(name: 'calories_total') + final int caloriesTotal; + @override + @JsonKey(name: 'drag_factor') + final int dragFactor; + @override + @JsonKey(name: 'stroke_count') + final int strokeCount; + @override + @JsonKey(name: 'workout') + final C2Workout? workout; +// REQUIRED/FOR INTERVAL WORKOUTS ONLY + @override + @JsonKey(name: 'rest_distance') + final double restDistance; + @override + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + final double? restTime; +// END REQUIRED/FOR INTERVAL WORKOUTS ONLY + @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 + 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, heartRate: $heartRate, caloriesTotal: $caloriesTotal, dragFactor: $dragFactor, strokeCount: $strokeCount, workout: $workout, restDistance: $restDistance, restTime: $restTime, 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.heartRate, heartRate) || + other.heartRate == heartRate) && + (identical(other.caloriesTotal, caloriesTotal) || + other.caloriesTotal == caloriesTotal) && + (identical(other.dragFactor, dragFactor) || + other.dragFactor == dragFactor) && + (identical(other.strokeCount, strokeCount) || + other.strokeCount == strokeCount) && + (identical(other.workout, workout) || other.workout == workout) && + (identical(other.restDistance, restDistance) || + other.restDistance == restDistance) && + (identical(other.restTime, restTime) || + other.restTime == restTime) && + (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.hashAll([ + runtimeType, + id, + userId, + endDate, + dateUtc, + timezone, + distance, + type, + time, + workoutType, + source, + weightClass, + strokeRate, + heartRate, + caloriesTotal, + dragFactor, + strokeCount, + workout, + restDistance, + restTime, + 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( + {@JsonKey(name: 'id') 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, + @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: 'heart_rate') final C2HeartRate? heartRate, + @JsonKey(name: 'calories_total') final int caloriesTotal, + @JsonKey(name: 'drag_factor') final int dragFactor, + @JsonKey(name: 'stroke_count') final int strokeCount, + @JsonKey(name: 'workout') final C2Workout? workout, + @JsonKey(name: 'rest_distance') final double restDistance, + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + final double? restTime, + @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._(); + + factory _C2Results.fromJson(Map json) = + _$C2ResultsImpl.fromJson; + + @override + @JsonKey(name: 'id') + 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 + @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: 'heart_rate') + C2HeartRate? get heartRate; + @override + @JsonKey(name: 'calories_total') + int get caloriesTotal; + @override + @JsonKey(name: 'drag_factor') + int get dragFactor; + @override + @JsonKey(name: 'stroke_count') + int get strokeCount; + @override + @JsonKey(name: 'workout') + C2Workout? get workout; + @override // REQUIRED/FOR INTERVAL WORKOUTS ONLY + @JsonKey(name: 'rest_distance') + double get restDistance; + @override + @JsonKey(name: 'rest_time') + @DecimalIntConverter.tenths() + double? get restTime; + @override // END REQUIRED/FOR INTERVAL WORKOUTS ONLY + @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) + _$$C2ResultsImplCopyWith<_$C2ResultsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +C2Splits _$C2SplitsFromJson(Map json) { + return _C2Splits.fromJson(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; + @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( + {@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; +} + +/// @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 = freezed, + Object? time = null, + Object? distance = null, + Object? caloriesTotal = null, + Object? strokeRate = null, + 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 + 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, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + ) 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); + }); + } +} + +/// @nodoc +abstract class _$$C2SplitsImplCopyWith<$Res> + implements $C2SplitsCopyWith<$Res> { + factory _$$C2SplitsImplCopyWith( + _$C2SplitsImpl value, $Res Function(_$C2SplitsImpl) then) = + __$$C2SplitsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@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; +} + +/// @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 = freezed, + Object? time = null, + Object? distance = null, + Object? caloriesTotal = null, + Object? strokeRate = null, + 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 + 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, + heartRate: freezed == heartRate + ? _value.heartRate + : heartRate // ignore: cast_nullable_to_non_nullable + as C2HeartRate?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2SplitsImpl extends _C2Splits { + _$C2SplitsImpl( + {@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(name: 'type') + final String? type; + @override + @JsonKey(name: 'time') + @DecimalIntConverter.tenths() + final double time; + @override + @JsonKey(name: 'distance') + final double distance; + @override + @JsonKey(name: 'calories_total') + final int caloriesTotal; + @override + @JsonKey(name: 'stroke_rate') + final int strokeRate; + @override + @JsonKey(name: 'heart_rate') + final C2HeartRate? heartRate; + + @override + String toString() { + return 'C2Splits(type: $type, time: $time, distance: $distance, caloriesTotal: $caloriesTotal, strokeRate: $strokeRate, 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.distance, distance) || + other.distance == distance) && + (identical(other.caloriesTotal, caloriesTotal) || + other.caloriesTotal == caloriesTotal) && + (identical(other.strokeRate, strokeRate) || + other.strokeRate == strokeRate) && + (identical(other.heartRate, heartRate) || + other.heartRate == heartRate)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, type, time, distance, caloriesTotal, strokeRate, 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( + {@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) + _$$C2SplitsImplCopyWith<_$C2SplitsImpl> 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; +} + +C2Workout _$C2WorkoutFromJson(Map json) { + return _C2Workout.fromJson(json); +} + +/// @nodoc +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) + $C2WorkoutCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +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}); +} + +/// @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, + }) { + 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); + } +} + +/// @nodoc +abstract class _$$C2WorkoutImplCopyWith<$Res> + implements $C2WorkoutCopyWith<$Res> { + factory _$$C2WorkoutImplCopyWith( + _$C2WorkoutImpl value, $Res Function(_$C2WorkoutImpl) then) = + __$$C2WorkoutImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'intervals') List? intervals, + @JsonKey(name: 'splits') List? splits}); +} + +/// @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, + }) { + 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?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$C2WorkoutImpl extends _C2Workout { + _$C2WorkoutImpl( + {@JsonKey(name: 'intervals') + final List? intervals = const [], + @JsonKey(name: 'splits') + final List? splits = const []}) + : _intervals = intervals, + _splits = splits, + super._(); + + factory _$C2WorkoutImpl.fromJson(Map json) => + _$$C2WorkoutImplFromJson(json); + + final List? _intervals; + @override + @JsonKey(name: 'intervals') + 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(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)'; + } + + @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)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_intervals), + const DeepCollectionEquality().hash(_splits)); + + @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( + {@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 + @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 new file mode 100644 index 0000000..2f1911d --- /dev/null +++ b/lib/src/types/index.g.dart @@ -0,0 +1,312 @@ +// 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, + 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: _$JsonConverterFromJson( + json['rest_time'], const DecimalIntConverter.tenths().fromJson), + 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) => + { + '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': _$JsonConverterToJson( + instance.restTime, const DecimalIntConverter.tenths().toJson), + 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), + 'workout': instance.workout?.toJson(), + 'rest_distance': instance.restDistance, + }; + +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', +}; + +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, + average: json['average'] as int? ?? 0, + max: json['max'] as int? ?? 0, + ending: json['ending'] as int? ?? 0, + rest: json['rest'] as int? ?? 0, + ); + +Map _$$C2HeartRateImplToJson(_$C2HeartRateImpl instance) => + { + 'min': instance.min, + 'average': instance.average, + 'max': instance.max, + 'ending': instance.ending, + 'rest': instance.rest, + }; + +_$C2IntervalsImpl _$$C2IntervalsImplFromJson(Map json) => + _$C2IntervalsImpl( + type: json['id'] as String? ?? "type", + time: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + restTime: + const DecimalIntConverter.tenths().fromJson(json['rest_time'] as int), + distance: (json['distance'] as num?)?.toDouble() ?? 0.0, + caloriesTotal: json['calories_total'] as int? ?? 0, + strokeRate: json['stroke_rate'] as int? ?? 0, + heartRate: json['heart_rate'] == null + ? null + : C2HeartRate.fromJson(json['heart_rate'] as Map), + restDistance: json['rest_distance'] as int? ?? null, + ); + +Map _$$C2IntervalsImplToJson(_$C2IntervalsImpl instance) => + { + 'id': instance.type, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'rest_time': const DecimalIntConverter.tenths().toJson(instance.restTime), + 'distance': instance.distance, + 'calories_total': instance.caloriesTotal, + 'stroke_rate': instance.strokeRate, + 'heart_rate': instance.heartRate?.toJson(), + '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? ?? null, + heartRate: json['heart_rate'] == null + ? null + : C2HeartRate.fromJson(json['heart_rate'] as Map), + caloriesTotal: json['calories_total'] as int? ?? 0, + dragFactor: json['drag_factor'] as int? ?? 0, + strokeCount: json['stroke_count'] as int? ?? 0, + workout: json['workout'] == null + ? null + : C2Workout.fromJson(json['workout'] as Map), + restDistance: (json['rest_distance'] as num?)?.toDouble() ?? 0.0, + restTime: _$JsonConverterFromJson( + json['rest_time'], const DecimalIntConverter.tenths().fromJson), + verified: json['verified'] as bool? ?? false, + ranked: json['ranked'] as bool? ?? false, + comments: json['comments'] as String? ?? null, + 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, + 'heart_rate': instance.heartRate?.toJson(), + 'calories_total': instance.caloriesTotal, + 'drag_factor': instance.dragFactor, + 'stroke_count': instance.strokeCount, + 'workout': instance.workout?.toJson(), + 'rest_distance': instance.restDistance, + 'rest_time': _$JsonConverterToJson( + instance.restTime, const DecimalIntConverter.tenths().toJson), + '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: const DecimalIntConverter.tenths().fromJson(json['time'] as int), + distance: (json['distance'] as num?)?.toDouble() ?? 0.0, + caloriesTotal: json['calories_total'] as int? ?? 0, + strokeRate: json['stroke_rate'] as int? ?? 0, + heartRate: json['heart_rate'] == null + ? null + : C2HeartRate.fromJson(json['heart_rate'] as Map), + ); + +Map _$$C2SplitsImplToJson(_$C2SplitsImpl instance) => + { + 'type': instance.type, + 'time': const DecimalIntConverter.tenths().toJson(instance.time), + 'distance': instance.distance, + 'calories_total': instance.caloriesTotal, + 'stroke_rate': instance.strokeRate, + 'heart_rate': 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? ?? '', + 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]!, + }; + +_$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 [], + ); + +Map _$$C2WorkoutImplToJson(_$C2WorkoutImpl instance) => + { + 'intervals': instance.intervals?.map((e) => e.toJson()).toList(), + 'splits': instance.splits?.map((e) => e.toJson()).toList(), + }; diff --git a/pubspec.yaml b/pubspec.yaml index 5ae1664..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.2 +version: 0.0.5 # repository: https://github.com/my_org/my_repo environment: diff --git a/test/c2logbook_test.dart b/test/c2logbook_test.dart index 25ac7ef..3fe7ef4 100644 --- a/test/c2logbook_test.dart +++ b/test/c2logbook_test.dart @@ -1,6 +1,6 @@ -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( @@ -51,7 +51,8 @@ void main() { group('Parsing Tests', () { test('Test Parsing minimal Result JSON', () { - final jsonData = json.decode("""{ + // data manually created to exercise the parser + final dynamic jsonData = json.decode("""{ "id": 3, "user_id": 1, "date": "2013-06-21 00:00:00", @@ -70,7 +71,8 @@ void main() { }); test('Test Parsing maximal Result JSON', () { - final jsonData = json.decode("""{ + // data manually created to exercise the parser + final dynamic jsonData = json.decode("""{ "id": 3, "user_id": 1, "date": "2013-06-21 00:00:00", @@ -92,8 +94,50 @@ void main() { expect(C2Results.fromJson(jsonData), testResultsMax); }); + test('Test Parsing Result JSON from Concept2 example', () { + // data from: https://log.concept2.com/developers/documentation/#logbook-users-results-get + final dynamic jsonData = json.decode("""{ + "id": 3, + "user_id": 1, + "date": "2013-06-21 00:00:00", + "timezone": null, + "date_utc": null, + "distance": 23000, + "type": "rower", + "time": 152350, + "time_formatted": "4:13:55.0", + "workout_type": "unknown", + "source": "Web", + "weight_class": "H", + "verified": false, + "ranked": false, + "comments": null, + "privacy": "partners" + }"""); + expect( + C2Results.fromJson(jsonData), + C2Results( + id: 3, + userId: 1, + endDate: DateTime.parse("2013-06-21 00:00:00"), + dateUtc: null, + timezone: null, + distance: 23000, + type: C2ResultType.rower, + time: 15235.0, + strokeRate: null, + workoutType: C2APIWorkoutType.unknown, + source: "Web", + weightClass: C2WeightClass.heavyweight, + verified: false, + ranked: false, + comments: null, + privacy: C2PrivacyLevel.partners)); + }); + test('Test Parsing User JSON', () { - final jsonData = json.decode("""{ + // Data from: https://log.concept2.com/developers/documentation/#logbook-users-user-get + final dynamic jsonData = json.decode("""{ "id": 1, "username": "David Hart", "first_name": "David", @@ -111,10 +155,10 @@ void main() { expect(C2User.fromJson(jsonData), testUser); }); - }); - test("Test parsing webhook JSON (minimal)", () { - final webhookJson = json.decode("""{ + test("Test parsing webhook JSON (minimal)", () { + // data from: https://log.concept2.com/developers/documentation/#webhook + final dynamic webhookJson = json.decode("""{ "data": { "type": "result-added", "result": @@ -135,7 +179,131 @@ void main() { } } }"""); - expect(C2Webhook.parse(webhookJson), testResultsMin); + expect(C2Webhook.parse(webhookJson), testResultsMin); + }); + + test("Test parsing Result JSON (with workout and Heart rate)", () { + // anonymized sample data provided from a real-world usecase + final dynamic webhookJson = json.decode("""{ + "id": 987654321, + "user_id": 123456789, + "date": "2024-03-06 18:13:00", + "timezone": "America/New_York", + "date_utc": "2024-03-06 23:13:00", + "distance": 9011, + "type": "bike", + "time": 11520, + "time_formatted": "19:12.0", + "workout_type": "JustRow", + "source": "ErgData iOS", + "weight_class": "H", + "verified": false, + "ranked": false, + "comments": null, + "privacy": "logged_in", + "stroke_data": true, + "calories_total": 278, + "drag_factor": 52, + "stroke_count": 1673, + "stroke_rate": 87, + "heart_rate": { + "min": 84, + "average": 122, + "max": 128, + "ending": 122 + }, + "workout": { + "splits": [ + { + "time": 3000, + "distance": 2341, + "calories_total": 72, + "stroke_rate": 87, + "heart_rate": { + "min": 81, + "average": 114, + "max": 125, + "ending": 122 + }, + "type": "distance" + } + ], + "intervals": [ + { + "type": "distance", + "time": 7045, + "distance": 3000, + "calories_total": 204, + "stroke_rate": 20, + "rest_time": 1800, + "heart_rate": { + "min": 71, + "average": 140, + "max": 160, + "ending": 148, + "rest": 157 + }, + "machine": "rower", + "rest_distance": 124 + } + ] + }, + "real_time": null, + "rest_distance": 887, + "rest_time": 9000 + }"""); + expect( + C2Results.fromJson(webhookJson), + C2Results( + id: 987654321, + userId: 123456789, + endDate: DateTime.parse("2024-03-06 18:13:00"), + dateUtc: DateTime.parse("2024-03-06 23:13:00"), + timezone: "America/New_York", + distance: 9011, + type: C2ResultType.bike, + time: 1152.0, + strokeRate: 87, + workoutType: C2APIWorkoutType.JustRow, + source: "ErgData iOS", + weightClass: C2WeightClass.heavyweight, + verified: false, + ranked: false, + comments: null, + privacy: C2PrivacyLevel.logged_in, + restDistance: 887, + restTime: 900.0, + // stroke_data True + caloriesTotal: 278, + dragFactor: 52, + strokeCount: 1673, + heartRate: + C2HeartRate(min: 84, average: 122, max: 128, ending: 122), + workout: C2Workout(splits: [ + C2Splits( + time: 300.0, + distance: 2341, + caloriesTotal: 72, + strokeRate: 87, + heartRate: C2HeartRate( + min: 81, average: 114, max: 125, ending: 122), + type: "distance") + ], intervals: [ + C2Intervals( + time: 704.5, + restTime: 180.0, + distance: 3000, + caloriesTotal: 204, + strokeRate: 20, + heartRate: C2HeartRate( + min: 71, + average: 140, + max: 160, + ending: 148, + rest: 157), + restDistance: 124) + ]))); + }); }); group('Equality Tests', () {