Skip to content

Commit

Permalink
Обновлены модели
Browse files Browse the repository at this point in the history
  • Loading branch information
K1llMan committed Jan 18, 2025
1 parent 6d2b21e commit 6a438fd
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Yandex.Music.Api/Models/Account/YAuthMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public enum YAuthMethod
Magic,
Otp,
[EnumMember(Value = "social_gg")]
Social
Social,
WebAuthN
}
}
3 changes: 3 additions & 0 deletions src/Yandex.Music.Api/Models/Album/YAlbum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

using Yandex.Music.Api.Models.Artist;
using Yandex.Music.Api.Models.Common;
using Yandex.Music.Api.Models.Common.Cover;
using Yandex.Music.Api.Models.Track;

namespace Yandex.Music.Api.Models.Album
Expand Down Expand Up @@ -66,6 +67,8 @@ public class YAlbum : YBaseModel
public bool ChildContent { get; set; }
public string ContentWarning { get; set; }
public string CoverUri { get; set; }
[JsonConverter(typeof(YCoverConverter))]
public YCover Cover { get; set; }
public YCustomWave CustomWave { get; set; }
public YDerivedColors DerivedColors { get; set; }
public string Description { get; set; }
Expand Down
7 changes: 7 additions & 0 deletions src/Yandex.Music.Api/Models/Common/Cover/YCover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
YCover cover;

try {
// Фиктивный тип, т.к. у такой обложки нет поля с типом
if (jObject["type"] == null)
jObject.Add("type", "color");

YCoverType type = jObject["error"] != null
? YCoverType.Error
: jObject["type"].ToObject<YCoverType>();
Expand All @@ -29,6 +33,9 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist
case YCoverType.Error:
cover = jObject.ToObject<YCoverError>();
break;
case YCoverType.Color:
cover = jObject.ToObject<YCoverColor>();
break;
case YCoverType.FromAlbumCover:
case YCoverType.FromArtistPhotos:
cover = jObject.ToObject<YCoverImage>();
Expand Down
8 changes: 8 additions & 0 deletions src/Yandex.Music.Api/Models/Common/Cover/YCoverColor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Yandex.Music.Api.Models.Common.Cover
{
public class YCoverColor : YCover
{
public string Uri { get; set; }
public string Color { get; set; }
}
}
1 change: 1 addition & 0 deletions src/Yandex.Music.Api/Models/Common/Cover/YCoverType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Yandex.Music.Api.Models.Common.Cover
[JsonConverter(typeof(StringEnumConverter))]
public enum YCoverType
{
Color,
Error,
[EnumMember(Value = "from-artist-photos")]
FromArtistPhotos,
Expand Down
4 changes: 4 additions & 0 deletions src/Yandex.Music.Api/Models/Feed/Event/YFeedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ private YFeedEventTitled GetEvent(JToken jObject)
feedEvent = jObject.ToObject<YFeedEventNotification>();
break;

case YFeedEventType.Promotion:
feedEvent = jObject.ToObject<YFeedEventPromotion>();
break;

case YFeedEventType.RecentTrackLikeToTracks:
feedEvent = jObject.ToObject<YFeedEventLikeTrack>();
break;
Expand Down
7 changes: 7 additions & 0 deletions src/Yandex.Music.Api/Models/Feed/Event/YFeedEventPromotion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Yandex.Music.Api.Models.Feed.Event
{
public class YFeedEventPromotion: YFeedEventTitled
{
public YFeedPromotion Promo { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Yandex.Music.Api.Models.Feed.Event
{
public enum YFeedEventPromotionType
{
Albums,
Tracks
}
}
2 changes: 2 additions & 0 deletions src/Yandex.Music.Api/Models/Feed/Event/YFeedEventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public enum YFeedEventType

Notification,

Promotion,

[EnumMember(Value = "rare-artist")]
RareArtist,

Expand Down
27 changes: 27 additions & 0 deletions src/Yandex.Music.Api/Models/Feed/Event/YFeedPromotion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;

using Yandex.Music.Api.Models.Album;
using Yandex.Music.Api.Models.Common;
using Yandex.Music.Api.Models.Track;

namespace Yandex.Music.Api.Models.Feed.Event
{
public class YFeedPromotion
{
public string PromoId { get; set; }
public string Description { get; set; }
public string Background { get; set; }
public string ImagePosition { get; set; }
public YFeedEventPromotionType PromotionType { get; set; }
public DateTime StartDate { get; set; }
public string SubTitle { get; set; }
public string SubtitleUrl { get; set; }
public string Title { get; set; }
public string TitleUrl { get; set; }
public List<YTag> Tags { get; set; }

public List<YAlbum> Albums { get; set; }
public List<YTrack> Tracks { get; set; }
}
}

0 comments on commit 6a438fd

Please # to comment.