generated from deepgram-devs/oss-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Program.cs
65 lines (56 loc) · 2.15 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2024 Deepgram .NET SDK contributors. All Rights Reserved.
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
namespace SampleApp
{
class Program
{
static async Task Main(string[] args)
{
// Initialize Library with default logging
// Normal logging is "Info" level
Library.Initialize();
// use the client factory with a API Key set with the "DEEPGRAM_API_KEY" environment variable
var deepgramClient = ClientFactory.CreateManageClient();
var response = await deepgramClient.GetProjects();
if (response == null)
{
Console.WriteLine("No projects found.");
return;
}
Console.WriteLine($"\n\n{response}\n\n");
var projectId = "";
foreach (var project in response.Projects)
{
Console.WriteLine($"Using Project ID: {project.ProjectId}");
projectId = project.ProjectId;
break;
}
var balanacesResponse = await deepgramClient.GetBalances(projectId);
if (balanacesResponse == null)
{
Console.WriteLine("\n\nNo balance found.\n\n");
return;
}
Console.WriteLine($"\n\n{balanacesResponse}\n\n");
string balanceId = "";
foreach (var balance in balanacesResponse.Balances)
{
Console.WriteLine($"Using Balance ID: {balance.BalanceId}");
balanceId = balance.BalanceId;
break;
}
var balanceResponse = await deepgramClient.GetBalance(projectId, balanceId);
if (balanceResponse == null)
{
Console.WriteLine("\n\nNo balance found.\n\n");
return;
}
Console.WriteLine($"\n\n{balanceResponse}\n\n");
Console.WriteLine("\n\nPress any key to exit.");
Console.ReadKey();
// Teardown Library
Library.Terminate();
}
}
}