mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
feat: update models to match hetu_spotube_plugin signature
This commit is contained in:
parent
7a6821f28d
commit
3306f21860
@ -3,20 +3,40 @@ part of 'metadata.dart';
|
||||
enum SpotubeAlbumType {
|
||||
album,
|
||||
single,
|
||||
compilation,
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeAlbumObject with _$SpotubeAlbumObject {
|
||||
factory SpotubeAlbumObject({
|
||||
required final String uid,
|
||||
required final String title,
|
||||
required final SpotubeArtistObject artist,
|
||||
@Default([]) final List<SpotubeImageObject> images,
|
||||
required final String releaseDate,
|
||||
required final String externalUrl,
|
||||
required final SpotubeAlbumType type,
|
||||
}) = _SpotubeAlbumObject;
|
||||
class SpotubeFullAlbumObject with _$SpotubeFullAlbumObject {
|
||||
factory SpotubeFullAlbumObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required List<SpotubeSimpleArtistObject> artists,
|
||||
@Default([]) List<SpotubeImageObject> images,
|
||||
required String releaseDate,
|
||||
required String externalUri,
|
||||
required int totalTracks,
|
||||
required SpotubeAlbumType albumType,
|
||||
String? recordLabel,
|
||||
List<String>? genres,
|
||||
}) = _SpotubeFullAlbumObject;
|
||||
|
||||
factory SpotubeAlbumObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeAlbumObjectFromJson(json);
|
||||
factory SpotubeFullAlbumObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeFullAlbumObjectFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeSimpleAlbumObject with _$SpotubeSimpleAlbumObject {
|
||||
factory SpotubeSimpleAlbumObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String externalUri,
|
||||
required List<SpotubeSimpleArtistObject> artists,
|
||||
@Default([]) List<SpotubeImageObject> images,
|
||||
required String releaseDate,
|
||||
required SpotubeAlbumType albumType,
|
||||
}) = _SpotubeSimpleAlbumObject;
|
||||
|
||||
factory SpotubeSimpleAlbumObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeSimpleAlbumObjectFromJson(json);
|
||||
}
|
||||
|
@ -1,14 +1,28 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
@freezed
|
||||
class SpotubeArtistObject with _$SpotubeArtistObject {
|
||||
factory SpotubeArtistObject({
|
||||
required final String uid,
|
||||
required final String name,
|
||||
@Default([]) final List<SpotubeImageObject> images,
|
||||
required final String externalUrl,
|
||||
}) = _SpotubeArtistObject;
|
||||
class SpotubeFullArtistObject with _$SpotubeFullArtistObject {
|
||||
factory SpotubeFullArtistObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String externalUri,
|
||||
@Default([]) List<SpotubeImageObject> images,
|
||||
List<String>? genres,
|
||||
int? followers,
|
||||
}) = _SpotubeFullArtistObject;
|
||||
|
||||
factory SpotubeArtistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeArtistObjectFromJson(json);
|
||||
factory SpotubeFullArtistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeFullArtistObjectFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeSimpleArtistObject with _$SpotubeSimpleArtistObject {
|
||||
factory SpotubeSimpleArtistObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String externalUri,
|
||||
}) = _SpotubeSimpleArtistObject;
|
||||
|
||||
factory SpotubeSimpleArtistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeSimpleArtistObjectFromJson(json);
|
||||
}
|
||||
|
43
lib/models/metadata/browse.dart
Normal file
43
lib/models/metadata/browse.dart
Normal file
@ -0,0 +1,43 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
enum SectionItemType {
|
||||
@JsonValue("Playlist")
|
||||
playlist,
|
||||
@JsonValue("Album")
|
||||
album,
|
||||
@JsonValue("Artist")
|
||||
artist
|
||||
}
|
||||
|
||||
@Freezed(unionKey: "itemType")
|
||||
class SpotubeBrowseSectionObject with _$SpotubeBrowseSectionObject {
|
||||
@FreezedUnionValue("Album")
|
||||
factory SpotubeBrowseSectionObject.album({
|
||||
required String id,
|
||||
required String title,
|
||||
required String externalUri,
|
||||
required SectionItemType itemType,
|
||||
required List<SpotubeSimpleAlbumObject> items,
|
||||
}) = SpotubeBrowseAlbumSectionObject;
|
||||
|
||||
@FreezedUnionValue("Artist")
|
||||
factory SpotubeBrowseSectionObject.artist({
|
||||
required String id,
|
||||
required String title,
|
||||
required String externalUri,
|
||||
required SectionItemType itemType,
|
||||
required List<SpotubeSimpleArtistObject> items,
|
||||
}) = SpotubeBrowseArtistSectionObject;
|
||||
|
||||
@FreezedUnionValue("Playlist")
|
||||
factory SpotubeBrowseSectionObject.playlist({
|
||||
required String id,
|
||||
required String title,
|
||||
required String externalUri,
|
||||
required SectionItemType itemType,
|
||||
required List<SpotubeSimplePlaylistObject> items,
|
||||
}) = SpotubeBrowsePlaylistSectionObject;
|
||||
|
||||
factory SpotubeBrowseSectionObject.fromJson(Map<String, Object?> json) =>
|
||||
_$SpotubeBrowseSectionObjectFromJson(json);
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
@freezed
|
||||
class SpotubeFeedObject with _$SpotubeFeedObject {
|
||||
factory SpotubeFeedObject({
|
||||
required final String uid,
|
||||
required final String name,
|
||||
required final String externalUrl,
|
||||
@Default([]) final List<SpotubeImageObject> images,
|
||||
}) = _SpotubeFeedObject;
|
||||
|
||||
factory SpotubeFeedObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeFeedObjectFromJson(json);
|
||||
}
|
@ -7,7 +7,7 @@ part 'metadata.freezed.dart';
|
||||
|
||||
part 'album.dart';
|
||||
part 'artist.dart';
|
||||
part 'feed.dart';
|
||||
part 'browse.dart';
|
||||
part 'image.dart';
|
||||
part 'pagination.dart';
|
||||
part 'playlist.dart';
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -6,79 +6,196 @@ part of 'metadata.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$SpotubeAlbumObjectImpl _$$SpotubeAlbumObjectImplFromJson(Map json) =>
|
||||
_$SpotubeAlbumObjectImpl(
|
||||
uid: json['uid'] as String,
|
||||
title: json['title'] as String,
|
||||
artist: SpotubeArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(json['artist'] as Map)),
|
||||
_$SpotubeFullAlbumObjectImpl _$$SpotubeFullAlbumObjectImplFromJson(Map json) =>
|
||||
_$SpotubeFullAlbumObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
artists: (json['artists'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeImageObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
releaseDate: json['releaseDate'] as String,
|
||||
externalUrl: json['externalUrl'] as String,
|
||||
type: $enumDecode(_$SpotubeAlbumTypeEnumMap, json['type']),
|
||||
externalUri: json['externalUri'] as String,
|
||||
totalTracks: (json['totalTracks'] as num).toInt(),
|
||||
albumType: $enumDecode(_$SpotubeAlbumTypeEnumMap, json['albumType']),
|
||||
recordLabel: json['recordLabel'] as String?,
|
||||
genres:
|
||||
(json['genres'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeAlbumObjectImplToJson(
|
||||
_$SpotubeAlbumObjectImpl instance) =>
|
||||
Map<String, dynamic> _$$SpotubeFullAlbumObjectImplToJson(
|
||||
_$SpotubeFullAlbumObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'title': instance.title,
|
||||
'artist': instance.artist.toJson(),
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'artists': instance.artists.map((e) => e.toJson()).toList(),
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
'releaseDate': instance.releaseDate,
|
||||
'externalUrl': instance.externalUrl,
|
||||
'type': _$SpotubeAlbumTypeEnumMap[instance.type]!,
|
||||
'externalUri': instance.externalUri,
|
||||
'totalTracks': instance.totalTracks,
|
||||
'albumType': _$SpotubeAlbumTypeEnumMap[instance.albumType]!,
|
||||
'recordLabel': instance.recordLabel,
|
||||
'genres': instance.genres,
|
||||
};
|
||||
|
||||
const _$SpotubeAlbumTypeEnumMap = {
|
||||
SpotubeAlbumType.album: 'album',
|
||||
SpotubeAlbumType.single: 'single',
|
||||
SpotubeAlbumType.compilation: 'compilation',
|
||||
};
|
||||
|
||||
_$SpotubeArtistObjectImpl _$$SpotubeArtistObjectImplFromJson(Map json) =>
|
||||
_$SpotubeArtistObjectImpl(
|
||||
uid: json['uid'] as String,
|
||||
_$SpotubeSimpleAlbumObjectImpl _$$SpotubeSimpleAlbumObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeSimpleAlbumObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
artists: (json['artists'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeImageObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
externalUrl: json['externalUrl'] as String,
|
||||
releaseDate: json['releaseDate'] as String,
|
||||
albumType: $enumDecode(_$SpotubeAlbumTypeEnumMap, json['albumType']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeArtistObjectImplToJson(
|
||||
_$SpotubeArtistObjectImpl instance) =>
|
||||
Map<String, dynamic> _$$SpotubeSimpleAlbumObjectImplToJson(
|
||||
_$SpotubeSimpleAlbumObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'externalUri': instance.externalUri,
|
||||
'artists': instance.artists.map((e) => e.toJson()).toList(),
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
'externalUrl': instance.externalUrl,
|
||||
'releaseDate': instance.releaseDate,
|
||||
'albumType': _$SpotubeAlbumTypeEnumMap[instance.albumType]!,
|
||||
};
|
||||
|
||||
_$SpotubeFeedObjectImpl _$$SpotubeFeedObjectImplFromJson(Map json) =>
|
||||
_$SpotubeFeedObjectImpl(
|
||||
uid: json['uid'] as String,
|
||||
_$SpotubeFullArtistObjectImpl _$$SpotubeFullArtistObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeFullArtistObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
externalUrl: json['externalUrl'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeImageObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
genres:
|
||||
(json['genres'] as List<dynamic>?)?.map((e) => e as String).toList(),
|
||||
followers: (json['followers'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeFeedObjectImplToJson(
|
||||
_$SpotubeFeedObjectImpl instance) =>
|
||||
Map<String, dynamic> _$$SpotubeFullArtistObjectImplToJson(
|
||||
_$SpotubeFullArtistObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'externalUrl': instance.externalUrl,
|
||||
'externalUri': instance.externalUri,
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
'genres': instance.genres,
|
||||
'followers': instance.followers,
|
||||
};
|
||||
|
||||
_$SpotubeSimpleArtistObjectImpl _$$SpotubeSimpleArtistObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeSimpleArtistObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeSimpleArtistObjectImplToJson(
|
||||
_$SpotubeSimpleArtistObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'externalUri': instance.externalUri,
|
||||
};
|
||||
|
||||
_$SpotubeBrowseAlbumSectionObjectImpl
|
||||
_$$SpotubeBrowseAlbumSectionObjectImplFromJson(Map json) =>
|
||||
_$SpotubeBrowseAlbumSectionObjectImpl(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
itemType: $enumDecode(_$SectionItemTypeEnumMap, json['itemType']),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleAlbumObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeBrowseAlbumSectionObjectImplToJson(
|
||||
_$SpotubeBrowseAlbumSectionObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'externalUri': instance.externalUri,
|
||||
'itemType': _$SectionItemTypeEnumMap[instance.itemType]!,
|
||||
'items': instance.items.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
const _$SectionItemTypeEnumMap = {
|
||||
SectionItemType.playlist: 'Playlist',
|
||||
SectionItemType.album: 'Album',
|
||||
SectionItemType.artist: 'Artist',
|
||||
};
|
||||
|
||||
_$SpotubeBrowseArtistSectionObjectImpl
|
||||
_$$SpotubeBrowseArtistSectionObjectImplFromJson(Map json) =>
|
||||
_$SpotubeBrowseArtistSectionObjectImpl(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
itemType: $enumDecode(_$SectionItemTypeEnumMap, json['itemType']),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeBrowseArtistSectionObjectImplToJson(
|
||||
_$SpotubeBrowseArtistSectionObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'externalUri': instance.externalUri,
|
||||
'itemType': _$SectionItemTypeEnumMap[instance.itemType]!,
|
||||
'items': instance.items.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
_$SpotubeBrowsePlaylistSectionObjectImpl
|
||||
_$$SpotubeBrowsePlaylistSectionObjectImplFromJson(Map json) =>
|
||||
_$SpotubeBrowsePlaylistSectionObjectImpl(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
itemType: $enumDecode(_$SectionItemTypeEnumMap, json['itemType']),
|
||||
items: (json['items'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimplePlaylistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeBrowsePlaylistSectionObjectImplToJson(
|
||||
_$SpotubeBrowsePlaylistSectionObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'title': instance.title,
|
||||
'externalUri': instance.externalUri,
|
||||
'itemType': _$SectionItemTypeEnumMap[instance.itemType]!,
|
||||
'items': instance.items.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
_$SpotubeImageObjectImpl _$$SpotubeImageObjectImplFromJson(Map json) =>
|
||||
@ -102,9 +219,9 @@ _$SpotubePaginationResponseObjectImpl<T>
|
||||
T Function(Object? json) fromJsonT,
|
||||
) =>
|
||||
_$SpotubePaginationResponseObjectImpl<T>(
|
||||
limit: (json['limit'] as num).toInt(),
|
||||
nextOffset: (json['nextOffset'] as num?)?.toInt(),
|
||||
total: (json['total'] as num).toInt(),
|
||||
nextCursor: json['nextCursor'] as String?,
|
||||
limit: json['limit'] as String,
|
||||
hasMore: json['hasMore'] as bool,
|
||||
items: (json['items'] as List<dynamic>).map(fromJsonT).toList(),
|
||||
);
|
||||
@ -114,91 +231,166 @@ Map<String, dynamic> _$$SpotubePaginationResponseObjectImplToJson<T>(
|
||||
Object? Function(T value) toJsonT,
|
||||
) =>
|
||||
<String, dynamic>{
|
||||
'total': instance.total,
|
||||
'nextCursor': instance.nextCursor,
|
||||
'limit': instance.limit,
|
||||
'nextOffset': instance.nextOffset,
|
||||
'total': instance.total,
|
||||
'hasMore': instance.hasMore,
|
||||
'items': instance.items.map(toJsonT).toList(),
|
||||
};
|
||||
|
||||
_$SpotubePlaylistObjectImpl _$$SpotubePlaylistObjectImplFromJson(Map json) =>
|
||||
_$SpotubePlaylistObjectImpl(
|
||||
uid: json['uid'] as String,
|
||||
_$SpotubeFullPlaylistObjectImpl _$$SpotubeFullPlaylistObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeFullPlaylistObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
owner: SpotubeUserObject.fromJson(
|
||||
Map<String, dynamic>.from(json['owner'] as Map)),
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeImageObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
description: json['description'] as String,
|
||||
externalUrl: json['externalUrl'] as String,
|
||||
owner: SpotubeUserObject.fromJson(
|
||||
Map<String, dynamic>.from(json['owner'] as Map)),
|
||||
collaborators: (json['collaborators'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeUserObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
collaborative: json['collaborative'] as bool? ?? false,
|
||||
public: json['public'] as bool? ?? false,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubePlaylistObjectImplToJson(
|
||||
_$SpotubePlaylistObjectImpl instance) =>
|
||||
Map<String, dynamic> _$$SpotubeFullPlaylistObjectImplToJson(
|
||||
_$SpotubeFullPlaylistObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
'description': instance.description,
|
||||
'externalUrl': instance.externalUrl,
|
||||
'externalUri': instance.externalUri,
|
||||
'owner': instance.owner.toJson(),
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
'collaborators': instance.collaborators.map((e) => e.toJson()).toList(),
|
||||
'collaborative': instance.collaborative,
|
||||
'public': instance.public,
|
||||
};
|
||||
|
||||
_$SpotubeSimplePlaylistObjectImpl _$$SpotubeSimplePlaylistObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeSimplePlaylistObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
description: json['description'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
owner: SpotubeUserObject.fromJson(
|
||||
Map<String, dynamic>.from(json['owner'] as Map)),
|
||||
images: (json['images'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeImageObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeSimplePlaylistObjectImplToJson(
|
||||
_$SpotubeSimplePlaylistObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'description': instance.description,
|
||||
'externalUri': instance.externalUri,
|
||||
'owner': instance.owner.toJson(),
|
||||
'images': instance.images.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
_$SpotubeSearchResponseObjectImpl _$$SpotubeSearchResponseObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeSearchResponseObjectImpl(
|
||||
tracks: _paginationTracksFromJson(json['tracks'] as Map<String, dynamic>),
|
||||
albums: _paginationAlbumsFromJson(json['albums'] as Map<String, dynamic>),
|
||||
artists:
|
||||
_paginationArtistsFromJson(json['artists'] as Map<String, dynamic>),
|
||||
playlists: _paginationPlaylistsFromJson(
|
||||
json['playlists'] as Map<String, dynamic>),
|
||||
albums: (json['albums'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleAlbumObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
artists: (json['artists'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
playlists: (json['playlists'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimplePlaylistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
tracks: (json['tracks'] as List<dynamic>)
|
||||
.map((e) => SpotubeSimpleTrackObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeSearchResponseObjectImplToJson(
|
||||
_$SpotubeSearchResponseObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'tracks': _paginationToJson(instance.tracks),
|
||||
'albums': _paginationToJson(instance.albums),
|
||||
'artists': _paginationToJson(instance.artists),
|
||||
'playlists': _paginationToJson(instance.playlists),
|
||||
'albums': instance.albums.map((e) => e.toJson()).toList(),
|
||||
'artists': instance.artists.map((e) => e.toJson()).toList(),
|
||||
'playlists': instance.playlists.map((e) => e.toJson()).toList(),
|
||||
'tracks': instance.tracks.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
|
||||
_$SpotubeTrackObjectImpl _$$SpotubeTrackObjectImplFromJson(Map json) =>
|
||||
_$SpotubeTrackObjectImpl(
|
||||
uid: json['uid'] as String,
|
||||
title: json['title'] as String,
|
||||
_$SpotubeFullTrackObjectImpl _$$SpotubeFullTrackObjectImplFromJson(Map json) =>
|
||||
_$SpotubeFullTrackObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
artists: (json['artists'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeArtistObject.fromJson(
|
||||
?.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
album: SpotubeAlbumObject.fromJson(
|
||||
album: SpotubeSimpleAlbumObject.fromJson(
|
||||
Map<String, dynamic>.from(json['album'] as Map)),
|
||||
durationMs: (json['durationMs'] as num).toInt(),
|
||||
isrc: json['isrc'] as String,
|
||||
externalUrl: json['externalUrl'] as String,
|
||||
explicit: json['explicit'] as bool,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeTrackObjectImplToJson(
|
||||
_$SpotubeTrackObjectImpl instance) =>
|
||||
Map<String, dynamic> _$$SpotubeFullTrackObjectImplToJson(
|
||||
_$SpotubeFullTrackObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'uid': instance.uid,
|
||||
'title': instance.title,
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'externalUri': instance.externalUri,
|
||||
'artists': instance.artists.map((e) => e.toJson()).toList(),
|
||||
'album': instance.album.toJson(),
|
||||
'durationMs': instance.durationMs,
|
||||
'isrc': instance.isrc,
|
||||
'externalUrl': instance.externalUrl,
|
||||
'explicit': instance.explicit,
|
||||
};
|
||||
|
||||
_$SpotubeSimpleTrackObjectImpl _$$SpotubeSimpleTrackObjectImplFromJson(
|
||||
Map json) =>
|
||||
_$SpotubeSimpleTrackObjectImpl(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
externalUri: json['externalUri'] as String,
|
||||
durationMs: (json['durationMs'] as num).toInt(),
|
||||
explicit: json['explicit'] as bool,
|
||||
artists: (json['artists'] as List<dynamic>?)
|
||||
?.map((e) => SpotubeSimpleArtistObject.fromJson(
|
||||
Map<String, dynamic>.from(e as Map)))
|
||||
.toList() ??
|
||||
const [],
|
||||
album: json['album'] == null
|
||||
? null
|
||||
: SpotubeSimpleAlbumObject.fromJson(
|
||||
Map<String, dynamic>.from(json['album'] as Map)),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$SpotubeSimpleTrackObjectImplToJson(
|
||||
_$SpotubeSimpleTrackObjectImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'externalUri': instance.externalUri,
|
||||
'durationMs': instance.durationMs,
|
||||
'explicit': instance.explicit,
|
||||
'artists': instance.artists.map((e) => e.toJson()).toList(),
|
||||
'album': instance.album?.toJson(),
|
||||
};
|
||||
|
||||
_$SpotubeUserObjectImpl _$$SpotubeUserObjectImplFromJson(Map json) =>
|
||||
|
@ -4,9 +4,9 @@ part of 'metadata.dart';
|
||||
class SpotubePaginationResponseObject<T>
|
||||
with _$SpotubePaginationResponseObject {
|
||||
factory SpotubePaginationResponseObject({
|
||||
required int limit,
|
||||
required int? nextOffset,
|
||||
required int total,
|
||||
required String? nextCursor,
|
||||
required String limit,
|
||||
required bool hasMore,
|
||||
required List<T> items,
|
||||
}) = _SpotubePaginationResponseObject;
|
||||
|
@ -1,17 +1,34 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
@freezed
|
||||
class SpotubePlaylistObject with _$SpotubePlaylistObject {
|
||||
factory SpotubePlaylistObject({
|
||||
required final String uid,
|
||||
required final String name,
|
||||
@Default([]) final List<SpotubeImageObject> images,
|
||||
required final String description,
|
||||
required final String externalUrl,
|
||||
required final SpotubeUserObject owner,
|
||||
@Default([]) final List<SpotubeUserObject> collaborators,
|
||||
}) = _SpotubePlaylistObject;
|
||||
class SpotubeFullPlaylistObject with _$SpotubeFullPlaylistObject {
|
||||
factory SpotubeFullPlaylistObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String description,
|
||||
required String externalUri,
|
||||
required SpotubeUserObject owner,
|
||||
@Default([]) List<SpotubeImageObject> images,
|
||||
@Default([]) List<SpotubeUserObject> collaborators,
|
||||
@Default(false) bool collaborative,
|
||||
@Default(false) bool public,
|
||||
}) = _SpotubeFullPlaylistObject;
|
||||
|
||||
factory SpotubePlaylistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubePlaylistObjectFromJson(json);
|
||||
factory SpotubeFullPlaylistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeFullPlaylistObjectFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeSimplePlaylistObject with _$SpotubeSimplePlaylistObject {
|
||||
factory SpotubeSimplePlaylistObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String description,
|
||||
required String externalUri,
|
||||
required SpotubeUserObject owner,
|
||||
@Default([]) List<SpotubeImageObject> images,
|
||||
}) = _SpotubeSimplePlaylistObject;
|
||||
|
||||
factory SpotubeSimplePlaylistObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeSimplePlaylistObjectFromJson(json);
|
||||
}
|
||||
|
@ -1,71 +1,12 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
SpotubePaginationResponseObject<SpotubeTrackObject> _paginationTracksFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return SpotubePaginationResponseObject<SpotubeTrackObject>.fromJson(
|
||||
json,
|
||||
(json) => SpotubeTrackObject.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
SpotubePaginationResponseObject<SpotubeAlbumObject> _paginationAlbumsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return SpotubePaginationResponseObject<SpotubeAlbumObject>.fromJson(
|
||||
json,
|
||||
(json) => SpotubeAlbumObject.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
SpotubePaginationResponseObject<SpotubeArtistObject> _paginationArtistsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return SpotubePaginationResponseObject<SpotubeArtistObject>.fromJson(
|
||||
json,
|
||||
(json) => SpotubeArtistObject.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
SpotubePaginationResponseObject<SpotubePlaylistObject>
|
||||
_paginationPlaylistsFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) {
|
||||
return SpotubePaginationResponseObject<SpotubePlaylistObject>.fromJson(
|
||||
json,
|
||||
(json) => SpotubePlaylistObject.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic>? _paginationToJson(
|
||||
SpotubePaginationResponseObject? instance,
|
||||
) {
|
||||
return instance?.toJson((item) => item.toJson());
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeSearchResponseObject with _$SpotubeSearchResponseObject {
|
||||
factory SpotubeSearchResponseObject({
|
||||
@JsonKey(
|
||||
fromJson: _paginationTracksFromJson,
|
||||
toJson: _paginationToJson,
|
||||
)
|
||||
final SpotubePaginationResponseObject<SpotubeTrackObject>? tracks,
|
||||
@JsonKey(
|
||||
fromJson: _paginationAlbumsFromJson,
|
||||
toJson: _paginationToJson,
|
||||
)
|
||||
final SpotubePaginationResponseObject<SpotubeAlbumObject>? albums,
|
||||
@JsonKey(
|
||||
fromJson: _paginationArtistsFromJson,
|
||||
toJson: _paginationToJson,
|
||||
)
|
||||
final SpotubePaginationResponseObject<SpotubeArtistObject>? artists,
|
||||
@JsonKey(
|
||||
fromJson: _paginationPlaylistsFromJson,
|
||||
toJson: _paginationToJson,
|
||||
)
|
||||
final SpotubePaginationResponseObject<SpotubePlaylistObject>? playlists,
|
||||
required List<SpotubeSimpleAlbumObject> albums,
|
||||
required List<SpotubeSimpleArtistObject> artists,
|
||||
required List<SpotubeSimplePlaylistObject> playlists,
|
||||
required List<SpotubeSimpleTrackObject> tracks,
|
||||
}) = _SpotubeSearchResponseObject;
|
||||
|
||||
factory SpotubeSearchResponseObject.fromJson(Map<String, dynamic> json) =>
|
||||
|
@ -1,17 +1,34 @@
|
||||
part of 'metadata.dart';
|
||||
|
||||
@freezed
|
||||
class SpotubeTrackObject with _$SpotubeTrackObject {
|
||||
factory SpotubeTrackObject({
|
||||
required final String uid,
|
||||
required final String title,
|
||||
@Default([]) final List<SpotubeArtistObject> artists,
|
||||
required final SpotubeAlbumObject album,
|
||||
required final int durationMs,
|
||||
required final String isrc,
|
||||
required final String externalUrl,
|
||||
}) = _SpotubeTrackObject;
|
||||
class SpotubeFullTrackObject with _$SpotubeFullTrackObject {
|
||||
factory SpotubeFullTrackObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String externalUri,
|
||||
@Default([]) List<SpotubeSimpleArtistObject> artists,
|
||||
required SpotubeSimpleAlbumObject album,
|
||||
required int durationMs,
|
||||
required String isrc,
|
||||
required bool explicit,
|
||||
}) = _SpotubeFullTrackObject;
|
||||
|
||||
factory SpotubeTrackObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeTrackObjectFromJson(json);
|
||||
factory SpotubeFullTrackObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeFullTrackObjectFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
class SpotubeSimpleTrackObject with _$SpotubeSimpleTrackObject {
|
||||
factory SpotubeSimpleTrackObject({
|
||||
required String id,
|
||||
required String name,
|
||||
required String externalUri,
|
||||
required int durationMs,
|
||||
required bool explicit,
|
||||
@Default([]) List<SpotubeSimpleArtistObject> artists,
|
||||
SpotubeSimpleAlbumObject? album,
|
||||
}) = _SpotubeSimpleTrackObject;
|
||||
|
||||
factory SpotubeSimpleTrackObject.fromJson(Map<String, dynamic> json) =>
|
||||
_$SpotubeSimpleTrackObjectFromJson(json);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user