mirror of
https://github.com/tribufu/tribufu-dotnet
synced 2025-06-16 10:24:18 +00:00
Add example project
This commit is contained in:
1
.env.example
Normal file
1
.env.example
Normal file
@ -0,0 +1 @@
|
|||||||
|
TRIBUFU_API_KEY=""
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,5 +3,7 @@ bin/
|
|||||||
obj/
|
obj/
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env
|
||||||
*.filters
|
*.filters
|
||||||
*.user
|
*.user
|
||||||
|
desktop.ini
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageVersion Include="dotenv.net" Version="3.2.0" />
|
||||||
<PackageVersion Include="JsonSubTypes" Version="2.0.1" />
|
<PackageVersion Include="JsonSubTypes" Version="2.0.1" />
|
||||||
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageVersion Include="Polly" Version="8.1.0" />
|
<PackageVersion Include="Polly" Version="8.1.0" />
|
||||||
|
26
Tribufu.sln
26
Tribufu.sln
@ -3,16 +3,42 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu", "src\Tribufu\Tribufu.csproj", "{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu", "src\Tribufu\Tribufu.csproj", "{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tribufu.Example", "src\Tribufu.Example\Tribufu.Example.csproj", "{D6392A29-E2DC-4050-B4C1-B279DD2D226D}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
Release|Any CPU = Release|Any CPU
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{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|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.ActiveCfg = Release|Any CPU
|
||||||
{7B7890D8-863A-4F1D-98C0-4B7D8C46CB52}.Release|Any CPU.Build.0 = 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
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
44
src/Tribufu.Example/Program.cs
Normal file
44
src/Tribufu.Example/Program.cs
Normal 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/Tribufu.Example/Tribufu.Example.csproj
Normal file
11
src/Tribufu.Example/Tribufu.Example.csproj
Normal 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>
|
@ -17,6 +17,7 @@
|
|||||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="dotenv.net" />
|
||||||
<PackageReference Include="JsonSubTypes" />
|
<PackageReference Include="JsonSubTypes" />
|
||||||
<PackageReference Include="Newtonsoft.Json" />
|
<PackageReference Include="Newtonsoft.Json" />
|
||||||
<PackageReference Include="Polly" />
|
<PackageReference Include="Polly" />
|
||||||
|
Reference in New Issue
Block a user