Add example project

This commit is contained in:
Guilherme Werner 2025-05-26 20:40:04 -03:00
parent f65b2a5912
commit 42f42637b2
7 changed files with 86 additions and 0 deletions

View file

@ -0,0 +1,44 @@
// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: UNLICENSED
using dotenv.net;
using Tribufu.Api;
using Tribufu.Client;
namespace Tribufu.Test
{
public static class Program
{
public static async Task Main(string[] args)
{
DotEnv.Load(new DotEnvOptions(ignoreExceptions: true, envFilePaths: [".env", "../../.env"]));
var config = new Configuration
{
BasePath = "https://api.tribufu.com"
};
var apiKey = Environment.GetEnvironmentVariable("TRIBUFU_API_KEY");
if (!string.IsNullOrEmpty(apiKey))
{
config.AddApiKey("Authorization", "DvyTVeT6EBsvqsPE1mRuW7ewwiP1f9playWE9wLTmdXnCuBQqBrluhU0p1KXYaRi");
config.AddApiKeyPrefix("Authorization", "ApiKey");
}
var tribufu = new TribufuApi(config);
try
{
var result = await tribufu.GetUserInfoAsync();
Console.WriteLine("Result:");
Console.WriteLine(result);
}
catch (ApiException e)
{
Console.WriteLine("---- API Error ----");
Console.WriteLine($"Status: {e.ErrorCode}");
Console.WriteLine($"Details: {e.Data}");
}
}
}
}

View file

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Tribufu\Tribufu.csproj" />
</ItemGroup>
</Project>

View file

@ -17,6 +17,7 @@
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="dotenv.net" />
<PackageReference Include="JsonSubTypes" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="Polly" />