Add api client project
This commit is contained in:
14
MusicCast.Net.Test/MusicCast.Net.Test.csproj
Normal file
14
MusicCast.Net.Test/MusicCast.Net.Test.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\MusicCast.Net.Api.Client\MusicCast.Net.Api.Client.csproj" PrivateAssets="*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
39
MusicCast.Net.Test/Program.cs
Normal file
39
MusicCast.Net.Test/Program.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
// API requires no authentication, so use the anonymous
|
||||
// authentication provider
|
||||
|
||||
using System.Text.Json;
|
||||
using Microsoft.Kiota.Abstractions.Authentication;
|
||||
using Microsoft.Kiota.Http.HttpClientLibrary;
|
||||
using MusicCast.Net.Api.Client;
|
||||
using MusicCast.Net.Api.Client.YamahaExtendedControl.V1.Main.SetPower;
|
||||
|
||||
// API requires no authentication, so use the anonymous
|
||||
// authentication provider
|
||||
var authProvider = new AnonymousAuthenticationProvider();
|
||||
|
||||
// Create request adapter using the HttpClient-based implementation
|
||||
using var adapter = new HttpClientRequestAdapter(authProvider);
|
||||
adapter.BaseUrl = "http://192.168.129.21";
|
||||
|
||||
var client = new MusicCastApiClient(adapter);
|
||||
|
||||
var status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
|
||||
Console.WriteLine(status!.Power);
|
||||
|
||||
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(conf => conf.QueryParameters.Power = GetPowerQueryParameterType.On);
|
||||
|
||||
await Task.Delay(5000);
|
||||
|
||||
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
|
||||
Console.WriteLine(status!.Power);
|
||||
|
||||
await client.YamahaExtendedControl.V1.Main.SetPower.GetAsync(r =>
|
||||
r.QueryParameters.Power = GetPowerQueryParameterType.Standby
|
||||
);
|
||||
|
||||
await Task.Delay(5000);
|
||||
|
||||
status = await client.YamahaExtendedControl.V1.Main.GetStatus.GetAsync();
|
||||
Console.WriteLine(status!.Power);
|
||||
Reference in New Issue
Block a user