Add example project

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

1
.env.example Normal file
View File

@ -0,0 +1 @@
TRIBUFU_API_KEY=""

2
.gitignore vendored
View File

@ -3,5 +3,7 @@ bin/
obj/
.DS_Store
.env
*.filters
*.user
desktop.ini

View File

@ -3,6 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="dotenv.net" Version="3.2.0" />
<PackageVersion Include="JsonSubTypes" Version="2.0.1" />
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
<PackageVersion Include="Polly" Version="8.1.0" />

View File

@ -3,16 +3,42 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu", "src\Tribufu\Tribufu.csproj", "{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Example", "src\Tribufu.Example\Tribufu.Example.csproj", "{D6392A29-E2DC-4050-B4C1-B279DD2D226D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|x64.ActiveCfg = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|x64.Build.0 = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|x86.ActiveCfg = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|x86.Build.0 = Debug|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|Any CPU.Build.0 = Release|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|x64.ActiveCfg = Release|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|x64.Build.0 = Release|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|x86.ActiveCfg = Release|Any CPU
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|x86.Build.0 = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|x64.ActiveCfg = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|x64.Build.0 = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|x86.ActiveCfg = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Debug|x86.Build.0 = Debug|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|Any CPU.Build.0 = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|x64.ActiveCfg = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|x64.Build.0 = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|x86.ActiveCfg = Release|Any CPU
{D6392A29-E2DC-4050-B4C1-B279DD2D226D}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

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" />