-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* gitignore: .idea * Queue API * Queue API Tests * Queue Client Tests * Yandex.Music.Api README.md Updated * Fix tests * Remove Console.WriteLine for debugging * Remove GetStringContent in favor of GetContent
- Loading branch information
Showing
24 changed files
with
552 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
################################################################################ | ||
# Данный GITIGNORE-файл был автоматически создан Microsoft(R) Visual Studio. | ||
################################################################################ | ||
|
||
.vs | ||
.vs | ||
.vscode | ||
/docs/build | ||
bin | ||
obj | ||
/output | ||
|
||
.idea | ||
|
||
/src/Yandex.Music.Api.Tests/appsettings.json | ||
/src/Yandex.Music.Client.Tests/appsettings.json | ||
/src/Yandex.Music.Api.sln.DotSettings.user | ||
/src/Yandex.Music.Api/Yandex.Music.Api.csproj.user | ||
src/Yandex.Music.Api/Yandex.Music.Api.csproj.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Collections.Generic; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Xunit.Extensions.Ordering; | ||
using Yandex.Music.Api.Models.Common; | ||
using Yandex.Music.Api.Models.Queue; | ||
using Yandex.Music.Api.Tests.Traits; | ||
|
||
namespace Yandex.Music.Api.Tests.Tests.API | ||
{ | ||
[Collection("Yandex Test Harness"), Order(9)] | ||
[TestBeforeAfter] | ||
public class QueueAPITest : YandexTest | ||
{ | ||
[Fact, YandexTrait(TraitGroup.QueueAPI)] | ||
[Order(0)] | ||
public void Create_ValidData_True() | ||
{ | ||
YResponse<YNewQueue> newQueue = Fixture.API.Queue.Create(Fixture.Storage, new YQueue | ||
{ | ||
Context = new YContext | ||
{ | ||
Description = "Сироп", | ||
Id = "track:819992702", | ||
Type = "radio" | ||
}, | ||
Tracks = new List<YTrackId> | ||
{ | ||
new() | ||
{ | ||
TrackId = "109253661", | ||
AlbumId = "24174855", | ||
From = "desktop_win-radio-radio_track_81999270-default" | ||
} | ||
}, | ||
CurrentIndex = null, | ||
From = "desktop_win-radio-radio_track_81999270-default", | ||
IsInteractive = true | ||
}); | ||
|
||
Fixture.NewQueue = newQueue.Result; | ||
|
||
Fixture.NewQueue.Id.Should().NotBeNullOrWhiteSpace(); | ||
} | ||
|
||
[Fact, YandexTrait(TraitGroup.QueueAPI)] | ||
[Order(1)] | ||
public void Get_ValidData_True() | ||
{ | ||
YResponse<YQueue> queue = Fixture.API.Queue.Get(Fixture.Storage, Fixture.NewQueue.Id); | ||
|
||
queue.Result.Id.Should().NotBeNullOrWhiteSpace(); | ||
} | ||
|
||
[Fact, YandexTrait(TraitGroup.QueueAPI)] | ||
[Order(2)] | ||
public void List_ValidData_True() | ||
{ | ||
YResponse<YQueueItemsContainer> queueItemsContainer = Fixture.API.Queue.List(Fixture.Storage); | ||
|
||
queueItemsContainer.Result.Queues.Count.Should().BeGreaterThan(0); | ||
} | ||
|
||
[Fact, YandexTrait(TraitGroup.QueueAPI)] | ||
[Order(3)] | ||
public void UpdatePosition_ValidData_True() | ||
{ | ||
YResponse<YUpdatedQueue> updatedQueue = Fixture.API.Queue.UpdatePosition(Fixture.Storage, Fixture.NewQueue.Id, 0, true); | ||
|
||
updatedQueue.Result.Status.Should().Be("ok"); | ||
} | ||
|
||
public QueueAPITest(YandexTestHarness fixture, ITestOutputHelper output) : base(fixture, output) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ public enum TraitGroup | |
RadioAPI, | ||
SearchAPI, | ||
TrackAPI, | ||
UserAPI | ||
UserAPI, | ||
QueueAPI | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Yandex.Music.Api.Common; | ||
using Yandex.Music.Api.Models.Common; | ||
using Yandex.Music.Api.Models.Queue; | ||
using Yandex.Music.Api.Requests.Queue; | ||
|
||
namespace Yandex.Music.Api.API | ||
{ | ||
/// <summary> | ||
/// API для взаимодействия с очередями | ||
/// </summary> | ||
public class YQueueAPI : YCommonAPI | ||
{ | ||
public YQueueAPI(YandexMusicApi yandex) : base(yandex) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Получение всех очередей треков с разных устройств для синхронизации между ними | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public Task<YResponse<YQueueItemsContainer>> ListAsync(AuthStorage storage, string device = null) | ||
{ | ||
return new YQueuesListBuilder(api, storage) | ||
.Build(device) | ||
.GetResponseAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Получение всех очередей треков с разных устройств для синхронизации между ними | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public YResponse<YQueueItemsContainer> List(AuthStorage storage, string device = null) | ||
{ | ||
return ListAsync(storage, device).GetAwaiter().GetResult(); | ||
} | ||
|
||
/// <summary> | ||
/// Получение очереди | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queueId">Идентификатор очереди</param> | ||
/// <returns></returns> | ||
public Task<YResponse<YQueue>> GetAsync(AuthStorage storage, string queueId) | ||
{ | ||
return new YGetQueueBuilder(api, storage) | ||
.Build(queueId) | ||
.GetResponseAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Получение очереди | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queueId">Идентификатор очереди</param> | ||
/// <returns></returns> | ||
public YResponse<YQueue> Get(AuthStorage storage, string queueId) | ||
{ | ||
return GetAsync(storage, queueId).GetAwaiter().GetResult(); | ||
} | ||
|
||
/// <summary> | ||
/// Создание новой очереди треков | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queue">Очередь треков</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public Task<YResponse<YNewQueue>> CreateAsync(AuthStorage storage, YQueue queue, string device = null) | ||
{ | ||
return new YQueueCreateBuilder(api, storage, device) | ||
.Build(queue) | ||
.GetResponseAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Создание новой очереди треков | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queue">Очередь треков</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public YResponse<YNewQueue> Create(AuthStorage storage, YQueue queue, string device = null) | ||
{ | ||
return CreateAsync(storage, queue, device).GetAwaiter().GetResult(); | ||
} | ||
|
||
/// <summary> | ||
/// Установка текущего индекса проигрываемого трека в очереди треков. | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queueId">Идентификатор очереди</param> | ||
/// <param name="currentIndex">Текущий индекс</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public Task<YResponse<YUpdatedQueue>> UpdatePositionAsync(AuthStorage storage, string queueId, int currentIndex, bool isInteractive, string device = null) | ||
{ | ||
return new YQueueUpdatePositionBuilder(api, storage, device) | ||
.Build((queueId, currentIndex, isInteractive)) | ||
.GetResponseAsync(); | ||
} | ||
|
||
/// <summary> | ||
/// Установка текущего индекса проигрываемого трека в очереди треков. | ||
/// </summary> | ||
/// <param name="storage">Хранилище</param> | ||
/// <param name="queueId">Идентификатор очереди</param> | ||
/// <param name="currentIndex">Текущий индекс</param> | ||
/// <param name="device">Устройство</param> | ||
/// <returns></returns> | ||
public YResponse<YUpdatedQueue> UpdatePosition(AuthStorage storage, string queueId, int currentIndex, bool isInteractive, string device = null) | ||
{ | ||
return UpdatePositionAsync(storage, queueId, currentIndex, isInteractive, device).GetAwaiter().GetResult(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Yandex.Music.Api.Models.Common | ||
{ | ||
public class YTrackId | ||
{ | ||
public string TrackId { get; set; } | ||
public string AlbumId { get; set; } | ||
public string From { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YContext | ||
{ | ||
public string Type { get; set; } | ||
public string Id { get; set; } | ||
public string Description { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Yandex.Music.Api.Models.Common; | ||
|
||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YNewQueue : YId | ||
{ | ||
public string Modified { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
using Yandex.Music.Api.Models.Common; | ||
|
||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YQueue | ||
{ | ||
public string Id { get; set; } | ||
public YContext Context { get; set; } | ||
public List<YTrackId> Tracks { get; set; } | ||
public int? CurrentIndex { get; set; } | ||
public string Modified { get; set; } | ||
public string From { get; set; } | ||
public bool IsInteractive { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YQueueItem | ||
{ | ||
public string Id { get; set; } | ||
public YContext Context { get; set; } | ||
public YContext InitialContext { get; set; } | ||
public string Modified { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YQueueItemsContainer | ||
{ | ||
public List<YQueueItem> Queues { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace Yandex.Music.Api.Models.Queue | ||
{ | ||
public class YUpdatedQueue | ||
{ | ||
public string Status { get; set; } | ||
public bool MostRecentQueue { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.