Initial commit
This commit is contained in:
@@ -0,0 +1,154 @@
|
||||
import 'trakt_ids.dart';
|
||||
|
||||
|
||||
class TraktCalendarEntry {
|
||||
|
||||
final DateTime firstAired;
|
||||
|
||||
|
||||
final String type;
|
||||
|
||||
final String? showTitle;
|
||||
final int? showYear;
|
||||
final TraktIds? showIds;
|
||||
final int? episodeSeason;
|
||||
final int? episodeNumber;
|
||||
final String? episodeTitle;
|
||||
final TraktIds? episodeIds;
|
||||
|
||||
final String? movieTitle;
|
||||
final int? movieYear;
|
||||
final TraktIds? movieIds;
|
||||
|
||||
|
||||
final String? posterUrl;
|
||||
|
||||
const TraktCalendarEntry({
|
||||
required this.firstAired,
|
||||
required this.type,
|
||||
this.showTitle,
|
||||
this.showYear,
|
||||
this.showIds,
|
||||
this.episodeSeason,
|
||||
this.episodeNumber,
|
||||
this.episodeTitle,
|
||||
this.episodeIds,
|
||||
this.movieTitle,
|
||||
this.movieYear,
|
||||
this.movieIds,
|
||||
this.posterUrl,
|
||||
});
|
||||
|
||||
TraktCalendarEntry withPoster(String? url) => TraktCalendarEntry(
|
||||
firstAired: firstAired,
|
||||
type: type,
|
||||
showTitle: showTitle,
|
||||
showYear: showYear,
|
||||
showIds: showIds,
|
||||
episodeSeason: episodeSeason,
|
||||
episodeNumber: episodeNumber,
|
||||
episodeTitle: episodeTitle,
|
||||
episodeIds: episodeIds,
|
||||
movieTitle: movieTitle,
|
||||
movieYear: movieYear,
|
||||
movieIds: movieIds,
|
||||
posterUrl: url,
|
||||
);
|
||||
|
||||
TraktCalendarEntry withTitle(String title) => TraktCalendarEntry(
|
||||
firstAired: firstAired,
|
||||
type: type,
|
||||
showTitle: type == 'movie' ? showTitle : title,
|
||||
showYear: showYear,
|
||||
showIds: showIds,
|
||||
episodeSeason: episodeSeason,
|
||||
episodeNumber: episodeNumber,
|
||||
episodeTitle: episodeTitle,
|
||||
episodeIds: episodeIds,
|
||||
movieTitle: type == 'movie' ? title : movieTitle,
|
||||
movieYear: movieYear,
|
||||
movieIds: movieIds,
|
||||
posterUrl: posterUrl,
|
||||
);
|
||||
|
||||
|
||||
int? get tmdbId => type == 'movie' ? movieIds?.tmdb : showIds?.tmdb;
|
||||
|
||||
|
||||
String get mediaType => type == 'movie' ? 'movie' : 'tv';
|
||||
|
||||
|
||||
String get displayTitle =>
|
||||
type == 'movie' ? (movieTitle ?? '') : (showTitle ?? '');
|
||||
|
||||
|
||||
String get displaySubtitle {
|
||||
if (type == 'movie') return movieYear?.toString() ?? '';
|
||||
final parts = <String>[];
|
||||
if (episodeSeason != null && episodeNumber != null) {
|
||||
parts.add(
|
||||
'S${episodeSeason.toString().padLeft(2, '0')}'
|
||||
'E${episodeNumber.toString().padLeft(2, '0')}',
|
||||
);
|
||||
}
|
||||
if (episodeTitle != null && episodeTitle!.isNotEmpty) {
|
||||
parts.add(episodeTitle!);
|
||||
}
|
||||
return parts.join(' · ');
|
||||
}
|
||||
|
||||
|
||||
static TraktCalendarEntry? fromShowJson(Map<String, dynamic> json) {
|
||||
final aired = _parseDate(json['first_aired']);
|
||||
if (aired == null) return null;
|
||||
|
||||
final show = json['show'];
|
||||
final episode = json['episode'];
|
||||
if (show is! Map<String, dynamic>) return null;
|
||||
|
||||
return TraktCalendarEntry(
|
||||
firstAired: aired,
|
||||
type: 'show',
|
||||
showTitle: show['title'] as String?,
|
||||
showYear: (show['year'] as num?)?.toInt(),
|
||||
showIds: TraktIds.fromJson(show['ids']),
|
||||
episodeSeason: episode is Map<String, dynamic>
|
||||
? (episode['season'] as num?)?.toInt()
|
||||
: null,
|
||||
episodeNumber: episode is Map<String, dynamic>
|
||||
? (episode['number'] as num?)?.toInt()
|
||||
: null,
|
||||
episodeTitle: episode is Map<String, dynamic>
|
||||
? episode['title'] as String?
|
||||
: null,
|
||||
episodeIds: episode is Map<String, dynamic>
|
||||
? TraktIds.fromJson(episode['ids'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
static TraktCalendarEntry? fromMovieJson(Map<String, dynamic> json) {
|
||||
final releasedStr = json['released'] as String?;
|
||||
final aired = releasedStr != null && releasedStr.isNotEmpty
|
||||
? DateTime.tryParse(releasedStr)
|
||||
: null;
|
||||
if (aired == null) return null;
|
||||
|
||||
final movie = json['movie'];
|
||||
if (movie is! Map<String, dynamic>) return null;
|
||||
|
||||
return TraktCalendarEntry(
|
||||
firstAired: aired,
|
||||
type: 'movie',
|
||||
movieTitle: movie['title'] as String?,
|
||||
movieYear: (movie['year'] as num?)?.toInt(),
|
||||
movieIds: TraktIds.fromJson(movie['ids']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? _parseDate(Object? raw) {
|
||||
if (raw is! String || raw.isEmpty) return null;
|
||||
return DateTime.tryParse(raw);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
|
||||
|
||||
class TraktIds {
|
||||
final int? trakt;
|
||||
final String? imdb;
|
||||
final int? tmdb;
|
||||
final int? tvdb;
|
||||
final String? slug;
|
||||
|
||||
const TraktIds({this.trakt, this.imdb, this.tmdb, this.tvdb, this.slug});
|
||||
|
||||
factory TraktIds.fromJson(Object? raw) {
|
||||
if (raw is! Map) return const TraktIds();
|
||||
final json = raw.cast<String, dynamic>();
|
||||
return TraktIds(
|
||||
trakt: (json['trakt'] as num?)?.toInt(),
|
||||
imdb: json['imdb'] as String?,
|
||||
tmdb: (json['tmdb'] as num?)?.toInt(),
|
||||
tvdb: (json['tvdb'] as num?)?.toInt(),
|
||||
slug: json['slug'] as String?,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
bool get hasReliableId =>
|
||||
(trakt != null && trakt! > 0) ||
|
||||
(imdb != null && imdb!.isNotEmpty) ||
|
||||
(tmdb != null && tmdb! > 0) ||
|
||||
(tvdb != null && tvdb! > 0);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final out = <String, dynamic>{};
|
||||
if (trakt != null && trakt! > 0) out['trakt'] = trakt;
|
||||
if (imdb != null && imdb!.isNotEmpty) out['imdb'] = imdb;
|
||||
if (tmdb != null && tmdb! > 0) out['tmdb'] = tmdb;
|
||||
if (tvdb != null && tvdb! > 0) out['tvdb'] = tvdb;
|
||||
if (slug != null && slug!.isNotEmpty) out['slug'] = slug;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import 'trakt_ids.dart';
|
||||
|
||||
|
||||
class TraktPlaybackEntry {
|
||||
|
||||
final double progress;
|
||||
final DateTime? pausedAt;
|
||||
|
||||
|
||||
final String type;
|
||||
|
||||
final String? movieTitle;
|
||||
final int? movieYear;
|
||||
final TraktIds? movieIds;
|
||||
|
||||
final String? showTitle;
|
||||
final int? showYear;
|
||||
final TraktIds? showIds;
|
||||
|
||||
final int? episodeSeason;
|
||||
final int? episodeNumber;
|
||||
final String? episodeTitle;
|
||||
final TraktIds? episodeIds;
|
||||
|
||||
const TraktPlaybackEntry({
|
||||
required this.progress,
|
||||
required this.type,
|
||||
this.pausedAt,
|
||||
this.movieTitle,
|
||||
this.movieYear,
|
||||
this.movieIds,
|
||||
this.showTitle,
|
||||
this.showYear,
|
||||
this.showIds,
|
||||
this.episodeSeason,
|
||||
this.episodeNumber,
|
||||
this.episodeTitle,
|
||||
this.episodeIds,
|
||||
});
|
||||
|
||||
static TraktPlaybackEntry? fromJson(Map<String, dynamic> json) {
|
||||
final movie = json['movie'];
|
||||
final show = json['show'];
|
||||
final episode = json['episode'];
|
||||
final hasMovie = movie is Map<String, dynamic>;
|
||||
final hasShow = show is Map<String, dynamic>;
|
||||
if (!hasMovie && !hasShow) return null;
|
||||
|
||||
final rawType = json['type'] as String? ?? '';
|
||||
return TraktPlaybackEntry(
|
||||
progress: (json['progress'] as num?)?.toDouble() ?? 0,
|
||||
pausedAt: _parseDate(json['paused_at']),
|
||||
type: rawType.isNotEmpty ? rawType : (hasMovie ? 'movie' : 'episode'),
|
||||
movieTitle: hasMovie ? movie['title'] as String? : null,
|
||||
movieYear: hasMovie ? (movie['year'] as num?)?.toInt() : null,
|
||||
movieIds: hasMovie ? TraktIds.fromJson(movie['ids']) : null,
|
||||
showTitle: hasShow ? show['title'] as String? : null,
|
||||
showYear: hasShow ? (show['year'] as num?)?.toInt() : null,
|
||||
showIds: hasShow ? TraktIds.fromJson(show['ids']) : null,
|
||||
episodeSeason: episode is Map<String, dynamic>
|
||||
? (episode['season'] as num?)?.toInt()
|
||||
: null,
|
||||
episodeNumber: episode is Map<String, dynamic>
|
||||
? (episode['number'] as num?)?.toInt()
|
||||
: null,
|
||||
episodeTitle: episode is Map<String, dynamic>
|
||||
? episode['title'] as String?
|
||||
: null,
|
||||
episodeIds: episode is Map<String, dynamic>
|
||||
? TraktIds.fromJson(episode['ids'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DateTime? _parseDate(Object? raw) {
|
||||
if (raw is! String || raw.isEmpty) return null;
|
||||
return DateTime.tryParse(raw);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
enum TraktResponseClass {
|
||||
|
||||
success,
|
||||
|
||||
|
||||
duplicate,
|
||||
|
||||
|
||||
invalid,
|
||||
|
||||
|
||||
rateLimited,
|
||||
|
||||
|
||||
unauthorized,
|
||||
|
||||
|
||||
transient,
|
||||
}
|
||||
|
||||
|
||||
class TraktScrobbleOutcome {
|
||||
final TraktResponseClass cls;
|
||||
|
||||
|
||||
final Duration? retryAfter;
|
||||
|
||||
const TraktScrobbleOutcome(this.cls, {this.retryAfter});
|
||||
}
|
||||
|
||||
|
||||
TraktResponseClass classifyTraktStatus(int statusCode) {
|
||||
if (statusCode >= 200 && statusCode < 300) return TraktResponseClass.success;
|
||||
switch (statusCode) {
|
||||
case 401:
|
||||
return TraktResponseClass.unauthorized;
|
||||
case 409:
|
||||
return TraktResponseClass.duplicate;
|
||||
case 422:
|
||||
return TraktResponseClass.invalid;
|
||||
case 429:
|
||||
return TraktResponseClass.rateLimited;
|
||||
default:
|
||||
return TraktResponseClass.transient;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import 'trakt_ids.dart';
|
||||
|
||||
|
||||
enum TraktMediaKind { movie, episode }
|
||||
|
||||
|
||||
class TraktScrobbleTarget {
|
||||
final TraktMediaKind kind;
|
||||
|
||||
final String title;
|
||||
final int? year;
|
||||
final TraktIds ids;
|
||||
|
||||
final int? season;
|
||||
final int? number;
|
||||
final TraktIds episodeIds;
|
||||
|
||||
const TraktScrobbleTarget._({
|
||||
required this.kind,
|
||||
required this.title,
|
||||
required this.year,
|
||||
required this.ids,
|
||||
this.season,
|
||||
this.number,
|
||||
this.episodeIds = const TraktIds(),
|
||||
});
|
||||
|
||||
factory TraktScrobbleTarget.movie({
|
||||
required String title,
|
||||
required int? year,
|
||||
required TraktIds ids,
|
||||
}) {
|
||||
return TraktScrobbleTarget._(
|
||||
kind: TraktMediaKind.movie,
|
||||
title: title,
|
||||
year: year,
|
||||
ids: ids,
|
||||
);
|
||||
}
|
||||
|
||||
factory TraktScrobbleTarget.episode({
|
||||
required String showTitle,
|
||||
required int? showYear,
|
||||
required TraktIds showIds,
|
||||
required int? season,
|
||||
required int? number,
|
||||
required TraktIds episodeIds,
|
||||
}) {
|
||||
return TraktScrobbleTarget._(
|
||||
kind: TraktMediaKind.episode,
|
||||
title: showTitle,
|
||||
year: showYear,
|
||||
ids: showIds,
|
||||
season: season,
|
||||
number: number,
|
||||
episodeIds: episodeIds,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Map<String, dynamic> toBody({
|
||||
required double progress,
|
||||
String? appVersion,
|
||||
String? appDate,
|
||||
}) {
|
||||
final body = <String, dynamic>{};
|
||||
|
||||
switch (kind) {
|
||||
case TraktMediaKind.movie:
|
||||
body['movie'] = _mediaNode(title, year, ids);
|
||||
case TraktMediaKind.episode:
|
||||
body['show'] = _mediaNode(title, year, ids);
|
||||
final episode = <String, dynamic>{'season': season, 'number': number};
|
||||
final epIds = episodeIds.toJson();
|
||||
if (epIds.isNotEmpty) episode['ids'] = epIds;
|
||||
body['episode'] = episode;
|
||||
}
|
||||
|
||||
body['progress'] = progress.toDouble();
|
||||
if (appVersion != null && appVersion.isNotEmpty) {
|
||||
body['app_version'] = appVersion;
|
||||
}
|
||||
if (appDate != null && appDate.isNotEmpty) body['app_date'] = appDate;
|
||||
return body;
|
||||
}
|
||||
|
||||
static Map<String, dynamic> _mediaNode(
|
||||
String title,
|
||||
int? year,
|
||||
TraktIds ids,
|
||||
) {
|
||||
final node = <String, dynamic>{'title': title};
|
||||
if (year != null && year > 0) node['year'] = year;
|
||||
node['ids'] = ids.toJson();
|
||||
return node;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
enum TraktSyncJobType {
|
||||
scrobbleStart('scrobble_start'),
|
||||
scrobblePause('scrobble_pause'),
|
||||
scrobbleStop('scrobble_stop'),
|
||||
historyAdd('history_add'),
|
||||
historyRemove('history_remove');
|
||||
|
||||
const TraktSyncJobType(this.wire);
|
||||
|
||||
|
||||
final String wire;
|
||||
|
||||
bool get isHistory => this == historyAdd || this == historyRemove;
|
||||
|
||||
static TraktSyncJobType fromWire(String wire) {
|
||||
return TraktSyncJobType.values.firstWhere(
|
||||
(e) => e.wire == wire,
|
||||
orElse: () => TraktSyncJobType.scrobbleStart,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class TraktSyncJob {
|
||||
final String id;
|
||||
final TraktSyncJobType type;
|
||||
final Map<String, dynamic> body;
|
||||
final int retryCount;
|
||||
final DateTime? nextRetryAt;
|
||||
final bool exhausted;
|
||||
|
||||
const TraktSyncJob({
|
||||
required this.id,
|
||||
required this.type,
|
||||
required this.body,
|
||||
this.retryCount = 0,
|
||||
this.nextRetryAt,
|
||||
this.exhausted = false,
|
||||
});
|
||||
|
||||
TraktSyncJob copyWith({
|
||||
int? retryCount,
|
||||
DateTime? nextRetryAt,
|
||||
bool clearNextRetryAt = false,
|
||||
bool? exhausted,
|
||||
}) {
|
||||
return TraktSyncJob(
|
||||
id: id,
|
||||
type: type,
|
||||
body: body,
|
||||
retryCount: retryCount ?? this.retryCount,
|
||||
nextRetryAt: clearNextRetryAt ? null : (nextRetryAt ?? this.nextRetryAt),
|
||||
exhausted: exhausted ?? this.exhausted,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'type': type.wire,
|
||||
'body': body,
|
||||
'retryCount': retryCount,
|
||||
'nextRetryAt': nextRetryAt?.toIso8601String(),
|
||||
'exhausted': exhausted,
|
||||
};
|
||||
|
||||
factory TraktSyncJob.fromJson(Map<String, dynamic> json) {
|
||||
return TraktSyncJob(
|
||||
id: json['id'] as String,
|
||||
type: TraktSyncJobType.fromWire(json['type'] as String? ?? ''),
|
||||
body: (json['body'] as Map?)?.cast<String, dynamic>() ?? const {},
|
||||
retryCount: (json['retryCount'] as num?)?.toInt() ?? 0,
|
||||
nextRetryAt: _parseDate(json['nextRetryAt']),
|
||||
exhausted: json['exhausted'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
static DateTime? _parseDate(Object? raw) {
|
||||
if (raw is! String || raw.isEmpty) return null;
|
||||
return DateTime.tryParse(raw);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'trakt_token.freezed.dart';
|
||||
part 'trakt_token.g.dart';
|
||||
|
||||
|
||||
@freezed
|
||||
abstract class TraktToken with _$TraktToken {
|
||||
const factory TraktToken({
|
||||
@JsonKey(name: 'access_token') @Default('') String accessToken,
|
||||
@JsonKey(name: 'refresh_token') @Default('') String refreshToken,
|
||||
@JsonKey(name: 'expires_in') @Default(0) int expiresIn,
|
||||
@JsonKey(name: 'created_at') @Default(0) int createdAt,
|
||||
@JsonKey(name: 'token_type') @Default('') String tokenType,
|
||||
@Default('') String scope,
|
||||
}) = _TraktToken;
|
||||
|
||||
factory TraktToken.fromJson(Map<String, dynamic> json) =>
|
||||
_$TraktTokenFromJson(json);
|
||||
}
|
||||
+292
@@ -0,0 +1,292 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// 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 'trakt_token.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$TraktToken {
|
||||
|
||||
@JsonKey(name: 'access_token') String get accessToken;@JsonKey(name: 'refresh_token') String get refreshToken;@JsonKey(name: 'expires_in') int get expiresIn;@JsonKey(name: 'created_at') int get createdAt;@JsonKey(name: 'token_type') String get tokenType; String get scope;
|
||||
/// Create a copy of TraktToken
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$TraktTokenCopyWith<TraktToken> get copyWith => _$TraktTokenCopyWithImpl<TraktToken>(this as TraktToken, _$identity);
|
||||
|
||||
/// Serializes this TraktToken to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is TraktToken&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.tokenType, tokenType) || other.tokenType == tokenType)&&(identical(other.scope, scope) || other.scope == scope));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,accessToken,refreshToken,expiresIn,createdAt,tokenType,scope);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktToken(accessToken: $accessToken, refreshToken: $refreshToken, expiresIn: $expiresIn, createdAt: $createdAt, tokenType: $tokenType, scope: $scope)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $TraktTokenCopyWith<$Res> {
|
||||
factory $TraktTokenCopyWith(TraktToken value, $Res Function(TraktToken) _then) = _$TraktTokenCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'access_token') String accessToken,@JsonKey(name: 'refresh_token') String refreshToken,@JsonKey(name: 'expires_in') int expiresIn,@JsonKey(name: 'created_at') int createdAt,@JsonKey(name: 'token_type') String tokenType, String scope
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$TraktTokenCopyWithImpl<$Res>
|
||||
implements $TraktTokenCopyWith<$Res> {
|
||||
_$TraktTokenCopyWithImpl(this._self, this._then);
|
||||
|
||||
final TraktToken _self;
|
||||
final $Res Function(TraktToken) _then;
|
||||
|
||||
/// Create a copy of TraktToken
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? accessToken = null,Object? refreshToken = null,Object? expiresIn = null,Object? createdAt = null,Object? tokenType = null,Object? scope = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
accessToken: null == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,refreshToken: null == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,tokenType: null == tokenType ? _self.tokenType : tokenType // ignore: cast_nullable_to_non_nullable
|
||||
as String,scope: null == scope ? _self.scope : scope // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [TraktToken].
|
||||
extension TraktTokenPatterns on TraktToken {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _TraktToken value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _TraktToken value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _TraktToken value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_in') int expiresIn, @JsonKey(name: 'created_at') int createdAt, @JsonKey(name: 'token_type') String tokenType, String scope)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken() when $default != null:
|
||||
return $default(_that.accessToken,_that.refreshToken,_that.expiresIn,_that.createdAt,_that.tokenType,_that.scope);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_in') int expiresIn, @JsonKey(name: 'created_at') int createdAt, @JsonKey(name: 'token_type') String tokenType, String scope) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken():
|
||||
return $default(_that.accessToken,_that.refreshToken,_that.expiresIn,_that.createdAt,_that.tokenType,_that.scope);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(name: 'access_token') String accessToken, @JsonKey(name: 'refresh_token') String refreshToken, @JsonKey(name: 'expires_in') int expiresIn, @JsonKey(name: 'created_at') int createdAt, @JsonKey(name: 'token_type') String tokenType, String scope)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktToken() when $default != null:
|
||||
return $default(_that.accessToken,_that.refreshToken,_that.expiresIn,_that.createdAt,_that.tokenType,_that.scope);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _TraktToken implements TraktToken {
|
||||
const _TraktToken({@JsonKey(name: 'access_token') this.accessToken = '', @JsonKey(name: 'refresh_token') this.refreshToken = '', @JsonKey(name: 'expires_in') this.expiresIn = 0, @JsonKey(name: 'created_at') this.createdAt = 0, @JsonKey(name: 'token_type') this.tokenType = '', this.scope = ''});
|
||||
factory _TraktToken.fromJson(Map<String, dynamic> json) => _$TraktTokenFromJson(json);
|
||||
|
||||
@override@JsonKey(name: 'access_token') final String accessToken;
|
||||
@override@JsonKey(name: 'refresh_token') final String refreshToken;
|
||||
@override@JsonKey(name: 'expires_in') final int expiresIn;
|
||||
@override@JsonKey(name: 'created_at') final int createdAt;
|
||||
@override@JsonKey(name: 'token_type') final String tokenType;
|
||||
@override@JsonKey() final String scope;
|
||||
|
||||
/// Create a copy of TraktToken
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$TraktTokenCopyWith<_TraktToken> get copyWith => __$TraktTokenCopyWithImpl<_TraktToken>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$TraktTokenToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TraktToken&&(identical(other.accessToken, accessToken) || other.accessToken == accessToken)&&(identical(other.refreshToken, refreshToken) || other.refreshToken == refreshToken)&&(identical(other.expiresIn, expiresIn) || other.expiresIn == expiresIn)&&(identical(other.createdAt, createdAt) || other.createdAt == createdAt)&&(identical(other.tokenType, tokenType) || other.tokenType == tokenType)&&(identical(other.scope, scope) || other.scope == scope));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,accessToken,refreshToken,expiresIn,createdAt,tokenType,scope);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktToken(accessToken: $accessToken, refreshToken: $refreshToken, expiresIn: $expiresIn, createdAt: $createdAt, tokenType: $tokenType, scope: $scope)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$TraktTokenCopyWith<$Res> implements $TraktTokenCopyWith<$Res> {
|
||||
factory _$TraktTokenCopyWith(_TraktToken value, $Res Function(_TraktToken) _then) = __$TraktTokenCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
@JsonKey(name: 'access_token') String accessToken,@JsonKey(name: 'refresh_token') String refreshToken,@JsonKey(name: 'expires_in') int expiresIn,@JsonKey(name: 'created_at') int createdAt,@JsonKey(name: 'token_type') String tokenType, String scope
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$TraktTokenCopyWithImpl<$Res>
|
||||
implements _$TraktTokenCopyWith<$Res> {
|
||||
__$TraktTokenCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _TraktToken _self;
|
||||
final $Res Function(_TraktToken) _then;
|
||||
|
||||
/// Create a copy of TraktToken
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? accessToken = null,Object? refreshToken = null,Object? expiresIn = null,Object? createdAt = null,Object? tokenType = null,Object? scope = null,}) {
|
||||
return _then(_TraktToken(
|
||||
accessToken: null == accessToken ? _self.accessToken : accessToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,refreshToken: null == refreshToken ? _self.refreshToken : refreshToken // ignore: cast_nullable_to_non_nullable
|
||||
as String,expiresIn: null == expiresIn ? _self.expiresIn : expiresIn // ignore: cast_nullable_to_non_nullable
|
||||
as int,createdAt: null == createdAt ? _self.createdAt : createdAt // ignore: cast_nullable_to_non_nullable
|
||||
as int,tokenType: null == tokenType ? _self.tokenType : tokenType // ignore: cast_nullable_to_non_nullable
|
||||
as String,scope: null == scope ? _self.scope : scope // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dart format on
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'trakt_token.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_TraktToken _$TraktTokenFromJson(Map<String, dynamic> json) => _TraktToken(
|
||||
accessToken: json['access_token'] as String? ?? '',
|
||||
refreshToken: json['refresh_token'] as String? ?? '',
|
||||
expiresIn: (json['expires_in'] as num?)?.toInt() ?? 0,
|
||||
createdAt: (json['created_at'] as num?)?.toInt() ?? 0,
|
||||
tokenType: json['token_type'] as String? ?? '',
|
||||
scope: json['scope'] as String? ?? '',
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TraktTokenToJson(_TraktToken instance) =>
|
||||
<String, dynamic>{
|
||||
'access_token': instance.accessToken,
|
||||
'refresh_token': instance.refreshToken,
|
||||
'expires_in': instance.expiresIn,
|
||||
'created_at': instance.createdAt,
|
||||
'token_type': instance.tokenType,
|
||||
'scope': instance.scope,
|
||||
};
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'trakt_user.freezed.dart';
|
||||
part 'trakt_user.g.dart';
|
||||
|
||||
|
||||
@freezed
|
||||
abstract class TraktUser with _$TraktUser {
|
||||
const factory TraktUser({@Default('') String username}) = _TraktUser;
|
||||
|
||||
factory TraktUser.fromJson(Map<String, dynamic> json) =>
|
||||
_$TraktUserFromJson(json);
|
||||
}
|
||||
|
||||
|
||||
@freezed
|
||||
abstract class TraktUserSettings with _$TraktUserSettings {
|
||||
const factory TraktUserSettings({TraktUser? user}) = _TraktUserSettings;
|
||||
|
||||
factory TraktUserSettings.fromJson(Map<String, dynamic> json) =>
|
||||
_$TraktUserSettingsFromJson(json);
|
||||
}
|
||||
+564
@@ -0,0 +1,564 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// coverage:ignore-file
|
||||
// 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 'trakt_user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
// dart format off
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
/// @nodoc
|
||||
mixin _$TraktUser {
|
||||
|
||||
String get username;
|
||||
/// Create a copy of TraktUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$TraktUserCopyWith<TraktUser> get copyWith => _$TraktUserCopyWithImpl<TraktUser>(this as TraktUser, _$identity);
|
||||
|
||||
/// Serializes this TraktUser to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is TraktUser&&(identical(other.username, username) || other.username == username));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,username);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktUser(username: $username)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $TraktUserCopyWith<$Res> {
|
||||
factory $TraktUserCopyWith(TraktUser value, $Res Function(TraktUser) _then) = _$TraktUserCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
String username
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$TraktUserCopyWithImpl<$Res>
|
||||
implements $TraktUserCopyWith<$Res> {
|
||||
_$TraktUserCopyWithImpl(this._self, this._then);
|
||||
|
||||
final TraktUser _self;
|
||||
final $Res Function(TraktUser) _then;
|
||||
|
||||
/// Create a copy of TraktUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? username = null,}) {
|
||||
return _then(_self.copyWith(
|
||||
username: null == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [TraktUser].
|
||||
extension TraktUserPatterns on TraktUser {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _TraktUser value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _TraktUser value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _TraktUser value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String username)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser() when $default != null:
|
||||
return $default(_that.username);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String username) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser():
|
||||
return $default(_that.username);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String username)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUser() when $default != null:
|
||||
return $default(_that.username);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _TraktUser implements TraktUser {
|
||||
const _TraktUser({this.username = ''});
|
||||
factory _TraktUser.fromJson(Map<String, dynamic> json) => _$TraktUserFromJson(json);
|
||||
|
||||
@override@JsonKey() final String username;
|
||||
|
||||
/// Create a copy of TraktUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$TraktUserCopyWith<_TraktUser> get copyWith => __$TraktUserCopyWithImpl<_TraktUser>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$TraktUserToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TraktUser&&(identical(other.username, username) || other.username == username));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,username);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktUser(username: $username)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$TraktUserCopyWith<$Res> implements $TraktUserCopyWith<$Res> {
|
||||
factory _$TraktUserCopyWith(_TraktUser value, $Res Function(_TraktUser) _then) = __$TraktUserCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
String username
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$TraktUserCopyWithImpl<$Res>
|
||||
implements _$TraktUserCopyWith<$Res> {
|
||||
__$TraktUserCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _TraktUser _self;
|
||||
final $Res Function(_TraktUser) _then;
|
||||
|
||||
/// Create a copy of TraktUser
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? username = null,}) {
|
||||
return _then(_TraktUser(
|
||||
username: null == username ? _self.username : username // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// @nodoc
|
||||
mixin _$TraktUserSettings {
|
||||
|
||||
TraktUser? get user;
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
$TraktUserSettingsCopyWith<TraktUserSettings> get copyWith => _$TraktUserSettingsCopyWithImpl<TraktUserSettings>(this as TraktUserSettings, _$identity);
|
||||
|
||||
/// Serializes this TraktUserSettings to a JSON map.
|
||||
Map<String, dynamic> toJson();
|
||||
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is TraktUserSettings&&(identical(other.user, user) || other.user == user));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,user);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktUserSettings(user: $user)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class $TraktUserSettingsCopyWith<$Res> {
|
||||
factory $TraktUserSettingsCopyWith(TraktUserSettings value, $Res Function(TraktUserSettings) _then) = _$TraktUserSettingsCopyWithImpl;
|
||||
@useResult
|
||||
$Res call({
|
||||
TraktUser? user
|
||||
});
|
||||
|
||||
|
||||
$TraktUserCopyWith<$Res>? get user;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class _$TraktUserSettingsCopyWithImpl<$Res>
|
||||
implements $TraktUserSettingsCopyWith<$Res> {
|
||||
_$TraktUserSettingsCopyWithImpl(this._self, this._then);
|
||||
|
||||
final TraktUserSettings _self;
|
||||
final $Res Function(TraktUserSettings) _then;
|
||||
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline') @override $Res call({Object? user = freezed,}) {
|
||||
return _then(_self.copyWith(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as TraktUser?,
|
||||
));
|
||||
}
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$TraktUserCopyWith<$Res>? get user {
|
||||
if (_self.user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $TraktUserCopyWith<$Res>(_self.user!, (value) {
|
||||
return _then(_self.copyWith(user: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Adds pattern-matching-related methods to [TraktUserSettings].
|
||||
extension TraktUserSettingsPatterns on TraktUserSettings {
|
||||
/// A variant of `map` that fallback to returning `orElse`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _TraktUserSettings value)? $default,{required TResult orElse(),}){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// Callbacks receives the raw object, upcasted.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case final Subclass2 value:
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _TraktUserSettings value) $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings():
|
||||
return $default(_that);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `map` that fallback to returning `null`.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case final Subclass value:
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _TraktUserSettings value)? $default,){
|
||||
final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings() when $default != null:
|
||||
return $default(_that);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to an `orElse` callback.
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return orElse();
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( TraktUser? user)? $default,{required TResult orElse(),}) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings() when $default != null:
|
||||
return $default(_that.user);case _:
|
||||
return orElse();
|
||||
|
||||
}
|
||||
}
|
||||
/// A `switch`-like method, using callbacks.
|
||||
///
|
||||
/// As opposed to `map`, this offers destructuring.
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case Subclass2(:final field2):
|
||||
/// return ...;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( TraktUser? user) $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings():
|
||||
return $default(_that.user);case _:
|
||||
throw StateError('Unexpected subclass');
|
||||
|
||||
}
|
||||
}
|
||||
/// A variant of `when` that fallback to returning `null`
|
||||
///
|
||||
/// It is equivalent to doing:
|
||||
/// ```dart
|
||||
/// switch (sealedClass) {
|
||||
/// case Subclass(:final field):
|
||||
/// return ...;
|
||||
/// case _:
|
||||
/// return null;
|
||||
/// }
|
||||
/// ```
|
||||
|
||||
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( TraktUser? user)? $default,) {final _that = this;
|
||||
switch (_that) {
|
||||
case _TraktUserSettings() when $default != null:
|
||||
return $default(_that.user);case _:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
|
||||
class _TraktUserSettings implements TraktUserSettings {
|
||||
const _TraktUserSettings({this.user});
|
||||
factory _TraktUserSettings.fromJson(Map<String, dynamic> json) => _$TraktUserSettingsFromJson(json);
|
||||
|
||||
@override final TraktUser? user;
|
||||
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@pragma('vm:prefer-inline')
|
||||
_$TraktUserSettingsCopyWith<_TraktUserSettings> get copyWith => __$TraktUserSettingsCopyWithImpl<_TraktUserSettings>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$TraktUserSettingsToJson(this, );
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) || (other.runtimeType == runtimeType&&other is _TraktUserSettings&&(identical(other.user, user) || other.user == user));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType,user);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'TraktUserSettings(user: $user)';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract mixin class _$TraktUserSettingsCopyWith<$Res> implements $TraktUserSettingsCopyWith<$Res> {
|
||||
factory _$TraktUserSettingsCopyWith(_TraktUserSettings value, $Res Function(_TraktUserSettings) _then) = __$TraktUserSettingsCopyWithImpl;
|
||||
@override @useResult
|
||||
$Res call({
|
||||
TraktUser? user
|
||||
});
|
||||
|
||||
|
||||
@override $TraktUserCopyWith<$Res>? get user;
|
||||
|
||||
}
|
||||
/// @nodoc
|
||||
class __$TraktUserSettingsCopyWithImpl<$Res>
|
||||
implements _$TraktUserSettingsCopyWith<$Res> {
|
||||
__$TraktUserSettingsCopyWithImpl(this._self, this._then);
|
||||
|
||||
final _TraktUserSettings _self;
|
||||
final $Res Function(_TraktUserSettings) _then;
|
||||
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override @pragma('vm:prefer-inline') $Res call({Object? user = freezed,}) {
|
||||
return _then(_TraktUserSettings(
|
||||
user: freezed == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
||||
as TraktUser?,
|
||||
));
|
||||
}
|
||||
|
||||
/// Create a copy of TraktUserSettings
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
$TraktUserCopyWith<$Res>? get user {
|
||||
if (_self.user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $TraktUserCopyWith<$Res>(_self.user!, (value) {
|
||||
return _then(_self.copyWith(user: value));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// dart format on
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'trakt_user.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_TraktUser _$TraktUserFromJson(Map<String, dynamic> json) =>
|
||||
_TraktUser(username: json['username'] as String? ?? '');
|
||||
|
||||
Map<String, dynamic> _$TraktUserToJson(_TraktUser instance) =>
|
||||
<String, dynamic>{'username': instance.username};
|
||||
|
||||
_TraktUserSettings _$TraktUserSettingsFromJson(Map<String, dynamic> json) =>
|
||||
_TraktUserSettings(
|
||||
user: json['user'] == null
|
||||
? null
|
||||
: TraktUser.fromJson(json['user'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$TraktUserSettingsToJson(_TraktUserSettings instance) =>
|
||||
<String, dynamic>{'user': instance.user};
|
||||
Reference in New Issue
Block a user