44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Net;
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Json;
|
|
using System.Text.Encodings.Web;
|
|
using System.Text.Json;
|
|
using System.Text.Json.Serialization;
|
|
|
|
using YandexMusic.API.Common;
|
|
using YandexMusic.API.Models.Common;
|
|
using YandexMusic.API.Models.Queue;
|
|
using YandexMusic.API.Requests.Common;
|
|
using YandexMusic.API.Requests.Common.Attributes;
|
|
|
|
namespace YandexMusic.API.Requests.Queue;
|
|
|
|
[YApiRequest(WebRequestMethods.Http.Post, "queues")]
|
|
public class YQueueCreateBuilder : YRequestBuilder<YResponse<YNewQueue>, YQueue>
|
|
{
|
|
public YQueueCreateBuilder(YandexMusicApi yandex, AuthStorage auth, string? device = null) : base(yandex, auth)
|
|
{
|
|
if (device != null)
|
|
this.device = device;
|
|
}
|
|
|
|
protected override HttpContent GetContent(YQueue queue)
|
|
{
|
|
JsonSerializerOptions settings = new()
|
|
{
|
|
Converters = {
|
|
new JsonStringEnumConverter()
|
|
},
|
|
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
|
};
|
|
|
|
return JsonContent.Create(queue, new MediaTypeHeaderValue("application/json"), settings);
|
|
}
|
|
|
|
protected override void SetCustomHeaders(HttpRequestHeaders headers)
|
|
{
|
|
headers.Add("X-Yandex-Music-Device", device);
|
|
}
|
|
}
|