Обнновлено до .net10
This commit is contained in:
@@ -12,61 +12,60 @@ using YandexMusic.API.Models.Track;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Radio
|
||||
namespace YandexMusic.API.Requests.Radio;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "rotor/station/{type}:{tag}/feedback")]
|
||||
public class YSetStationFeedbackBuilder : YRequestBuilder<string, (YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds)>
|
||||
{
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "rotor/station/{type}:{tag}/feedback")]
|
||||
public class YSetStationFeedbackBuilder : YRequestBuilder<string, (YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds)>
|
||||
public YSetStationFeedbackBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
public YSetStationFeedbackBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "type", tuple.station.Station.Id.Type },
|
||||
{ "tag", tuple.station.Station.Id.Tag }
|
||||
};
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
{
|
||||
long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
||||
|
||||
JsonSerializerOptions settings = new()
|
||||
{
|
||||
}
|
||||
Converters = {
|
||||
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
|
||||
},
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
|
||||
};
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
YStationFeedback feedBack = new()
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "type", tuple.station.Station.Id.Type },
|
||||
{ "tag", tuple.station.Station.Id.Tag }
|
||||
};
|
||||
}
|
||||
Type = tuple.type,
|
||||
From = tuple.station.Station.IdForFrom,
|
||||
Timestamp = timestamp
|
||||
};
|
||||
|
||||
protected override HttpContent GetContent((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
{
|
||||
long timestamp = ((DateTimeOffset)DateTime.Now).ToUnixTimeSeconds();
|
||||
if (tuple.track != null)
|
||||
feedBack.TrackId = tuple.track.Id;
|
||||
|
||||
JsonSerializerOptions settings = new()
|
||||
{
|
||||
Converters = {
|
||||
new JsonStringEnumConverter(JsonNamingPolicy.CamelCase)
|
||||
},
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault
|
||||
};
|
||||
if (tuple.totalPlayedSeconds > 0)
|
||||
feedBack.TotalPlayedSeconds = tuple.totalPlayedSeconds;
|
||||
|
||||
YStationFeedback feedBack = new()
|
||||
{
|
||||
Type = tuple.type,
|
||||
From = tuple.station.Station.IdForFrom,
|
||||
Timestamp = timestamp
|
||||
};
|
||||
return JsonContent.Create(feedBack, new MediaTypeHeaderValue("application/json"), settings); ;
|
||||
}
|
||||
|
||||
if (tuple.track != null)
|
||||
feedBack.TrackId = tuple.track.Id;
|
||||
protected override NameValueCollection GetQueryParams((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
{
|
||||
NameValueCollection query = new();
|
||||
|
||||
if (tuple.totalPlayedSeconds > 0)
|
||||
feedBack.TotalPlayedSeconds = tuple.totalPlayedSeconds;
|
||||
if (!string.IsNullOrWhiteSpace(tuple.batchId))
|
||||
query.Add("batch-id", tuple.batchId);
|
||||
|
||||
return JsonContent.Create(feedBack, new MediaTypeHeaderValue("application/json"), settings); ;
|
||||
}
|
||||
|
||||
protected override NameValueCollection GetQueryParams((YStationFeedbackType type, YStation station, YTrack track, string batchId, double totalPlayedSeconds) tuple)
|
||||
{
|
||||
NameValueCollection query = new();
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tuple.batchId))
|
||||
query.Add("batch-id", tuple.batchId);
|
||||
|
||||
return query;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user